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

BranchingFactors.h

00001 // BranchingFactors.h -- The interface to a cache of branching factors.
00002 
00003 /*
00004  * Copyright (C) 2004 Tudor Hulubei <tudor@hulubei.net>.
00005  *
00006  * This library is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as
00008  * published by the Free Software Foundation; either version 2, or (at
00009  * your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA,
00019  * 02111-1307, USA.
00020  */
00021 
00022 /*
00023  * NOTE: This is an interal header file.
00024  * You should not attempt to use it directly.
00025  */
00026 
00027 // $Id: BranchingFactors_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00028 
00029 #ifndef _CSP_CACHES_BranchingFactors_H
00030 #define _CSP_CACHES_BranchingFactors_H
00031 
00032 
00033 CSP_NAMESPACE_BEGIN(csp);
00034 CSP_NAMESPACE_BEGIN(caches);
00035 
00036 
00040 class CSP_API BranchingFactors
00041 {
00042   public:
00043     enum Preference
00044     {
00046         Minimum,
00047 
00049         Maximum
00050     };
00051 
00053     BranchingFactors(
00054         Decomposition& decomposition,
00055         Preference /*preference*/ = Minimum) :
00056         m_decomposition(decomposition),
00057         m_variable(0) {}
00058 
00060     void init(const vlist_type& uninstantiatedVariables);
00061 
00070     void init(Variable& variable, Domain& domain);
00071 
00073     void done();
00074 
00080     void setVariable(const Variable& variable)
00081     {
00082         m_variable = &variable;
00083     }
00084 
00091     size_t branchingFactor(const Value& value) const;
00092 
00100     const hash_map<const Value*, size_t>& branchingFactors(
00101         const Variable& variable) const;
00102 
00111     bool contains(const Variable& variable) const
00112     {
00113         return m_branchingFactors.find(&variable) != m_branchingFactors.end();
00114     }
00115 
00117     void clear() { m_branchingFactors.clear(); }
00118 
00120     bool empty() { return m_branchingFactors.empty(); }
00121 
00122   private:
00124     BranchingFactors(const BranchingFactors&);
00125 
00127     BranchingFactors& operator=(const BranchingFactors&);
00128 
00130     typedef hash_map<const Variable*, hash_map<const Value*, size_t> > bf_type;
00131 
00133     Preference m_preference;
00134 
00136     Decomposition& m_decomposition;
00137 
00139     bf_type m_branchingFactors;
00140 
00142     const Variable* m_variable;
00143 };
00144 
00145 
00146 CSP_NAMESPACE_END(caches);
00147 CSP_NAMESPACE_END(csp);
00148 
00149 
00150 #endif // _CSP_KERNEL_BranchingFactors_H
00151 
00152 // Local Variables:
00153 // mode: C++
00154 // End:

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