bab.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, 2009
*
* 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_PAR_BAB_HH__
#define __GECODE_SEARCH_PAR_BAB_HH__
#include <gecode/search/par/engine.hh>
namespace Gecode { namespace Search { namespace Par {
template<class Tracer>
class BAB : public Engine<Tracer> {
protected:
using Engine<Tracer>::idle;
using Engine<Tracer>::busy;
using Engine<Tracer>::stop;
using Engine<Tracer>::block;
using Engine<Tracer>::e_search;
using Engine<Tracer>::e_reset_ack_start;
using Engine<Tracer>::e_reset_ack_stop;
using Engine<Tracer>::n_busy;
using Engine<Tracer>::m_search;
using Engine<Tracer>::m_wait_reset;
using Engine<Tracer>::opt;
using Engine<Tracer>::release;
using Engine<Tracer>::signal;
using Engine<Tracer>::solutions;
using Engine<Tracer>::terminate;
using Engine<Tracer>::workers;
using Engine<Tracer>::C_WAIT;
using Engine<Tracer>::C_RESET;
using Engine<Tracer>::C_TERMINATE;
using Engine<Tracer>::C_WORK;
class Worker : public Engine<Tracer>::Worker {
protected:
using Engine<Tracer>::Worker::_engine;
using Engine<Tracer>::Worker::m;
using Engine<Tracer>::Worker::path;
using Engine<Tracer>::Worker::cur;
using Engine<Tracer>::Worker::d;
using Engine<Tracer>::Worker::idle;
using Engine<Tracer>::Worker::node;
using Engine<Tracer>::Worker::fail;
using Engine<Tracer>::Worker::start;
using Engine<Tracer>::Worker::tracer;
using Engine<Tracer>::Worker::stop;
int mark;
Space* best;
public:
Worker(Space* s, BAB& e);
BAB& engine(void) const;
virtual void run(void);
void better(Space* b);
void find(void);
void reset(Space* s, unsigned int ngdl);
virtual ~Worker(void);
};
Worker** _worker;
Space* best;
public:
Worker* worker(unsigned int i) const;
void solution(Space* s);
BAB(Space* s, const Options& o);
virtual Statistics statistics(void) const;
virtual void reset(Space* s);
virtual void constrain(const Space& b);
virtual NoGoods& nogoods(void);
virtual ~BAB(void);
};
}}}
#include <gecode/search/par/bab.hpp>
#endif
// STATISTICS: search-par
Gecode::NoGoods
No-goods recorded from restarts.
Definition core.hpp:1588
Gecode::Search::Options
Search engine options
Definition search.hh:746
Gecode::Search::Par::BAB::Worker
Parallel branch-and-bound search worker
Definition bab.hh:66
Gecode::Search::Par::BAB::Worker::find
void find(void)
Try to find some work.
Definition bab.hpp:148
Gecode::Search::Par::BAB::Worker::best
Space * best
Best solution found so far.
Definition bab.hh:82
Gecode::Search::Par::BAB::Worker::mark
int mark
Number of entries not yet constrained to be better.
Definition bab.hh:80
Gecode::Search::Par::BAB::Worker::Worker
Worker(Space *s, BAB &e)
Initialize for space s with engine e.
Definition bab.hpp:76
Gecode::Search::Par::BAB::Worker::better
void better(Space *b)
Accept better solution b.
Definition bab.hpp:106
Gecode::Search::Par::BAB::Worker::engine
BAB & engine(void) const
Provide access to engine.
Definition bab.hpp:41
Gecode::Search::Par::BAB::Worker::~Worker
virtual ~Worker(void)
Destructor.
Definition bab.hpp:411
Gecode::Search::Par::BAB::Worker::run
virtual void run(void)
Start execution of worker.
Definition bab.hpp:209
Gecode::Search::Par::BAB::_worker
Worker ** _worker
Array of worker references.
Definition bab.hh:100
Gecode::Search::Par::BAB::solution
void solution(Space *s)
Report solution s.
Definition bab.hpp:117
Gecode::Search::Par::BAB::worker
Worker * worker(unsigned int i) const
Provide access to worker i.
Definition bab.hpp:46
Gecode::Search::Par::BAB::constrain
virtual void constrain(const Space &b)
Constrain future solutions to be better than b.
Definition bab.hpp:187
Gecode::Search::Par::BAB::reset
virtual void reset(Space *s)
Reset engine to restart at space s.
Definition bab.hpp:360
Gecode::Search::Par::BAB::~BAB
virtual ~BAB(void)
Destructor.
Definition bab.hpp:416
Gecode::Search::Par::BAB::best
Space * best
Best solution so far.
Definition bab.hh:102
Gecode::Search::Par::BAB::BAB
BAB(Space *s, const Options &o)
Initialize for space s with options o.
Definition bab.hpp:81
Gecode::Search::Par::BAB::statistics
virtual Statistics statistics(void) const
Return statistics.
Definition bab.hpp:178
Gecode::Search::Par::BAB::nogoods
virtual NoGoods & nogoods(void)
Constrain Return no-goods.
Definition bab.hpp:389
Gecode::Search::Par::Engine::Worker::m
Support::Mutex m
Mutex for access to worker.
Definition engine.hh:57
Gecode::Search::Par::Engine::Worker::_engine
Engine & _engine
Reference to engine.
Definition engine.hh:55
Gecode::Search::Par::Engine::Worker::cur
Space * cur
Current space being explored.
Definition engine.hh:61
Gecode::Search::Par::Engine::Worker::tracer
Tracer tracer
Search tracer.
Definition engine.hh:52
Gecode::Search::Par::Engine::Worker::d
unsigned int d
Distance until next clone.
Definition engine.hh:63
Gecode::Search::Par::Engine::Worker::idle
bool idle
Whether the worker is idle.
Definition engine.hh:65
Gecode::Search::Par::Engine::Worker::path
Path< Tracer > path
Current path ins search tree.
Definition engine.hh:59
Gecode::Search::Par::Engine::idle
void idle(void)
Report that worker is idle.
Definition engine.hpp:152
Gecode::Search::Par::Engine::opt
const Options & opt(void) const
Provide access to search options.
Definition engine.hpp:47
Gecode::Search::Par::Engine::e_reset_ack_stop
Support::Event e_reset_ack_stop
Event for reset acknowledgment stopped.
Definition engine.hh:151
Gecode::Search::Par::Engine::e_search
Support::Event e_search
Event for search (solution found, no more solutions, search stopped).
Definition engine.hh:169
Gecode::Search::Par::Engine::solutions
Support::DynamicQueue< Space *, Heap > solutions
Queue of solutions.
Definition engine.hh:171
Gecode::Search::Par::Engine::stop
void stop(void)
Report that worker has been stopped.
Definition engine.hpp:172
Gecode::Search::Par::Engine::block
void block(void)
Block all workers.
Definition engine.hpp:73
Gecode::Search::Par::Engine::m_wait_reset
Support::Mutex m_wait_reset
Mutex for waiting for reset.
Definition engine.hh:153
Gecode::Search::Par::Engine::m_search
Support::Mutex m_search
Mutex for search.
Definition engine.hh:167
Gecode::Search::Par::Engine::e_reset_ack_start
Support::Event e_reset_ack_start
Event for reset acknowledgment started.
Definition engine.hh:149
Gecode::Search::Par::Engine::Engine
Engine(const Options &o)
Initialize with options o.
Definition engine.hpp:116
Gecode::Search::Par::Engine::busy
void busy(void)
Report that worker is busy.
Definition engine.hpp:163
Gecode::Search::Par::Engine::release
void release(Cmd c)
Release all workers.
Definition engine.hpp:79
Gecode::Search::Par::Engine::signal
bool signal(void) const
Whether search state changed such that signal is needed.
Definition engine.hpp:147
Gecode::Search::Par::Engine::terminate
void terminate(void)
For engine to peform thread termination.
Definition engine.hpp:216
Gecode::Search::Par::Engine::n_busy
volatile unsigned int n_busy
Number of busy workers.
Definition engine.hh:173
Gecode::Search::Par::Engine::workers
unsigned int workers(void) const
Return number of workers.
Definition engine.hpp:52
Gecode::Search::Par::Engine::C_WORK
@ C_WORK
Perform work.
Definition engine.hh:94
Gecode::Search::Par::Engine::C_RESET
@ C_RESET
Perform reset operation.
Definition engine.hh:96
Gecode::Search::Par::Engine::C_WAIT
@ C_WAIT
Run into wait lock.
Definition engine.hh:95
Gecode::Search::Par::Engine::C_TERMINATE
@ C_TERMINATE
Terminate.
Definition engine.hh:97
Gecode::Search::Statistics
Search engine statistics
Definition search.hh:147
Gecode::Search::Statistics::reset
void reset(void)
Reset.
Definition statistics.hpp:39
Gecode::Search::Statistics::fail
unsigned long int fail
Number of failed nodes in search tree.
Definition search.hh:150
Gecode::Search::Statistics::node
unsigned long int node
Number of nodes expanded.
Definition search.hh:152
Gecode::Search::Worker::start
void start(void)
Reset stop information.
Definition worker.hh:74
Gecode::Search::Worker::Worker
Worker(void)
Initialize.
Definition worker.hh:70
Gecode::Search::Worker::stop
bool stop(const Options &o)
Check whether engine must be stopped.
Definition worker.hh:79
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Tracer
Tracer.
Definition tracer.hpp:149
engine.hh
Gecode::Search::Par
Definition bab.hh:39
Gecode::Search
Search engines
Gecode
Gecode toplevel namespace
bab.hpp