00001 // BM.h -- The back marking filter interface. See "FC w/ BM", 00002 // Technical Report AISL-48-93, June 1993, Patrick Prosser 00003 // <pat@cs.strath.ac.uk>. 00004 00005 /* 00006 * Copyright (C) 1998 Tudor Hulubei <tudor@hulubei.net>. 00007 * 00008 * This library is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as 00010 * published by the Free Software Foundation; either version 2, or (at 00011 * your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 00021 * 02111-1307, USA. 00022 */ 00023 00024 // $Id: BM_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $ 00025 00026 #ifndef _CSP_FILTERS_BM_H 00027 #define _CSP_FILTERS_BM_H 00028 00029 00030 CSP_NAMESPACE_BEGIN(csp); 00031 CSP_NAMESPACE_BEGIN(filters); 00032 00033 00039 class CSP_API BM : 00040 public Filter 00041 { 00042 public: 00043 BM(Problem& problem, Retraction& retraction) : 00044 Filter(L"Back Marking", L"BM", problem, retraction) 00045 { 00046 /* FIXME: Does BM really require that all the variables have 00047 the same domain size? Can we make m_mcl a vector of arrays? */ 00048 size_t size = (**problem.beginVariables()).domain().size(); 00049 m_mcl = new size_t [problem.variables() * size]; 00050 m_mbl = new size_t [problem.variables()]; 00051 } 00052 00053 ~BM() 00054 { 00055 delete m_mbl; 00056 delete m_mcl; 00057 } 00058 00060 virtual bool restoresArcConsistency() const { return false; } 00061 00062 virtual bool propagate( 00063 const vlist_type& uninstantiatedVariables, 00064 const vlist_type& modifiedVariables, 00065 const bool keepChanges = true); 00066 00067 private: 00068 /* NOTE: The backmarking fiter doesn't work with dynamic CSPs, 00069 because the m_mcl & m_mbl arrays have fixed size. */ 00070 00071 /* Maximum checking level. When a consistency ckeck is performed 00072 between v[h] and v[i]=k, m_mcl[i,k] becomes h. */ 00073 size_t* m_mcl; 00074 00075 /* Minimum backtracking level. m_mbl[i] records the shallowest 00076 variable in the search tree that has been re-instantiated since 00077 we last visited v[i]. */ 00078 size_t* m_mbl; 00079 00081 BM(const BM&); 00082 00084 BM& operator=(const BM&); 00085 }; 00086 00087 00088 CSP_NAMESPACE_END(filters); 00089 CSP_NAMESPACE_END(csp); 00090 00091 00092 #endif // _CSP_FILTERS_BM_H 00093 00094 // Local Variables: 00095 // mode: C++ 00096 // End:
1.3.9.1