Main Page | Class Hierarchy | Class List | File List | Class Members

Retraction.h

00001 // Retraction.h -- An interface to objects monitoring domain changes and
00002 // filter failures.
00003 
00004 /*
00005  * Copyright (C) 1998,2004 Tudor Hulubei <tudor@hulubei.net>.
00006  *
00007  * This library is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU Lesser General Public License as
00009  * published by the Free Software Foundation; either version 2, or (at
00010  * your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA,
00020  * 02111-1307, USA.
00021  */
00022 
00023 /*
00024  * NOTE: This is an interal header file.
00025  * You should not attempt to use it directly.
00026  */
00027 
00028 // $Id: Retraction_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00029 
00030 #ifndef _CSP_KERNEL_Retraction_H
00031 #define _CSP_KERNEL_Retraction_H
00032 
00033 
00034 CSP_NAMESPACE_BEGIN(csp);
00035 
00036 
00041 class CSP_API Retraction
00042 {
00043   public:
00044     Retraction(const wstring& name, Problem& problem) :
00045         m_name(name),
00046         m_problem(problem),
00047         m_decomposition(0),
00048         m_filter(0) {}
00049 
00050     virtual ~Retraction() {}
00051 
00053     const wstring& name() const { return m_name; }
00054 
00056     const Problem& problem() const { return m_problem; }
00057 
00059     Problem& problem() { return m_problem; }
00060 
00062     const Decomposition& decomposition() const
00063     {
00064         assert(m_decomposition);
00065         return *m_decomposition;
00066     }
00067 
00069     Decomposition& decomposition()
00070     {
00071         assert(m_decomposition);
00072         return *m_decomposition; }
00073 
00075     const Filter& filter() const
00076     {
00077         assert(m_filter);
00078         return *m_filter;
00079     }
00080 
00082     Filter& filter()
00083     {
00084         assert(m_filter);
00085         return *m_filter;
00086     }
00087 
00089     virtual void init() {}
00090 
00092     virtual void done() {}
00093 
00096     virtual void start() {}
00097 
00100     virtual void stop() {}
00101 
00111     virtual void recordDomainChange(
00112         Variable& victim,
00113         Variable& aggressor) = 0;
00114 
00122     virtual void recordFailure(
00123         Constraint& constraint,
00124         Variable& victim,
00125         Variable& aggressor) = 0;
00126 
00134     virtual void unifyConflictSets(int /*jumpDepth*/) {}
00135 
00143     virtual void eraseConflictSets(int /*jumpDepth*/) {}
00144 
00154     virtual int computeJump(bool chronological = true) const = 0;
00155 
00162     virtual wostream& print(wostream& wos) const
00163     {
00164         return wos << L"Retraction: " << m_name << endl;
00165     }
00166 
00167     friend CSP_API wostream& operator<<(
00168         wostream& wos, const Retraction& retraction)
00169     {
00170         return retraction.print(wos);
00171     }
00172 
00173   private:
00174     // The algorithm's name.
00175     const wstring m_name;
00176 
00177   protected:
00178     // The problem.
00179     Problem& m_problem;
00180 
00181     // The decomposition guided by this retraction.
00182     Decomposition* m_decomposition;
00183 
00184     // The filter monitored by this monitor.
00185     Filter* m_filter;
00186 
00187   private:
00188     friend class Decomposition;
00189     void setDecomposition(Decomposition& decomposition)
00190     {
00191         m_decomposition = &decomposition;
00192     }
00193 
00194     void setFilter(Filter& filter)
00195     {
00196         m_filter = &filter;
00197     }
00198 };
00199 
00200 
00201 CSP_NAMESPACE_END(csp);
00202 
00203 
00204 #endif // _CSP_KERNEL_Retraction_H
00205 
00206 // Local Variables:
00207 // mode: C++
00208 // End:

Generated on Wed May 25 12:21:15 2005 for csp.kdevelop by  doxygen 1.3.9.1