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

VariableOH.h

00001 // VariableOH.h -- The interface to the super class of all the
00002 // variable ordering heuristics.
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: VariableOH_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00029 
00030 #ifndef _CSP_KERNEL_VariableOH_H
00031 #define _CSP_KERNEL_VariableOH_H
00032 
00033 
00034 CSP_NAMESPACE_BEGIN(csp);
00035 
00036 
00037 class StrictWeakVariableOrdering
00038 {
00039   public:
00040     virtual ~StrictWeakVariableOrdering() {}
00041     virtual bool operator()(
00042         const Variable* /* variable0 */,
00043         const Variable* /* variable1 */) = 0;
00044 };
00045 
00046 
00048 class StrictWeakVariableOrderingWrapper
00049 {
00050   public:
00051     StrictWeakVariableOrderingWrapper(
00052         StrictWeakVariableOrdering& implementation) :
00053         m_implementation(implementation) {}
00054 
00056     bool operator()(
00057         const Variable* variable0,
00058         const Variable* variable1)
00059     {
00060         return m_implementation(variable0, variable1);
00061     }
00062 
00063   private:
00064     StrictWeakVariableOrdering& m_implementation;
00065 };
00066 
00067 
00071 class CSP_API VariableOH :
00072     public OrderingHeuristic
00073 {
00074   public:
00084     VariableOH(
00085         const wstring& name,
00086         Decomposition& decomposition,
00087         const vector<pair<double, double> >& intervals,
00088         double quality = 1);
00089 
00090     virtual ~VariableOH() {}
00091 
00102     virtual void init(const vlist_type& /*uninstantiatedVariables*/) {}
00103 
00105     virtual void done() {}
00106 
00121     virtual void select(vlist_type& selectable, vlist_type& selected) = 0;
00122 
00128     virtual wostream& print(wostream& wos) const;
00129 
00130     friend CSP_API wostream& operator<<(
00131         wostream& wos, const VariableOH& variableOH)
00132     {
00133         return variableOH.print(wos);
00134     }
00135 
00136   protected:
00148     void selectByQuality(
00149         vlist_type& selectable,
00150         vlist_type& selected,
00151         StrictWeakVariableOrdering& better,
00152         StrictWeakVariableOrdering& equal);
00153 
00154   private:
00156     VariableOH(const VariableOH&);
00157 
00159     VariableOH& operator=(const VariableOH&);
00160 };
00161 
00162 
00163 CSP_NAMESPACE_END(csp);
00164 
00165 
00166 #endif // _CSP_KERNEL_VariableOH_H
00167 
00168 // Local Variables:
00169 // mode: C++
00170 // End:

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