Generated on Sat Jan 12 2019 20:58:51 for Gecode by doxygen 1.8.13
bab.hpp
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  * Contributing authors:
7  * Guido Tack <tack@gecode.org>
8  *
9  * Copyright:
10  * Christian Schulte, 2004
11  * Guido Tack, 2004
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 namespace Gecode { namespace Search {
39 
41  GECODE_SEARCH_EXPORT Engine*
42  babengine(Space* s, const Options& o);
43 
45  template<class T>
46  class BabBuilder : public Builder {
47  using Builder::opt;
48  public:
50  BabBuilder(const Options& opt);
52  virtual Engine* operator() (Space* s) const;
53  };
54 
55  template<class T>
56  inline
58  : Builder(opt,BAB<T>::best) {}
59 
60  template<class T>
61  Engine*
63  return build<T,BAB>(s,opt);
64  }
65 
66 }}
67 
68 namespace Gecode {
69 
70  template<class T>
71  inline
72  BAB<T>::BAB(T* s, const Search::Options& o)
73  : Search::Base<T>(Search::babengine(s,o)) {}
74 
75  template<class T>
76  inline T*
77  bab(T* s, const Search::Options& o) {
78  BAB<T> b(s,o);
79  T* l = NULL;
80  while (T* n = b.next()) {
81  delete l; l = n;
82  }
83  return l;
84  }
85 
86  template<class T>
87  SEB
88  bab(const Search::Options& o) {
89  return new Search::BabBuilder<T>(o);
90  }
91 
92 }
93 
94 // STATISTICS: search-other
Search engine implementation interface
Definition: search.hh:899
NNF * l
Left subtree.
Definition: bool-expr.cpp:240
#define GECODE_SEARCH_EXPORT
Definition: search.hh:67
Search engine options
Definition: search.hh:746
A class for building search engines.
Definition: search.hh:965
Options opt
Stored and already expanded options.
Definition: search.hh:968
A BAB engine builder.
Definition: bab.hpp:46
virtual T * next(void)
Return next solution (NULL, if none exists or search has been stopped)
Definition: base.hpp:46
Computation spaces.
Definition: core.hpp:1701
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
Depth-first branch-and-bound search engine.
Definition: search.hh:1070
struct Gecode::@593::NNF::@62::@63 b
For binary nodes (and, or, eqv)
Engine * babengine(Space *s, const Options &o)
Create branch and bound engine.
Definition: bab.cpp:45
T * bab(T *s, const Search::Options &o)
Perform depth-first branch-and-bound search for subclass T of space s and options o...
Definition: bab.hpp:77
BAB(T *s, const Search::Options &o=Search::Options::def)
Initialize engine for space s and options o.
Definition: bab.hpp:72
BabBuilder(const Options &opt)
The constructor.
Definition: bab.hpp:57
bool best(void) const
Whether engine is a best solution search engine.
Definition: build.hpp:48
virtual Engine * operator()(Space *s) const
The actual build function.
Definition: bab.hpp:62
Gecode toplevel namespace