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

Failures.h

00001 // Failure.h -- The `minimum/maximum failures' value ordering
00002 // heuristic interface.
00003 
00004 /*
00005  * Copyright (C) 2005 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: Failures_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00024 
00025 #ifndef _CSP_HEURISTICS_VALUE_Failures_H
00026 #define _CSP_HEURISTICS_VALUE_Failures_H
00027 
00028 
00029 CSP_NAMESPACE_BEGIN(csp);
00030 CSP_NAMESPACE_BEGIN(heuristics);
00031 CSP_NAMESPACE_BEGIN(values);
00032 
00033 
00034 class FailureCountLT :
00035     public StrictWeakValueOrdering
00036 {
00037   public:
00038     FailureCountLT() {}
00039 
00040     bool operator()(const Value* value0, const Value* value1)
00041     {
00042         return value0->failures() < value1->failures();
00043     }
00044 };
00045 
00046 
00047 class FailureCountGT :
00048     public StrictWeakValueOrdering
00049 {
00050   public:
00051     FailureCountGT() {}
00052 
00053     bool operator()(const Value* value0, const Value* value1)
00054     {
00055         return value0->failures() > value1->failures();
00056     }
00057 };
00058 
00059 
00060 class FailureCountEQ :
00061     public StrictWeakValueOrdering
00062 {
00063   public:
00064     FailureCountEQ() {}
00065 
00066     bool operator()(const Value* value0, const Value* value1)
00067     {
00068         return value0->failures() == value1->failures();
00069     }
00070 };
00071 
00072 
00080 class CSP_API Failures :
00081     public ValueOH
00082 {
00083   public:
00084     enum Preference
00085     {
00087         Minimum,
00088 
00090         Maximum
00091     };
00092 
00106     Failures(
00107         Decomposition& decomposition,
00108         const vector<pair<double, double> >& intervals,
00109         double quality = 1,
00110         Preference preference = Minimum,
00111         bool analysis = false);
00112 
00120     virtual void select(
00121         Domain& selectable,
00122         Domain& selected,
00123         Variable& variable);
00124 
00133     virtual bool better(const Value& value0, const Value& value1);
00134 
00142     virtual bool equal(const Value& value0, const Value& value1);
00143 
00148     virtual void sort(
00149         Domain& original,
00150         Domain& sorted,
00151         Variable& variable);
00152 
00164     virtual long double score(Variable& variable, const Value& value);
00165 
00166   private:
00168     Failures(const Failures&);
00169 
00171     Failures& operator=(const Failures&);
00172 
00174     Preference m_preference;
00175 
00178     FailureCountLT m_compareLT;
00179 
00182     FailureCountGT m_compareGT;
00183 
00186     FailureCountEQ m_compareEQ;
00187 };
00188 
00189 
00190 CSP_NAMESPACE_END(values);
00191 CSP_NAMESPACE_END(heuristics);
00192 CSP_NAMESPACE_END(csp);
00193 
00194 
00195 #endif // _CSP_HEURISTICS_VALUE_Failures_H
00196 
00197 // Local Variables:
00198 // mode: C++
00199 // End:

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