Generated on Thu Apr 5 2018 19:44:19 for Gecode by doxygen 1.8.13
lds.hh
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2004, 2016
8  *
9  * Last modified:
10  * $Date$ by $Author$
11  * $Revision$
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef __GECODE_SEARCH_SEQ_LDS_HH__
39 #define __GECODE_SEARCH_SEQ_LDS_HH__
40 
41 #include <gecode/search.hh>
42 #include <gecode/search/support.hh>
43 #include <gecode/search/worker.hh>
44 
45 namespace Gecode { namespace Search { namespace Seq {
46 
48  template<class Tracer>
49  class Probe : public Worker {
50  protected:
52  typedef typename Tracer::ID ID;
54  class Node {
55  private:
57  Space* _space;
59  const Choice* _choice;
61  unsigned int _alt;
63  ID _nid;
64  public:
66  Node(void);
68  Node(Space* s, const Choice* c, unsigned int a, unsigned int nid);
70  Space* space(void) const;
72  const Choice* choice(void) const;
74  unsigned int alt(void) const;
76  unsigned int nid(void) const;
78  void next(void);
79  };
87  unsigned int d;
89  bool exhausted;
90  public:
92  Probe(const Options& opt);
94  void init(Space* s);
96  void reset(Space* s, unsigned int d);
98  Statistics statistics(void) const;
100  ~Probe(void);
102  Space* next(const Options& o);
104  bool done(void) const;
105  };
106 
108  template<class Tracer>
109  class LDS : public Engine {
110  protected:
118  unsigned int d;
121  public:
123  LDS(Space* s, const Options& o);
125  virtual Space* next(void);
127  virtual Statistics statistics(void) const;
129  void constrain(const Space& b);
131  void reset(Space* s);
133  virtual bool stopped(void) const;
135  virtual ~LDS(void);
136  };
137 
138 }}}
139 
140 #include <gecode/search/seq/lds.hpp>
141 
142 #endif
143 
144 // STATISTICS: search-seq
Space * root
Root node for problem.
Definition: lds.hh:116
bool exhausted
Whether entire search space has been exhausted.
Definition: lds.hh:89
Search engine implementation interface
Definition: search.hh:901
Space * cur
Current space.
Definition: lds.hh:85
Search engine statistics
Definition: search.hh:149
Search engine options
Definition: search.hh:748
Probe engine for LDS
Definition: lds.hh:49
unsigned int nid(void) const
Return node identifier.
Definition: lds.hpp:76
Space * space(void) const
Return space.
Definition: lds.hpp:58
Tracer::ID ID
Node identity type.
Definition: lds.hh:52
Node(void)
Default constructor.
Definition: lds.hpp:48
unsigned int d
Current discrepancy.
Definition: lds.hh:87
bool stopped(void) const
Check whether engine has been stopped.
Definition: worker.hh:91
void next(void)
Set next alternative
Definition: lds.hpp:82
Computation spaces.
Definition: core.hpp:1668
Probe(const Options &opt)
Initialize.
Definition: lds.hpp:96
Gecode::FloatVal c(-8, 8)
Options opt
The options.
Definition: test.cpp:101
unsigned int alt(void) const
Return next alternative.
Definition: lds.hpp:70
Statistics statistics(void) const
Return statistics.
Definition: lds.hpp:125
Support::DynamicStack< Node, Heap > ds
Stack storing current path in search tree
Definition: lds.hh:83
const Choice * choice(void) const
Return choice.
Definition: lds.hpp:64
Search worker statistics
Definition: worker.hh:48
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
~Probe(void)
Destructor.
Definition: lds.hpp:137
bool no_solution
Solution found for current discrepancy.
Definition: lds.hh:120
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Choice for performing commit
Definition: core.hpp:1338
bool done(void) const
Test whether probing is done.
Definition: lds.hpp:131
Stack with arbitrary number of elements.
Tracer tracer
Search tracer.
Definition: lds.hh:81
Tracer.
Definition: tracer.hpp:153
Probe< Tracer > e
The probe engine.
Definition: lds.hh:114
void init(Space *s)
Initialize with space s.
Definition: lds.hpp:104
unsigned int d
Current discrepancy.
Definition: lds.hh:118
Gecode toplevel namespace
Options opt
Search options.
Definition: lds.hh:112
Node in the search tree for LDS
Definition: lds.hh:54
Limited discrepancy search engine implementation.
Definition: lds.hh:109
void reset(void)
Reset.
Definition: statistics.hpp:43