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

DomainWipeouts.h

00001 // DomainWipeouts.h -- The 'maximum/minimum domain wipeouts' variable
00002 // ordering heuristic.
00003 
00004 /*
00005  * Copyright (C) 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 // $Id: DomainWipeouts_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00024 
00025 
00026 #ifndef _CSP_HEURISTICS_VARIABLE_DomainWipeouts_H
00027 #define _CSP_HEURISTICS_VARIABLE_DomainWipeouts_H
00028 
00029 
00030 CSP_NAMESPACE_BEGIN(csp);
00031 CSP_NAMESPACE_BEGIN(heuristics);
00032 CSP_NAMESPACE_BEGIN(variables);
00033 
00034 
00035 class DomainWipeoutsLT :
00036     public StrictWeakVariableOrdering
00037 {
00038   public:
00039     DomainWipeoutsLT(Filter& filter) : m_filter(filter) {}
00040 
00041     bool operator()(const Variable* variable0, const Variable* variable1)
00042     {
00043         return variable0->domainWipeouts() < variable1->domainWipeouts();
00044     }
00045 
00046   private:
00047     Filter& m_filter;
00048 };
00049 
00050 
00051 class DomainWipeoutsGT :
00052     public StrictWeakVariableOrdering
00053 {
00054   public:
00055     DomainWipeoutsGT(Filter& filter) : m_filter(filter) {}
00056 
00057     bool operator()(const Variable* variable0, const Variable* variable1)
00058     {
00059         return variable0->domainWipeouts() > variable1->domainWipeouts();
00060     }
00061 
00062   private:
00063     Filter& m_filter;
00064 };
00065 
00066 
00067 class DomainWipeoutsEQ :
00068     public StrictWeakVariableOrdering
00069 {
00070   public:
00071     DomainWipeoutsEQ(Filter& filter) :
00072         m_filter(filter),
00073         m_previousVariable0(0),
00074         m_previousVariable1(0),
00075         m_previousDomainWipeouts0(0),
00076         m_previousDomainWipeouts1(0) {}
00077 
00078     bool operator()(const Variable* variable0, const Variable* variable1);
00079 
00080     void reset()
00081     {
00082         m_previousVariable0 = 0;
00083         m_previousVariable1 = 0;
00084         m_previousDomainWipeouts0 = 0;
00085         m_previousDomainWipeouts1 = 0;
00086     }
00087 
00088   private:
00089     Filter& m_filter;
00090 
00091     const Variable* m_previousVariable0;
00092     const Variable* m_previousVariable1;
00093 
00094     ulonglong m_previousDomainWipeouts0;
00095     ulonglong m_previousDomainWipeouts1;
00096 };
00097 
00098 
00104 class CSP_API DomainWipeouts :
00105     public VariableOH
00106 {
00107   public:
00108     enum Preference
00109     {
00111         Minimum,
00112 
00114         Maximum
00115     };
00116 
00126     DomainWipeouts(
00127         Decomposition& decomposition,
00128         const vector<pair<double, double> >& intervals,
00129         double quality = 1,
00130         Preference preference = Maximum);
00131 
00139     virtual void select(vlist_type& selectable, vlist_type& selected);
00140 
00141   private:
00143     DomainWipeouts(const DomainWipeouts&);
00144 
00146     DomainWipeouts& operator=(const DomainWipeouts&);
00147 
00149     Preference m_preference;
00150 
00153     DomainWipeoutsLT m_compareLT;
00154 
00157     DomainWipeoutsGT m_compareGT;
00158 
00160     DomainWipeoutsEQ m_compareEQ;
00161 };
00162 
00163 
00164 CSP_NAMESPACE_END(variables);
00165 CSP_NAMESPACE_END(heuristics);
00166 CSP_NAMESPACE_END(csp);
00167 
00168 
00169 #endif // _CSP_HEURISTICS_VARIABLE_DomainWipeouts_H
00170 
00171 // Local Variables:
00172 // mode: C++
00173 // End:

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