Generated on Sun Feb 17 15:24:29 2019 for Gecode by doxygen 1.6.3

pbs.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, 2015
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_SEQ_PBS_HH__
00035 #define __GECODE_SEARCH_SEQ_PBS_HH__
00036 
00037 #include <gecode/search.hh>
00038 
00039 namespace Gecode { namespace Search { namespace Seq {
00040 
00042   class SharedStopInfo {
00043   public:
00045     bool done;
00047     unsigned long int l;
00048   };
00049 
00051   class GECODE_SEARCH_EXPORT PortfolioStop : public Stop {
00052   private:
00054     Stop* so;
00056     SharedStopInfo* ssi;
00057   public:
00059     PortfolioStop(Stop* so);
00061     void share(SharedStopInfo* ssi);
00063     virtual bool stop(const Statistics& s, const Options& o);
00064   };
00065 
00067   class Slave {
00068   protected:
00070     Engine* slave;
00072     Stop* stop;
00073   public:
00075     void init(Engine* s, Stop* so);
00077     Space* next(void);
00079     Statistics statistics(void) const;
00081     bool stopped(void) const;
00083     void constrain(const Space& b);
00085     void run(void);
00087     ~Slave(void);
00088   };
00089 
00091   template<bool best>
00092   class GECODE_SEARCH_EXPORT PBS : public Engine {
00093   protected:
00095     Statistics stat;
00097     SharedStopInfo ssi;
00099     unsigned int slice;
00101     Slave* slaves;
00103     unsigned int n_slaves;
00105     unsigned int cur;
00107     bool slave_stop;
00108   public:
00110     PBS(Engine** slaves, Stop** stops, unsigned int n,
00111         const Statistics& stat, const Search::Options& opt);
00113     virtual Space* next(void);
00115     virtual Statistics statistics(void) const;
00117     virtual bool stopped(void) const;
00119     virtual void constrain(const Space& b);
00121     virtual ~PBS(void);
00122   };
00123 
00124 }}}
00125 
00126 #include <gecode/search/seq/pbs.hpp>
00127 
00128 #endif
00129 
00130 // STATISTICS: search-seq