00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _CSP_KERNEL_VariableOH_H
00031 #define _CSP_KERNEL_VariableOH_H
00032
00033
00034 CSP_NAMESPACE_BEGIN(csp);
00035
00036
00037 class StrictWeakVariableOrdering
00038 {
00039 public:
00040 virtual ~StrictWeakVariableOrdering() {}
00041 virtual bool operator()(
00042 const Variable* ,
00043 const Variable* ) = 0;
00044 };
00045
00046
00048 class StrictWeakVariableOrderingWrapper
00049 {
00050 public:
00051 StrictWeakVariableOrderingWrapper(
00052 StrictWeakVariableOrdering& implementation) :
00053 m_implementation(implementation) {}
00054
00056 bool operator()(
00057 const Variable* variable0,
00058 const Variable* variable1)
00059 {
00060 return m_implementation(variable0, variable1);
00061 }
00062
00063 private:
00064 StrictWeakVariableOrdering& m_implementation;
00065 };
00066
00067
00071 class CSP_API VariableOH :
00072 public OrderingHeuristic
00073 {
00074 public:
00084 VariableOH(
00085 const wstring& name,
00086 Decomposition& decomposition,
00087 const vector<pair<double, double> >& intervals,
00088 double quality = 1);
00089
00090 virtual ~VariableOH() {}
00091
00102 virtual void init(const vlist_type& ) {}
00103
00105 virtual void done() {}
00106
00121 virtual void select(vlist_type& selectable, vlist_type& selected) = 0;
00122
00128 virtual wostream& print(wostream& wos) const;
00129
00130 friend CSP_API wostream& operator<<(
00131 wostream& wos, const VariableOH& variableOH)
00132 {
00133 return variableOH.print(wos);
00134 }
00135
00136 protected:
00148 void selectByQuality(
00149 vlist_type& selectable,
00150 vlist_type& selected,
00151 StrictWeakVariableOrdering& better,
00152 StrictWeakVariableOrdering& equal);
00153
00154 private:
00156 VariableOH(const VariableOH&);
00157
00159 VariableOH& operator=(const VariableOH&);
00160 };
00161
00162
00163 CSP_NAMESPACE_END(csp);
00164
00165
00166 #endif // _CSP_KERNEL_VariableOH_H
00167
00168
00169
00170