lds.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, 2004, 2016
*
* 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_LDS_HH__
#define __GECODE_SEARCH_SEQ_LDS_HH__
#include <gecode/search.hh>
#include <gecode/search/support.hh>
#include <gecode/search/worker.hh>
namespace Gecode { namespace Search { namespace Seq {
template<class Tracer>
class Probe : public Worker {
protected:
typedef typename Tracer::ID ID;
class Node {
private:
Space* _space;
const Choice* _choice;
unsigned int _alt;
ID _nid;
public:
Node(void);
Node(Space* s, const Choice* c, unsigned int a, unsigned int nid);
Space* space(void) const;
const Choice* choice(void) const;
unsigned int alt(void) const;
unsigned int nid(void) const;
void next(void);
};
Tracer tracer;
Support::DynamicStack<Node,Heap> ds;
Space* cur;
unsigned int d;
bool exhausted;
public:
Probe(const Options& opt);
void init(Space* s);
void reset(Space* s, unsigned int d);
Statistics statistics(void) const;
~Probe(void);
Space* next(const Options& o);
bool done(void) const;
};
template<class Tracer>
class LDS : public Engine {
protected:
Options opt;
Probe<Tracer> e;
Space* root;
unsigned int d;
bool no_solution;
public:
LDS(Space* s, const Options& o);
virtual Space* next(void);
virtual Statistics statistics(void) const;
void constrain(const Space& b);
void reset(Space* s);
virtual bool stopped(void) const;
virtual ~LDS(void);
};
}}}
#include <gecode/search/seq/lds.hpp>
#endif
// STATISTICS: search-seq
Gecode::Choice
Choice for performing commit
Definition core.hpp:1412
Gecode::Search::Engine
Search engine implementation interface
Definition search.hh:899
Gecode::Search::Options
Search engine options
Definition search.hh:746
Gecode::Search::Seq::LDS::opt
Options opt
Search options.
Definition lds.hh:108
Gecode::Search::Seq::LDS::reset
void reset(Space *s)
Reset engine to restart at space s.
Definition lds.hpp:322
Gecode::Search::Seq::LDS::statistics
virtual Statistics statistics(void) const
Return statistics.
Definition lds.hpp:315
Gecode::Search::Seq::LDS::d
unsigned int d
Current discrepancy.
Definition lds.hh:114
Gecode::Search::Seq::LDS::no_solution
bool no_solution
Solution found for current discrepancy.
Definition lds.hh:116
Gecode::Search::Seq::LDS::next
virtual Space * next(void)
Return next solution (NULL, if none exists or search has been stopped).
Definition lds.hpp:289
Gecode::Search::Seq::LDS::constrain
void constrain(const Space &b)
Constrain future solutions to be better than b (should never be called).
Definition lds.hpp:339
Gecode::Search::Seq::LDS::stopped
virtual bool stopped(void) const
Check whether engine has been stopped.
Definition lds.hpp:309
Gecode::Search::Seq::LDS::root
Space * root
Root node for problem.
Definition lds.hh:112
Gecode::Search::Seq::LDS::e
Probe< Tracer > e
The probe engine.
Definition lds.hh:110
Gecode::Search::Seq::LDS::~LDS
virtual ~LDS(void)
Destructor.
Definition lds.hpp:345
Gecode::Search::Seq::LDS::LDS
LDS(Space *s, const Options &o)
Initialize for space s with options o.
Definition lds.hpp:272
Gecode::Search::Seq::Probe::Node::Node
Node(void)
Default constructor.
Definition lds.hpp:44
Gecode::Search::Seq::Probe::Node::nid
unsigned int nid(void) const
Return node identifier.
Definition lds.hpp:72
Gecode::Search::Seq::Probe::Node::next
void next(void)
Set next alternative
Definition lds.hpp:78
Gecode::Search::Seq::Probe::Node::choice
const Choice * choice(void) const
Return choice.
Definition lds.hpp:60
Gecode::Search::Seq::Probe::Node::alt
unsigned int alt(void) const
Return next alternative.
Definition lds.hpp:66
Gecode::Search::Seq::Probe::Node::space
Space * space(void) const
Return space.
Definition lds.hpp:54
Gecode::Search::Seq::Probe
Probe engine for LDS
Definition lds.hh:45
Gecode::Search::Seq::Probe::ID
Tracer::ID ID
Node identity type.
Definition lds.hh:48
Gecode::Search::Seq::Probe::d
unsigned int d
Current discrepancy.
Definition lds.hh:83
Gecode::Search::Seq::Probe::tracer
Tracer tracer
Search tracer.
Definition lds.hh:77
Gecode::Search::Seq::Probe::init
void init(Space *s)
Initialize with space s.
Definition lds.hpp:100
Gecode::Search::Seq::Probe::cur
Space * cur
Current space.
Definition lds.hh:81
Gecode::Search::Seq::Probe::done
bool done(void) const
Test whether probing is done.
Definition lds.hpp:127
Gecode::Search::Seq::Probe::~Probe
~Probe(void)
Destructor.
Definition lds.hpp:133
Gecode::Search::Seq::Probe::ds
Support::DynamicStack< Node, Heap > ds
Stack storing current path in search tree
Definition lds.hh:79
Gecode::Search::Seq::Probe::Probe
Probe(const Options &opt)
Initialize.
Definition lds.hpp:92
Gecode::Search::Seq::Probe::next
Space * next(const Options &o)
Search for next solution
Definition lds.hpp:142
Gecode::Search::Seq::Probe::statistics
Statistics statistics(void) const
Return statistics.
Definition lds.hpp:121
Gecode::Search::Seq::Probe::exhausted
bool exhausted
Whether entire search space has been exhausted.
Definition lds.hh:85
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::Statistics
Statistics(void)
Initialize.
Definition statistics.hpp:45
Gecode::Search::Worker::Worker
Worker(void)
Initialize.
Definition worker.hh:70
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Support::DynamicStack
Stack with arbitrary number of elements.
Definition dynamic-stack.hpp:42
Gecode::Tracer
Tracer.
Definition tracer.hpp:149
Gecode::Search::Seq
Definition pbs.cpp:36
Gecode::Search
Search engines
Gecode
Gecode toplevel namespace
support.hh
search.hh
lds.hpp
worker.hh