00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef SG_SEARCHCONTROL_H
00012 #define SG_SEARCHCONTROL_H
00013
00014
00015
00016
00017 class SgSearchControl
00018 {
00019 public:
00020 SgSearchControl();
00021
00022 virtual ~SgSearchControl();
00023
00024
00025
00026
00027 virtual bool Abort(double elapsedTime, int numNodes) = 0;
00028
00029
00030
00031
00032
00033
00034
00035
00036 virtual bool StartNextIteration(int depth, double elapsedTime,
00037 int numNodes);
00038
00039 private:
00040
00041 SgSearchControl(const SgSearchControl&);
00042
00043
00044 SgSearchControl& operator=(const SgSearchControl&);
00045 };
00046
00047 inline SgSearchControl::SgSearchControl()
00048 {
00049 }
00050
00051
00052
00053
00054 class SgTimeSearchControl
00055 : public SgSearchControl
00056 {
00057 public:
00058 SgTimeSearchControl(double maxTime);
00059
00060 virtual ~SgTimeSearchControl();
00061
00062 virtual bool Abort(double elapsedTime, int ignoreNumNodes);
00063
00064 double GetMaxTime() const;
00065
00066 void SetMaxTime(double maxTime);
00067
00068 private:
00069 double m_maxTime;
00070
00071
00072 SgTimeSearchControl(const SgTimeSearchControl&);
00073
00074
00075 SgTimeSearchControl& operator=(const SgTimeSearchControl&);
00076 };
00077
00078 inline double SgTimeSearchControl::GetMaxTime() const
00079 {
00080 return m_maxTime;
00081 }
00082
00083 inline void SgTimeSearchControl::SetMaxTime(double maxTime)
00084 {
00085 m_maxTime = maxTime;
00086 }
00087
00088
00089
00090
00091
00092
00093 class SgNodeSearchControl
00094 : public SgSearchControl
00095 {
00096 public:
00097 SgNodeSearchControl(int maxNumNodes);
00098
00099 virtual ~SgNodeSearchControl();
00100
00101 virtual bool Abort(double ignoreElapsedTime, int numNodes);
00102
00103 void SetMaxNumNodes(int maxNumNodes);
00104
00105 private:
00106 int m_maxNumNodes;
00107
00108
00109 SgNodeSearchControl(const SgNodeSearchControl&);
00110
00111
00112 SgNodeSearchControl& operator=(const SgNodeSearchControl&);
00113 };
00114
00115 inline void SgNodeSearchControl::SetMaxNumNodes(int maxNumNodes)
00116 {
00117 m_maxNumNodes = maxNumNodes;
00118 }
00119
00120
00121
00122
00123 class SgCombinedSearchControl
00124 : public SgSearchControl
00125 {
00126 public:
00127 SgCombinedSearchControl(double maxTime, int maxNumNodes);
00128
00129 virtual ~SgCombinedSearchControl();
00130
00131 virtual bool Abort(double elapsedTime, int numNodes);
00132
00133 private:
00134 double m_maxTime;
00135
00136 int m_maxNumNodes;
00137
00138
00139 SgCombinedSearchControl(const SgCombinedSearchControl&);
00140
00141
00142 SgCombinedSearchControl& operator=(const SgCombinedSearchControl&);
00143 };
00144
00145 inline SgCombinedSearchControl::SgCombinedSearchControl(double maxTime,
00146 int maxNumNodes)
00147 : m_maxTime(maxTime),
00148 m_maxNumNodes(maxNumNodes)
00149 {
00150 }
00151
00152
00153
00154
00155 class SgRelaxedSearchControl
00156 : public SgSearchControl
00157 {
00158 public:
00159 static const int MIN_NODES_PER_SECOND = 1000;
00160
00161 SgRelaxedSearchControl(double maxTime);
00162
00163 virtual ~SgRelaxedSearchControl();
00164
00165 virtual bool Abort(double elapsedTime, int numNodes);
00166
00167 private:
00168 double m_maxTime;
00169
00170
00171 SgRelaxedSearchControl(const SgRelaxedSearchControl&);
00172
00173
00174 SgRelaxedSearchControl& operator=(const SgRelaxedSearchControl&);
00175 };
00176
00177 inline SgRelaxedSearchControl::SgRelaxedSearchControl(double maxTime)
00178 : m_maxTime(maxTime)
00179 {
00180 }
00181
00182
00183
00184 #endif // SG_SEARCHCONTROL_H