Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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
38namespace Gecode { namespace Search {
39
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
68namespace Gecode {
69
70 template<class T>
71 inline
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
NNF * l
Left subtree.
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int n
Number of negative literals for node type.
Depth-first branch-and-bound search engine.
Definition search.hh:1070
BAB(T *s, const Search::Options &o=Search::Options::def)
Initialize engine for space s and options o.
Definition bab.hpp:72
A BAB engine builder.
Definition bab.hpp:46
virtual Engine * operator()(Space *s) const
The actual build function.
Definition bab.hpp:62
BabBuilder(const Options &opt)
The constructor.
Definition bab.hpp:57
A class for building search engines.
Definition search.hh:965
Options opt
Stored and already expanded options.
Definition search.hh:968
Search engine implementation interface
Definition search.hh:899
Search engine options
Definition search.hh:746
Computation spaces.
Definition core.hpp:1742
T * bab(T *s, const Search::Options &o=Search::Options::def)
Perform depth-first branch-and-bound search for subclass T of space s and options o.
Definition bab.hpp:77
Engine * babengine(Space *s, const Options &o)
Create branch and bound engine.
Definition bab.cpp:45
Engine * build(Space *s, const Options &opt)
Build an engine of type E for a script T.
Definition build.hpp:58
Gecode toplevel namespace
Search::Builder * SEB
Type for a search engine builder.
Definition search.hh:993
#define GECODE_SEARCH_EXPORT
Definition search.hh:67