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_RETRACTIONS_CBJ_H
00025 #define _CSP_RETRACTIONS_CBJ_H
00026
00027
00028 CSP_NAMESPACE_BEGIN(csp);
00029 CSP_NAMESPACE_BEGIN(retractions);
00030
00031
00035 class CSP_API CBJ :
00036 public Retraction
00037 {
00038 public:
00039 CBJ(Problem& problem) :
00040 Retraction(L"Conflict Directed Backjumping", problem),
00041 m_success(true) {}
00042 virtual ~CBJ() {}
00043
00044 virtual void init() { m_gcs.clear(); m_jumps.clear(); }
00045 virtual void done() { m_gcs.clear(); }
00046 virtual void start();
00047 virtual void stop();
00048
00058 virtual void recordDomainChange(
00059 Variable& victim,
00060 Variable& aggressor);
00061
00069 virtual void recordFailure(
00070 Constraint& constraint,
00071 Variable& victim,
00072 Variable& aggressor);
00073
00080 virtual int computeJump(bool chronological = true) const;
00081
00089 virtual void unifyConflictSets(int jumpDepth);
00090
00098 virtual void eraseConflictSets(int jumpDepth);
00099
00106 virtual wostream& print(wostream& wos) const;
00107
00108 private:
00109
00110 typedef set<const Variable*, id_less<const Variable*> > cs_type;
00111
00112
00113
00114 bool m_success;
00115
00116
00117 hash_map<id_t, cs_type> m_gcs;
00118
00119
00120 hash_map<id_t, cs_type> m_lcs;
00121
00122
00123 cs_type m_ucs;
00124
00125
00126
00127 mutable vector<int> m_jumps;
00128
00136 void unify(const Variable& src, const Variable& dest);
00137
00144 void updateStatistics(int currentDepth, int jumpDepth) const;
00145 };
00146
00147
00148 CSP_NAMESPACE_END(retractions);
00149 CSP_NAMESPACE_END(csp);
00150
00151
00152 #endif // _CSP_RETRACTIONS_CBJ_H
00153
00154
00155
00156