this repo has no description
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
40 /// Create branch and bound engine
41 GECODE_SEARCH_EXPORT Engine*
42 babengine(Space* s, const Options& o);
43
44 /// A BAB engine builder
45 template<class T>
46 class BabBuilder : public Builder {
47 using Builder::opt;
48 public:
49 /// The constructor
50 BabBuilder(const Options& opt);
51 /// The actual build function
52 virtual Engine* operator() (Space* s) const;
53 };
54
55 template<class T>
56 inline
57 BabBuilder<T>::BabBuilder(const Options& opt)
58 : Builder(opt,BAB<T>::best) {}
59
60 template<class T>
61 Engine*
62 BabBuilder<T>::operator() (Space* s) const {
63 return build<T,BAB>(s,opt);
64 }
65
66}}
67
68namespace 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 = nullptr;
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