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

Impact.h

00001 // Impact.h -- The `maximum/minimum impact' variable ordering
00002 // heuristic interface.
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: Impact_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00024 
00025 #ifndef _CSP_HEURISTICS_VARIABLE_Impact_H
00026 #define _CSP_HEURISTICS_VARIABLE_Impact_H
00027 
00028 
00029 #include "../../caches/ConflictCounts.h"
00030 
00031 
00032 CSP_NAMESPACE_BEGIN(csp);
00033 CSP_NAMESPACE_BEGIN(heuristics);
00034 CSP_NAMESPACE_BEGIN(variables);
00035 
00036 
00037 class ImpactLT :
00038     public StrictWeakVariableOrdering
00039 {
00040   public:
00041     ImpactLT(caches::ConflictCounts& conflictCounts) :
00042         m_conflictCounts(conflictCounts) {}
00043 
00044     bool operator()(const Variable* variable0, const Variable* variable1);
00045 
00046   private:
00047     caches::ConflictCounts& m_conflictCounts;
00048 };
00049 
00050 
00051 class ImpactGT :
00052     public StrictWeakVariableOrdering
00053 {
00054   public:
00055     ImpactGT(caches::ConflictCounts& conflictCounts) :
00056         m_conflictCounts(conflictCounts) {}
00057 
00058     bool operator()(const Variable* variable0, const Variable* variable1);
00059 
00060   private:
00061     caches::ConflictCounts& m_conflictCounts;
00062 };
00063 
00064 
00065 class ImpactEQ :
00066     public StrictWeakVariableOrdering
00067 {
00068   public:
00069     ImpactEQ(caches::ConflictCounts& conflictCounts) :
00070         m_conflictCounts(conflictCounts),
00071         m_previousVariable0(0),
00072         m_previousVariable1(0),
00073         m_previousTotalConflictCount0(0),
00074         m_previousTotalConflictCount1(0) {}
00075 
00076     bool operator()(const Variable* variable0, const Variable* variable1);
00077 
00078     void reset()
00079     {
00080         m_previousVariable0 = 0;
00081         m_previousVariable1 = 0;
00082         m_previousTotalConflictCount0 = 0;
00083         m_previousTotalConflictCount1 = 0;
00084     }
00085 
00086   private:
00087     caches::ConflictCounts& m_conflictCounts;
00088 
00089     const Variable* m_previousVariable0;
00090     const Variable* m_previousVariable1;
00091 
00092     size_t m_previousTotalConflictCount0;
00093     size_t m_previousTotalConflictCount1;
00094 };
00095 
00096 
00101 class CSP_API Impact :
00102     public VariableOH
00103 {
00104   public:
00105     enum Preference
00106     {
00108         Minimum,
00109 
00111         Maximum
00112     };
00113 
00125     Impact(
00126         Decomposition& decomposition,
00127         const vector<pair<double, double> >& intervals,
00128         double quality = 1,
00129         Preference preference = Maximum,
00130         bool dynamic = false);
00131 
00133     ~Impact();
00134 
00136     virtual void init(const vlist_type& /*uninstantiatedVariables*/);
00137     
00139     virtual void done();
00140 
00148     virtual void select(vlist_type& selectable, vlist_type& selected);
00149 
00150   private:
00152     Impact(const Impact&);
00153 
00155     Impact& operator=(const Impact&);
00156 
00158     Preference m_preference;
00159 
00164     bool m_dynamic;
00165 
00167     caches::ConflictCounts m_conflictCounts;
00168 
00171     ImpactLT m_compareLT;
00172 
00175     ImpactGT m_compareGT;
00176 
00179     ImpactEQ m_compareEQ;
00180 };
00181 
00182 
00183 CSP_NAMESPACE_END(variables);
00184 CSP_NAMESPACE_END(heuristics);
00185 CSP_NAMESPACE_END(csp);
00186 
00187 
00188 #endif // _CSP_HEURISTICS_VARIABLE_Impact_H
00189 
00190 // Local Variables:
00191 // mode: C++
00192 // End:

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