support.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, 2008
*
* 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_SUPPORT_HH__
#define __GECODE_SEARCH_SUPPORT_HH__
#include <gecode/search.hh>
namespace Gecode { namespace Search {
forceinline Space*
snapshot(Space* s, const Options& o);
template<class Worker>
class WorkerToEngine : public Engine {
protected:
Worker w;
public:
WorkerToEngine(Space* s, const Options& o);
virtual Space* next(void);
virtual Search::Statistics statistics(void) const;
virtual bool stopped(void) const;
virtual void constrain(const Space& b);
virtual void reset(Space* s);
virtual NoGoods& nogoods(void);
};
forceinline Space*
snapshot(Space* s, const Options& o) {
return o.clone ? s->clone() : s;
}
template<class Worker>
WorkerToEngine<Worker>::WorkerToEngine(Space* s, const Options& o)
: w(s,o) {}
template<class Worker>
Space*
WorkerToEngine<Worker>::next(void) {
return w.next();
}
template<class Worker>
Search::Statistics
WorkerToEngine<Worker>::statistics(void) const {
return w.statistics();
}
template<class Worker>
bool
WorkerToEngine<Worker>::stopped(void) const {
return w.stopped();
}
template<class Worker>
void
WorkerToEngine<Worker>::reset(Space* s) {
w.reset(s);
}
template<class Worker>
void
WorkerToEngine<Worker>::constrain(const Space& b) {
w.constrain(b);
}
template<class Worker>
NoGoods&
WorkerToEngine<Worker>::nogoods(void) {
return w.nogoods();
}
}}
#endif
// STATISTICS: search-other
Gecode::NoGoods
No-goods recorded from restarts.
Definition core.hpp:1588
Gecode::Search::Engine
Search engine implementation interface
Definition search.hh:899
Gecode::Search::Options
Search engine options
Definition search.hh:746
Gecode::Search::Options::clone
bool clone
Whether engines create a clone when being initialized.
Definition search.hh:749
Gecode::Search::Statistics
Search engine statistics
Definition search.hh:147
Gecode::Search::WorkerToEngine::reset
virtual void reset(Space *s)
Reset engine to restart at space s.
Definition support.hh:96
Gecode::Search::WorkerToEngine::constrain
virtual void constrain(const Space &b)
Constrain future solutions to be better than b.
Definition support.hh:101
Gecode::Search::WorkerToEngine::WorkerToEngine
WorkerToEngine(Space *s, const Options &o)
Initialization.
Definition support.hh:77
Gecode::Search::WorkerToEngine::stopped
virtual bool stopped(void) const
Check whether engine has been stopped.
Definition support.hh:91
Gecode::Search::WorkerToEngine::w
Worker w
The worker to wrap into an engine.
Definition support.hh:50
Gecode::Search::WorkerToEngine::nogoods
virtual NoGoods & nogoods(void)
Return no-goods.
Definition support.hh:106
Gecode::Search::WorkerToEngine::statistics
virtual Search::Statistics statistics(void) const
Return statistics.
Definition support.hh:86
Gecode::Search::WorkerToEngine::next
virtual Space * next(void)
Return next solution (NULL, if none exists or search has been stopped).
Definition support.hh:81
Gecode::Search::Worker
Search worker statistics
Definition worker.hh:44
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Space::clone
Space * clone(CloneStatistics &stat=unused_clone) const
Clone space.
Definition core.hpp:3224
Gecode::Search
Search engines
Gecode::Search::snapshot
Space * snapshot(Space *s, const Options &o)
Clone space s dependening on options o.
Definition support.hh:71
Gecode
Gecode toplevel namespace
search.hh
forceinline
#define forceinline
Definition config.hpp:187