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

AC2001.h

00001 // AC2001.h -- The AC-2001 filter interface.
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 // $Id: AC2001_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00023 
00024 #ifndef _CSP_FILTERS_AC2001_H
00025 #define _CSP_FILTERS_AC2001_H
00026 
00027 
00028 CSP_NAMESPACE_BEGIN(csp);
00029 CSP_NAMESPACE_BEGIN(filters);
00030 
00031 
00038 class CSP_API AC2001 :
00039     public Filter
00040 {
00041   public:
00042     AC2001(Problem& problem, Retraction& retraction) :
00043         Filter(L"Arc Consistency 2001", L"AC-2001", problem, retraction) {}
00044     ~AC2001() {}
00045 
00046     virtual bool init(
00047         const vlist_type& uninstantiatedVariables,
00048         bool propagate = true);
00049     virtual void done() { Filter::done(); }
00050 
00051     virtual bool restoresArcConsistency() const { return true; }
00052 
00053     virtual bool propagate(
00054         const vlist_type& uninstantiatedVariables,
00055         const vlist_type& modifiedVariables,
00056         const bool keepChanges = true);
00057 
00058   private:
00060     AC2001(const AC2001&);
00061 
00063     AC2001& operator=(const AC2001&);
00064 
00070     void insertInQueue(Variable& variable);
00071 
00077     void removeFromQueue(Variable& variable);
00078 
00085     bool isInQueue(const Variable& variable);
00086 
00095     void prune(
00096         Variable& variable,
00097         const Constraint& constraint,
00098         Domain& diffs);
00099 
00115     Value* findSupport(
00116         Variable& variable,
00117         Value& value,
00118         const Constraint& constraint,
00119         Variable& pair);
00120 
00133     Value* findSupportInDomain(
00134         Variable& variable,
00135         Value& value,
00136         const Constraint& constraint,
00137         Variable& pair,
00138         Domain& subDomain);
00139 
00141     void clearSupports();
00142 
00144     void clearDomains();
00145 
00147     Domain m_diffs;
00148 
00150     deque<Variable*> m_queue;
00151 
00153     hash_set<const Variable*> m_inQueue;
00154 
00155     typedef hash_map<const Value*, Value*> shash_type;
00156     typedef hash_map<const Constraint*, shash_type*> phash_type;
00157     typedef hash_map<const Variable*, phash_type*> thash_type;
00158     typedef hash_map<const Variable*, Domain*> dhash_type;
00159 
00173     thash_type m_supports;
00174 
00179     dhash_type m_domains;
00180 };
00181 
00182 
00183 CSP_NAMESPACE_END(filters);
00184 CSP_NAMESPACE_END(csp);
00185 
00186 
00187 #endif // _CSP_FILTERS_AC2001_H
00188 
00189 // Local Variables:
00190 // mode: C++
00191 // End:

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