pbs.hh
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2015
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __GECODE_SEARCH_SEQ_PBS_HH__
#define __GECODE_SEARCH_SEQ_PBS_HH__
#include <gecode/search.hh>
namespace Gecode { namespace Search { namespace Seq {
class SharedStopInfo {
public:
bool done;
unsigned long int l;
};
class GECODE_SEARCH_EXPORT PortfolioStop : public Stop {
private:
Stop* so;
SharedStopInfo* ssi;
public:
PortfolioStop(Stop* so);
void share(SharedStopInfo* ssi);
virtual bool stop(const Statistics& s, const Options& o);
};
class Slave {
protected:
Engine* slave;
Stop* stop;
public:
void init(Engine* s, Stop* so);
Space* next(void);
Statistics statistics(void) const;
bool stopped(void) const;
void constrain(const Space& b);
void run(void);
~Slave(void);
};
template<bool best>
class GECODE_SEARCH_EXPORT PBS : public Engine {
protected:
Statistics stat;
SharedStopInfo ssi;
unsigned int slice;
Slave* slaves;
unsigned int n_slaves;
unsigned int cur;
bool slave_stop;
public:
PBS(Engine** slaves, Stop** stops, unsigned int n,
const Statistics& stat, const Search::Options& opt);
virtual Space* next(void);
virtual Statistics statistics(void) const;
virtual bool stopped(void) const;
virtual void constrain(const Space& b);
virtual ~PBS(void);
};
}}}
#include <gecode/search/seq/pbs.hpp>
#endif
// STATISTICS: search-seq
Gecode::Search::Engine
Search engine implementation interface
Definition search.hh:899
Gecode::Search::Options
Search engine options
Definition search.hh:746
Gecode::Search::Seq::PBS::slaves
Slave * slaves
Slaves.
Definition pbs.hh:101
Gecode::Search::Seq::PBS::ssi
SharedStopInfo ssi
Shared slave information.
Definition pbs.hh:97
Gecode::Search::Seq::PBS::n_slaves
unsigned int n_slaves
Number of slave engines.
Definition pbs.hh:103
Gecode::Search::Seq::PBS::slave_stop
bool slave_stop
Whether a slave has been stopped.
Definition pbs.hh:107
Gecode::Search::Seq::PBS::slice
unsigned int slice
Size of a slice.
Definition pbs.hh:99
Gecode::Search::Seq::PBS::next
virtual Space * next(void)
Return next solution (NULL, if none exists or search has been stopped).
Definition pbs.hpp:94
Gecode::Search::Seq::PBS::stat
Statistics stat
Master statistics.
Definition pbs.hh:95
Gecode::Search::Seq::PBS::stopped
virtual bool stopped(void) const
Check whether engine has been stopped.
Definition pbs.hpp:137
Gecode::Search::Seq::PBS::statistics
virtual Statistics statistics(void) const
Return statistics.
Definition pbs.hpp:143
Gecode::Search::Seq::PBS::cur
unsigned int cur
Current slave to run.
Definition pbs.hh:105
Gecode::Search::Seq::PBS::constrain
virtual void constrain(const Space &b)
Constrain future solutions to be better than b.
Definition pbs.hpp:152
Gecode::Search::Seq::PBS::PBS
PBS(Engine **slaves, Stop **stops, unsigned int n, const Statistics &stat, const Search::Options &opt)
Initialize.
Definition pbs.hpp:77
Gecode::Search::Seq::PortfolioStop::stop
virtual bool stop(const Statistics &s, const Options &o)
Return true if portfolio engine must be stopped.
Definition pbs.cpp:39
Gecode::Search::Seq::PortfolioStop::share
void share(SharedStopInfo *ssi)
Intialize shared stop information.
Definition pbs.hpp:43
Gecode::Search::Seq::PortfolioStop::PortfolioStop
PortfolioStop(Stop *so)
Initialize.
Definition pbs.hpp:40
Gecode::Search::Seq::SharedStopInfo
Shared stop information.
Definition pbs.hh:42
Gecode::Search::Seq::SharedStopInfo::l
unsigned long int l
The current failure limit, incremented for each slice.
Definition pbs.hh:47
Gecode::Search::Seq::SharedStopInfo::done
bool done
Whether search stopped because the slice is done.
Definition pbs.hh:45
Gecode::Search::Seq::Slave
Runnable slave of a portfolio master.
Definition pbs.hh:67
Gecode::Search::Seq::Slave::stopped
bool stopped(void) const
Check whether slave has been stopped.
Definition pbs.hpp:61
Gecode::Search::Seq::Slave::next
Space * next(void)
Return next solution.
Definition pbs.hpp:53
Gecode::Search::Seq::Slave::slave
Engine * slave
The slave engine.
Definition pbs.hh:70
Gecode::Search::Seq::Slave::constrain
void constrain(const Space &b)
Constrain with better solution b.
Definition pbs.hpp:65
Gecode::Search::Seq::Slave::stop
Stop * stop
Stop object.
Definition pbs.hh:72
Gecode::Search::Seq::Slave::init
void init(Engine *s, Stop *so)
Initialize with slave s and its stop object so.
Definition pbs.hpp:49
Gecode::Search::Seq::Slave::statistics
Statistics statistics(void) const
Return statistics of slave.
Definition pbs.hpp:57
Gecode::Search::Seq::Slave::~Slave
~Slave(void)
Delete slave.
Definition pbs.hpp:69
Gecode::Search::Seq::Slave::run
void run(void)
Perform one run.
Gecode::Search::Statistics
Search engine statistics
Definition search.hh:147
Gecode::Search::Stop
Base-class for Stop-object.
Definition search.hh:799
Gecode::Search::Stop::Stop
Stop(void)
Default constructor.
Definition stop.hpp:41
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Search::Seq
Definition pbs.cpp:36
Gecode::Search
Search engines
Gecode
Gecode toplevel namespace
search.hh
GECODE_SEARCH_EXPORT
#define GECODE_SEARCH_EXPORT
Definition search.hh:67
pbs.hpp