00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _CSP_FILTERS_AC3X_H
00025 #define _CSP_FILTERS_AC3X_H
00026
00027
00028 CSP_NAMESPACE_BEGIN(csp);
00029 CSP_NAMESPACE_BEGIN(filters);
00030
00031
00035 class CSP_API AC3x :
00036 public Filter
00037 {
00038 public:
00039 AC3x(Problem& problem, Retraction& retraction, bool optimizeCC = false) :
00040 Filter(L"Arc Consistency 3x", L"AC-3x", problem, retraction) {
00041 m_optimizeCC = optimizeCC; }
00042 ~AC3x() {}
00043
00044 virtual bool init(
00045 const vlist_type& uninstantiatedVariables,
00046 bool propagate = true);
00047 virtual void done() { Filter::done(); }
00048
00049 virtual bool restoresArcConsistency() const { return true; }
00050
00051 virtual bool propagate(
00052 const vlist_type& uninstantiatedVariables,
00053 const vlist_type& modifiedVariables,
00054 const bool keepChanges = true);
00055
00056 private:
00061 void queueInit();
00062
00064 void queueClear();
00065
00067 void queueMaintain();
00068
00070 void queuePush(Constraint& c);
00071
00073 void queuePop();
00074
00076 bool queueEmpty() const;
00077
00079 Constraint& queueTop() const;
00080
00082 Domain m_diffs;
00083
00084
00085 vector<Constraint*> m_heap;
00086
00087
00088 deque<Constraint*> m_queue;
00089
00090
00091
00092
00093
00094
00095 bool m_optimizeCC;
00096
00097
00098 hash_set<const Constraint*> m_inQueue;
00099
00101 AC3x(const AC3x&);
00102
00104 AC3x& operator=(const AC3x&);
00105
00106
00107
00108 bool pruneUnaryConstraint(Constraint& constraint);
00109
00110
00111
00112
00113 bool pruneBinaryConstraint(Constraint& c);
00114
00119 void addRelatedConstraints(Constraint& constraint, Variable& variable);
00120
00128 void addActiveConstraints(const Variable& variable);
00129 };
00130
00131
00132 CSP_NAMESPACE_END(filters);
00133 CSP_NAMESPACE_END(csp);
00134
00135
00136 #endif // _CSP_FILTERS_AC3X_H
00137
00138
00139
00140