Generated on Wed Jun 8 2016 10:43:17 for Gecode by doxygen 1.8.11
rbs.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  * Guido Tack <tack@gecode.org>
6  *
7  * Copyright:
8  * Christian Schulte, 2014
9  * Guido Tack, 2012
10  *
11  * Last modified:
12  * $Date: 2015-03-19 14:02:56 +0100 (Thu, 19 Mar 2015) $ by $Author: schulte $
13  * $Revision: 14468 $
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 #include <gecode/search/support.hh>
42 
43 namespace Gecode {
44 
45  template<template<class> class E, class T>
47  RBS<E,T>::RBS(T* s, const Search::Options& m_opt) {
48  if (m_opt.cutoff == NULL)
49  throw Search::UninitializedCutoff("RBS::RBS");
50  Search::Options e_opt(m_opt.expand());
51  e_opt.clone = false;
53  e_opt.stop = rs;
54  Space* master;
55  Space* slave;
56  if (s->status(rs->m_stat) == SS_FAILED) {
57  rs->m_stat.fail++;
58  master = NULL;
59  slave = NULL;
60  } else {
61  if (m_opt.clone)
62  master = s->clone();
63  else
64  master = s;
65  slave = master->clone();
66  CRI cri(0,0,0,NULL,NoGoods::eng);
67  slave->slave(cri);
68  }
69  E<T> engine(dynamic_cast<T*>(slave),e_opt);
70  Search::EngineBase<T>* eb = &engine;
71  Search::Engine* ee = eb->e;
72  eb->e = NULL;
73  e = new Search::Meta::RBS(master,rs,ee,m_opt);
74  }
75 
76 
77  template<template<class> class E, class T>
78  forceinline T*
79  rbs(T* s, const Search::Options& o) {
80  RBS<E,T> r(s,o);
81  return r.next();
82  }
83 
84 }
85 
86 // STATISTICS: search-meta
Search engine implementation interface
Definition: search.hh:601
Meta-engine performing restart-based search.
Definition: search.hh:631
Engine for restart-based search.
Definition: rbs.hh:80
Space * clone(bool share=true, CloneStatistics &stat=unused_clone) const
Clone space.
Definition: core.hpp:2854
Search engine options
Definition: search.hh:449
unsigned long int fail
Number of failed nodes in search tree.
Definition: search.hh:139
Current restart information during search.
Definition: core.hpp:1265
Computation spaces.
Definition: core.hpp:1362
virtual T * next(void)
Return next solution (NULL, if none exists or search has been stopped)
Definition: engine-base.hpp:50
Cutoff * cutoff
Cutoff for restart-based search.
Definition: search.hh:464
NNF * r
Right subtree.
Definition: bool-expr.cpp:246
Base-class for search engines.
Definition: search.hh:639
Engine * e
The actual search engine.
Definition: search.hh:643
bool clone
Whether engines create a clone when being initialized.
Definition: search.hh:452
virtual bool slave(const CRI &cri)
Slave configuration function for restart meta search engine.
Definition: core.cpp:658
Stop-object for restart engine
Definition: rbs.hh:48
Options expand(void) const
Expand with real number of threads.
Definition: options.cpp:47
Exception: Uninitialized cutoff for restart-based search
Definition: search.hh:120
#define forceinline
Definition: config.hpp:170
static NoGoods eng
Empty no-goods.
Definition: core.hpp:1258
RBS(T *s, const Search::Options &o)
Initialize engine for space s and options o.
Definition: rbs.hpp:47
Stop * stop
Stop object for stopping search.
Definition: search.hh:462
Gecode toplevel namespace
Space is failed
Definition: core.hpp:1301
T * rbs(T *s, const Search::Options &o)
Perform restart-based search.
Definition: rbs.hpp:79