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 #ifndef _CSP_CACHES_ConflictCounts_H
00030 #define _CSP_CACHES_ConflictCounts_H
00031
00032
00033 CSP_NAMESPACE_BEGIN(csp);
00034 CSP_NAMESPACE_BEGIN(caches);
00035
00036
00040 class CSP_API ConflictCounts
00041 {
00042 public:
00044 ConflictCounts(const Decomposition& decomposition) :
00045 m_decomposition(decomposition),
00046 m_variable(0) {}
00047
00049 void init(const vlist_type& uninstantiatedVariables);
00050
00059 void init(const Variable& variable, Domain& domain);
00060
00062 void done();
00063
00069 void setVariable(const Variable& variable)
00070 {
00071 m_variable = &variable;
00072 }
00073
00081 size_t conflictCount(const Value& value) const;
00082
00090 const hash_map<const Value*, int>& conflictCounts(
00091 const Variable& variable) const;
00092
00101 bool contains(const Variable& variable) const
00102 {
00103 return m_conflictCounts.find(&variable) != m_conflictCounts.end();
00104 }
00105
00107 void clear() { m_conflictCounts.clear(); }
00108
00110 bool empty() { return m_conflictCounts.empty(); }
00111
00112 private:
00114 ConflictCounts(const ConflictCounts&);
00115
00117 ConflictCounts& operator=(const ConflictCounts&);
00118
00126 void compute2(const Constraint& constraint);
00127
00137 void compute(
00138 const Constraint& constraint,
00139 const Variable& variable,
00140 Domain& domain);
00141
00143 typedef hash_map<const Variable*, hash_map<const Value*, int> > cc_type;
00144
00146 const Decomposition& m_decomposition;
00147
00149 cc_type m_conflictCounts;
00150
00152 const Variable* m_variable;
00153 };
00154
00155
00156 CSP_NAMESPACE_END(caches);
00157 CSP_NAMESPACE_END(csp);
00158
00159
00160 #endif // _CSP_KERNEL_ConflictCounts_H
00161
00162
00163
00164