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.

79 lines
2.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: utility.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // utility.h: Algorithms for computation of utility
  12. //
  13. #ifndef _UTILITY_H_
  14. #define _UTILITY_H_
  15. #include <deque>
  16. #include "gmobj.h"
  17. //////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////
  19. //
  20. // class MBNET_ENTROPIC_UTILITY:
  21. //
  22. // Ranking for entropic utility. Uses function object
  23. // semantics. Construct using an inference engine, since
  24. // utility calculations are computed w.r.t. a set of evidence.
  25. //
  26. //////////////////////////////////////////////////////////////////
  27. //////////////////////////////////////////////////////////////////
  28. struct UTILWORK
  29. {
  30. GNODEMBND * _pgndd; // Pointer to node
  31. int _iLbl; // Label of node
  32. MDVCPD _dd; // Unconditional distribution given evidence
  33. REAL _rUtil; // Utility
  34. int _iClamp; // index of clamped state or -1
  35. bool operator < ( const UTILWORK & ut ) const
  36. { return _rUtil < ut._rUtil ; }
  37. };
  38. typedef deque<UTILWORK> DQUTILWORK;
  39. class MBNET_ENTROPIC_UTILITY : public MBNET_NODE_RANKER
  40. {
  41. public:
  42. MBNET_ENTROPIC_UTILITY ( GOBJMBN_INFER_ENGINE & inferEng );
  43. virtual ~ MBNET_ENTROPIC_UTILITY () {}
  44. INT EType () const
  45. { return EBNO_RANKER_ENTROPIC_UTIL; }
  46. // The ranking function
  47. virtual void operator () ();
  48. protected:
  49. // The inference engine we're operating against
  50. GOBJMBN_INFER_ENGINE & _inferEng;
  51. // Property handler
  52. PROPMGR _propMgr;
  53. // Queue of work items
  54. DQUTILWORK _dquwrk;
  55. // Indicies of standard labels in this network
  56. int _iLblHypo;
  57. int _iLblInfo;
  58. int _iLblProblem;
  59. // Counts of nodes by label
  60. int _cHypo;
  61. int _cInfo;
  62. protected:
  63. void BuildWorkItems ();
  64. void ComputeWorkItems ();
  65. REAL RComputeHypoGivenInfo ( UTILWORK & uwHypo, UTILWORK & uwInfo );
  66. };
  67. #endif // _UTILITY_H_