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 #ifndef _CSP_HEURISTICS_VARIABLE_Impact_H
00026 #define _CSP_HEURISTICS_VARIABLE_Impact_H
00027
00028
00029 #include "../../caches/ConflictCounts.h"
00030
00031
00032 CSP_NAMESPACE_BEGIN(csp);
00033 CSP_NAMESPACE_BEGIN(heuristics);
00034 CSP_NAMESPACE_BEGIN(variables);
00035
00036
00037 class ImpactLT :
00038 public StrictWeakVariableOrdering
00039 {
00040 public:
00041 ImpactLT(caches::ConflictCounts& conflictCounts) :
00042 m_conflictCounts(conflictCounts) {}
00043
00044 bool operator()(const Variable* variable0, const Variable* variable1);
00045
00046 private:
00047 caches::ConflictCounts& m_conflictCounts;
00048 };
00049
00050
00051 class ImpactGT :
00052 public StrictWeakVariableOrdering
00053 {
00054 public:
00055 ImpactGT(caches::ConflictCounts& conflictCounts) :
00056 m_conflictCounts(conflictCounts) {}
00057
00058 bool operator()(const Variable* variable0, const Variable* variable1);
00059
00060 private:
00061 caches::ConflictCounts& m_conflictCounts;
00062 };
00063
00064
00065 class ImpactEQ :
00066 public StrictWeakVariableOrdering
00067 {
00068 public:
00069 ImpactEQ(caches::ConflictCounts& conflictCounts) :
00070 m_conflictCounts(conflictCounts),
00071 m_previousVariable0(0),
00072 m_previousVariable1(0),
00073 m_previousTotalConflictCount0(0),
00074 m_previousTotalConflictCount1(0) {}
00075
00076 bool operator()(const Variable* variable0, const Variable* variable1);
00077
00078 void reset()
00079 {
00080 m_previousVariable0 = 0;
00081 m_previousVariable1 = 0;
00082 m_previousTotalConflictCount0 = 0;
00083 m_previousTotalConflictCount1 = 0;
00084 }
00085
00086 private:
00087 caches::ConflictCounts& m_conflictCounts;
00088
00089 const Variable* m_previousVariable0;
00090 const Variable* m_previousVariable1;
00091
00092 size_t m_previousTotalConflictCount0;
00093 size_t m_previousTotalConflictCount1;
00094 };
00095
00096
00101 class CSP_API Impact :
00102 public VariableOH
00103 {
00104 public:
00105 enum Preference
00106 {
00108 Minimum,
00109
00111 Maximum
00112 };
00113
00125 Impact(
00126 Decomposition& decomposition,
00127 const vector<pair<double, double> >& intervals,
00128 double quality = 1,
00129 Preference preference = Maximum,
00130 bool dynamic = false);
00131
00133 ~Impact();
00134
00136 virtual void init(const vlist_type& );
00137
00139 virtual void done();
00140
00148 virtual void select(vlist_type& selectable, vlist_type& selected);
00149
00150 private:
00152 Impact(const Impact&);
00153
00155 Impact& operator=(const Impact&);
00156
00158 Preference m_preference;
00159
00164 bool m_dynamic;
00165
00167 caches::ConflictCounts m_conflictCounts;
00168
00171 ImpactLT m_compareLT;
00172
00175 ImpactGT m_compareGT;
00176
00179 ImpactEQ m_compareEQ;
00180 };
00181
00182
00183 CSP_NAMESPACE_END(variables);
00184 CSP_NAMESPACE_END(heuristics);
00185 CSP_NAMESPACE_END(csp);
00186
00187
00188 #endif // _CSP_HEURISTICS_VARIABLE_Impact_H
00189
00190
00191
00192