Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
3.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: testinfo.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // testinfo.h: test file generation
  12. //
  13. #ifndef _TESTINFO_H_
  14. #define _TESTINFO_H_
  15. #include "cliqset.h" // Exact clique-based inference
  16. #include "clique.h" // Clique structure details
  17. #include "parmio.h" // Text Parameter streaming I/O
  18. #include "utility.h" // Entropic utility
  19. #include "recomend.h" // Troubleshooting recommendations
  20. typedef unsigned long ULONG;
  21. //
  22. // Options flags; first 16 bits are the pass count; i.e., number of times to run
  23. // the inference testing code for timing purposes.
  24. //
  25. const ULONG fPassCountMask = 0x0FFF;
  26. const ULONG fDistributions = 1<<15;
  27. const ULONG fImpossible = 1<<16;
  28. const ULONG fVerbose = 1<<17;
  29. const ULONG fCliquing = 1<<18;
  30. const ULONG fInference = 1<<19;
  31. const ULONG fMulti = 1<<20;
  32. const ULONG fOutputFile = 1<<21;
  33. const ULONG fShowTime = 1<<22;
  34. const ULONG fSaveDsc = 1<<23;
  35. const ULONG fPause = 1<<24;
  36. const ULONG fSymName = 1<<25;
  37. const ULONG fExpand = 1<<26;
  38. const ULONG fClone = 1<<27;
  39. const ULONG fUtil = 1<<28;
  40. const ULONG fReg = 1<<29;
  41. const ULONG fTSUtil = 1<<30;
  42. const ULONG fInferStats = 1<<31;
  43. // Declare a map from strings to pointers to nodes
  44. typedef map<ZSTR, GNODEMBND *, less<ZSTR> > MPSTRPND;
  45. class TESTINFO
  46. {
  47. public:
  48. TESTINFO ( ULONG fCtl, MBNETDSC & mbnet, ostream * pos = NULL )
  49. :_fCtl(fCtl),
  50. _mbnet(mbnet),
  51. _pos(pos),
  52. _pInferEng(NULL),
  53. _pmbUtil(NULL),
  54. _pmbRecom(NULL),
  55. _rImposs(-1.0),
  56. _clOut(0)
  57. {
  58. _pInferEng = mbnet.PInferEngine();
  59. assert( _pInferEng );
  60. if ( fCtl & fUtil )
  61. {
  62. _pmbUtil = new MBNET_ENTROPIC_UTILITY( *_pInferEng );
  63. }
  64. if ( fCtl & fTSUtil )
  65. {
  66. GOBJMBN_CLIQSET * pCliqueSet;
  67. DynCastThrow(_pInferEng, pCliqueSet);
  68. _pmbRecom = new MBNET_RECOMMENDER( *pCliqueSet );
  69. }
  70. }
  71. ~ TESTINFO ()
  72. {
  73. delete _pmbUtil;
  74. delete _pmbRecom;
  75. }
  76. void InferTest ();
  77. MBNET_ENTROPIC_UTILITY & MbUtil ()
  78. {
  79. assert( _pmbUtil );
  80. return *_pmbUtil;
  81. }
  82. MBNET_RECOMMENDER & MbRecom ()
  83. {
  84. assert( _pmbRecom );
  85. return *_pmbRecom;
  86. }
  87. MBNETDSC & Mbnet ()
  88. { return _mbnet; }
  89. GOBJMBN_INFER_ENGINE & InferEng ()
  90. {
  91. assert( _pInferEng );
  92. return *_pInferEng;
  93. }
  94. ostream * Postream ()
  95. { return _pos; }
  96. ostream & Ostream ()
  97. {
  98. assert( _pos );
  99. return *_pos;
  100. }
  101. MPSTRPND & Mpstrpnd ()
  102. { return _mpstrpnd; }
  103. ULONG FCtl ()
  104. { return _fCtl; }
  105. void GetUtilities ();
  106. void GetTSUtilities ();
  107. void GetBeliefs ();
  108. SZC SzcNdName ( GNODEMBN * pgnd );
  109. SZC SzcNdName ( ZSREF zsSymName );
  110. bool BFlag ( ULONG fFlag )
  111. {
  112. return (FCtl() & fFlag) > 0;
  113. }
  114. // Return a displayable string of the current options settings
  115. static ZSTR ZsOptions ( ULONG fFlag );
  116. public:
  117. ULONG _fCtl; // Control flags
  118. MBNETDSC & _mbnet; // The model to test
  119. MPSTRPND _mpstrpnd; // The set of nodes to use
  120. ostream * _pos; // The output stream or NULL
  121. REAL _rImposs; // The value to report for impossible probs
  122. int _clOut; // Output line counter
  123. protected:
  124. GOBJMBN_INFER_ENGINE * _pInferEng;
  125. MBNET_ENTROPIC_UTILITY * _pmbUtil;
  126. MBNET_RECOMMENDER * _pmbRecom;
  127. };
  128. #endif // _TESTINFO_H_