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_BranchingFactors_H
00030 #define _CSP_CACHES_BranchingFactors_H
00031
00032
00033 CSP_NAMESPACE_BEGIN(csp);
00034 CSP_NAMESPACE_BEGIN(caches);
00035
00036
00040 class CSP_API BranchingFactors
00041 {
00042 public:
00043 enum Preference
00044 {
00046 Minimum,
00047
00049 Maximum
00050 };
00051
00053 BranchingFactors(
00054 Decomposition& decomposition,
00055 Preference = Minimum) :
00056 m_decomposition(decomposition),
00057 m_variable(0) {}
00058
00060 void init(const vlist_type& uninstantiatedVariables);
00061
00070 void init(Variable& variable, Domain& domain);
00071
00073 void done();
00074
00080 void setVariable(const Variable& variable)
00081 {
00082 m_variable = &variable;
00083 }
00084
00091 size_t branchingFactor(const Value& value) const;
00092
00100 const hash_map<const Value*, size_t>& branchingFactors(
00101 const Variable& variable) const;
00102
00111 bool contains(const Variable& variable) const
00112 {
00113 return m_branchingFactors.find(&variable) != m_branchingFactors.end();
00114 }
00115
00117 void clear() { m_branchingFactors.clear(); }
00118
00120 bool empty() { return m_branchingFactors.empty(); }
00121
00122 private:
00124 BranchingFactors(const BranchingFactors&);
00125
00127 BranchingFactors& operator=(const BranchingFactors&);
00128
00130 typedef hash_map<const Variable*, hash_map<const Value*, size_t> > bf_type;
00131
00133 Preference m_preference;
00134
00136 Decomposition& m_decomposition;
00137
00139 bf_type m_branchingFactors;
00140
00142 const Variable* m_variable;
00143 };
00144
00145
00146 CSP_NAMESPACE_END(caches);
00147 CSP_NAMESPACE_END(csp);
00148
00149
00150 #endif // _CSP_KERNEL_BranchingFactors_H
00151
00152
00153
00154