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.

134 lines
3.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: domain.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // domain.h: domain declarations
  12. //
  13. #ifndef _DOMAIN_H_
  14. #define _DOMAIN_H_
  15. #include "symtmbn.h"
  16. #include <list>
  17. ////////////////////////////////////////////////////////////////////
  18. // Declarations for common state or range sets.
  19. // For continuous variables, RANGEDEFs can be open or closed.
  20. // For discrete variables, RANGEDEFs must have lbound and ubound
  21. // (i.e., be closed) and the must be the same integer value.
  22. ////////////////////////////////////////////////////////////////////
  23. // Boundary of a domain
  24. struct RANGELIM : pair<bool,REAL>
  25. {
  26. RANGELIM( bool b = false, REAL r = 0.0 )
  27. : pair<bool,REAL>(b,r)
  28. {}
  29. DECLARE_ORDERING_OPERATORS(RANGELIM);
  30. };
  31. class RANGEDEF
  32. {
  33. public:
  34. RANGEDEF ( bool bLower = false,
  35. REAL rLower = 0.0,
  36. bool bUpper = false,
  37. REAL rUpper = 0.0 )
  38. {
  39. _rlimLower.first = bLower;
  40. _rlimLower.second = rLower;
  41. _rlimUpper.first = bUpper;
  42. _rlimUpper.second = rUpper;
  43. }
  44. RANGEDEF ( const RANGELIM & rlimLower,
  45. const RANGELIM & rlimUpper,
  46. ZSREF zsrName )
  47. : _rlimLower(rlimLower),
  48. _rlimUpper(rlimUpper),
  49. _zsrName(zsrName)
  50. {}
  51. bool BLbound () const
  52. { return _rlimLower.first; }
  53. REAL RLbound () const
  54. { return _rlimLower.second; }
  55. bool BUbound () const
  56. { return _rlimUpper.first; }
  57. REAL RUbound () const
  58. { return _rlimUpper.second; }
  59. ZSREF ZsrName () const
  60. { return _zsrName; }
  61. void SetName ( ZSREF zsrName )
  62. { _zsrName = zsrName; }
  63. const RANGELIM & RlimLower () const
  64. { return _rlimLower; }
  65. const RANGELIM & RlimUpper () const
  66. { return _rlimUpper; }
  67. bool BValid () const;
  68. bool BOverlap ( const RANGEDEF & rdef ) const;
  69. bool BDiscrete () const
  70. {
  71. return BLbound()
  72. && BUbound()
  73. && int(RLbound()) == int(RUbound());
  74. }
  75. int IDiscrete () const
  76. {
  77. assert( BDiscrete() );
  78. return int(RLbound());
  79. }
  80. DECLARE_ORDERING_OPERATORS(RANGEDEF);
  81. protected:
  82. ZSREF _zsrName;
  83. RANGELIM _rlimLower;
  84. RANGELIM _rlimUpper;
  85. };
  86. // A RDOMAIN is a sorted list of RANGELIMs
  87. class RDOMAIN : public list<RANGEDEF>
  88. {
  89. public:
  90. // Convert a numeric value to a state name
  91. SZC SzcState ( REAL rValue ) const;
  92. bool BOverlap () const;
  93. };
  94. ////////////////////////////////////////////////////////////////////
  95. // GOBJMBN_DOMAIN: Belief network object representing
  96. // a named, sharable mapping of names to scalar ranges.
  97. ////////////////////////////////////////////////////////////////////
  98. class GOBJMBN_DOMAIN : public GOBJMBN
  99. {
  100. public:
  101. GOBJMBN_DOMAIN ( RDOMAIN * pdomain = NULL)
  102. {
  103. if ( pdomain )
  104. _domain = *pdomain;
  105. }
  106. ~ GOBJMBN_DOMAIN() {}
  107. virtual INT EType () const
  108. { return EBNO_VARIABLE_DOMAIN ; }
  109. virtual GOBJMBN * CloneNew ( MODEL & modelSelf,
  110. MODEL & modelNew,
  111. GOBJMBN * pgobjNew = NULL );
  112. RDOMAIN & Domain ()
  113. { return _domain; }
  114. const RDOMAIN & Domain () const
  115. { return _domain; }
  116. protected:
  117. // Vector of RANGEDEFs
  118. RDOMAIN _domain;
  119. };
  120. #endif // _DOMAIN_H_