bab.hh
Go to the documentation of this file.00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 00002 /* 00003 * Main authors: 00004 * Christian Schulte <schulte@gecode.org> 00005 * 00006 * Copyright: 00007 * Christian Schulte, 2009 00008 * 00009 * This file is part of Gecode, the generic constraint 00010 * development environment: 00011 * http://www.gecode.org 00012 * 00013 * Permission is hereby granted, free of charge, to any person obtaining 00014 * a copy of this software and associated documentation files (the 00015 * "Software"), to deal in the Software without restriction, including 00016 * without limitation the rights to use, copy, modify, merge, publish, 00017 * distribute, sublicense, and/or sell copies of the Software, and to 00018 * permit persons to whom the Software is furnished to do so, subject to 00019 * the following conditions: 00020 * 00021 * The above copyright notice and this permission notice shall be 00022 * included in all copies or substantial portions of the Software. 00023 * 00024 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00025 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00026 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00027 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00028 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00029 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00030 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00031 * 00032 */ 00033 00034 #ifndef __GECODE_SEARCH_PAR_BAB_HH__ 00035 #define __GECODE_SEARCH_PAR_BAB_HH__ 00036 00037 #include <gecode/search/par/engine.hh> 00038 00039 namespace Gecode { namespace Search { namespace Par { 00040 00042 template<class Tracer> 00043 class BAB : public Engine<Tracer> { 00044 protected: 00045 using Engine<Tracer>::idle; 00046 using Engine<Tracer>::busy; 00047 using Engine<Tracer>::stop; 00048 using Engine<Tracer>::block; 00049 using Engine<Tracer>::e_search; 00050 using Engine<Tracer>::e_reset_ack_start; 00051 using Engine<Tracer>::e_reset_ack_stop; 00052 using Engine<Tracer>::n_busy; 00053 using Engine<Tracer>::m_search; 00054 using Engine<Tracer>::m_wait_reset; 00055 using Engine<Tracer>::opt; 00056 using Engine<Tracer>::release; 00057 using Engine<Tracer>::signal; 00058 using Engine<Tracer>::solutions; 00059 using Engine<Tracer>::terminate; 00060 using Engine<Tracer>::workers; 00061 using Engine<Tracer>::C_WAIT; 00062 using Engine<Tracer>::C_RESET; 00063 using Engine<Tracer>::C_TERMINATE; 00064 using Engine<Tracer>::C_WORK; 00066 class Worker : public Engine<Tracer>::Worker { 00067 protected: 00068 using Engine<Tracer>::Worker::_engine; 00069 using Engine<Tracer>::Worker::m; 00070 using Engine<Tracer>::Worker::path; 00071 using Engine<Tracer>::Worker::cur; 00072 using Engine<Tracer>::Worker::d; 00073 using Engine<Tracer>::Worker::idle; 00074 using Engine<Tracer>::Worker::node; 00075 using Engine<Tracer>::Worker::fail; 00076 using Engine<Tracer>::Worker::start; 00077 using Engine<Tracer>::Worker::tracer; 00078 using Engine<Tracer>::Worker::stop; 00080 int mark; 00082 Space* best; 00083 public: 00085 Worker(Space* s, BAB& e); 00087 BAB& engine(void) const; 00089 virtual void run(void); 00091 void better(Space* b); 00093 void find(void); 00095 void reset(Space* s, unsigned int ngdl); 00097 virtual ~Worker(void); 00098 }; 00100 Worker** _worker; 00102 Space* best; 00103 public: 00105 Worker* worker(unsigned int i) const; 00106 00108 00109 00110 void solution(Space* s); 00112 00114 00115 00116 BAB(Space* s, const Options& o); 00118 virtual Statistics statistics(void) const; 00120 virtual void reset(Space* s); 00122 virtual void constrain(const Space& b); 00125 virtual NoGoods& nogoods(void); 00127 virtual ~BAB(void); 00129 }; 00130 00131 }}} 00132 00133 #include <gecode/search/par/bab.hpp> 00134 00135 #endif 00136 00137 // STATISTICS: search-par