Generated on for Gecode by doxygen 1.17.0
rbs.hh
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Guido Tack <tack@gecode.dev>
5 *
6 * Contributing authors:
7 * Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
8 *
9 * Copyright:
10 * Guido Tack, 2012
11 * Mikael Zayenz Lagerkvist, 2026
12 *
13 * This file is part of Gecode, the generic constraint
14 * development environment:
15 * http://www.gecode.dev
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_RBS_HH
39#define GECODE_SEARCH_SEQ_RBS_HH
40
41#include <gecode/search.hh>
42
43namespace Gecode { namespace Search { namespace Seq {
44
45 class RBS;
46
49 template<class,template<class>class> friend class ::Gecode::RBS;
50 friend class ::Gecode::Search::Seq::RBS;
51 private:
53 mutable Support::Mutex m;
55 unsigned long long int l;
57 Stop* m_stop;
59 bool e_stopped;
61 Statistics m_stat;
62 public:
64 RestartStop(Stop* s);
66 virtual bool stop(const Statistics& s, const Options& o);
68 bool meta_stop(const Statistics& s, const Options& o);
70 unsigned long int restarts(void) const;
72 void restart(void);
74 void nogood(unsigned long int n);
78 void limit(const Statistics& s, unsigned long long int l);
80 void update(const Search::Statistics& s);
82 bool enginestopped(void) const;
84 Statistics metastatistics(void) const;
85 };
86
89 protected:
103 unsigned long int sslr;
111 bool best;
115 NoGoods& master_nogoods(void);
116 public:
124 RBS(Space* s, RestartStop* stop0, Engine* e0,
125 const Search::Statistics& stat, const Options& o, bool best,
126 bool complete);
128 virtual Space* next(void);
130 virtual Statistics statistics(void) const;
132 virtual bool stopped(void) const;
134 virtual void constrain(const Space& b);
136 virtual ~RBS(void);
137 };
138
139}}}
140
142
143#endif
144
145// STATISTICS: search-seq
No-goods recorded from restarts.
Definition core.hpp:1606
Base class for cutoff generators for restart-based meta engine.
Definition search.hh:480
Engine(void)
Construct a meta engine without worker control.
Definition engine.cpp:39
Search engine options
Definition search.hh:848
Engine for restart-based search.
Definition rbs.hh:88
RestartStop * stop
The stop control object.
Definition rbs.hh:99
virtual Space * next(void)
Return next solution (nullptr, if none exists or search has been stopped).
Definition rbs.cpp:80
bool best
Whether the engine performs best solution search.
Definition rbs.hh:111
Space * master
The master space to restart from.
Definition rbs.hh:93
bool restart
Whether a restart must be performed when next is called.
Definition rbs.hh:109
bool complete
Whether search for the next solution will be complete.
Definition rbs.hh:105
RBS(Space *s, RestartStop *stop0, Engine *e0, const Search::Statistics &stat, const Options &o, bool best, bool complete)
Constructor.
Definition rbs.hpp:97
Engine * e
The actual engine.
Definition rbs.hh:91
NoGoods & master_nogoods(void)
Return the no-goods of the last slave search, valid in the master.
Definition rbs.cpp:68
virtual bool stopped(void) const
Check whether engine has been stopped.
Definition rbs.cpp:185
virtual void constrain(const Space &b)
Constrain future solutions to be better than b.
Definition rbs.cpp:166
Space * last
The last solution space (possibly nullptr).
Definition rbs.hh:95
Options m_opt
The options for the stop object of the meta engine.
Definition rbs.hh:101
unsigned long int sslr
How many solutions since the last restart.
Definition rbs.hh:103
bool m_stopped
Whether the stop object for the meta engine stopped a restart.
Definition rbs.hh:113
Cutoff * co
The cutoff object.
Definition rbs.hh:97
bool nogoods_valid
Whether the no-goods of the current slave search hold in the master.
Definition rbs.hh:107
virtual Statistics statistics(void) const
Return statistics.
Definition rbs.cpp:161
Stop-object for restart engine
Definition rbs.hh:48
unsigned long int restarts(void) const
Return current restart count.
Definition rbs.hpp:46
Statistics metastatistics(void) const
Return statistics for the meta engine.
Definition rbs.hpp:90
void limit(const Statistics &s, unsigned long long int l)
Set current limit for the engine to l fails.
Definition rbs.hpp:70
void nogood(unsigned long int n)
Add no-goods to meta statistics.
Definition rbs.hpp:58
void restart(void)
Increment current restart count.
Definition rbs.hpp:52
RestartStop(Stop *s)
Stop the meta engine if indicated by the stop object s.
Definition rbs.hpp:42
bool meta_stop(const Statistics &s, const Options &o)
Return true if the stop object for the meta engine says so.
Definition rbs.cpp:62
SpaceStatus status(Space *s)
Test master status with meta statistics.
Definition rbs.hpp:64
void update(const Search::Statistics &s)
Update statistics.
Definition rbs.hpp:78
virtual bool stop(const Statistics &s, const Options &o)
Return true if meta engine must be stopped.
Definition rbs.cpp:44
bool enginestopped(void) const
Return whether the engine has been stopped.
Definition rbs.hpp:84
Search engine statistics
Definition search.hh:155
Stop(void)
Default constructor.
Definition stop.hpp:45
Computation spaces.
Definition core.hpp:1787
A mutex for mutual exclausion among several threads.
Definition thread.hpp:78
SpaceStatus
Space status
Definition core.hpp:1726
Search engines
Gecode toplevel namespace
#define GECODE_SEARCH_EXPORT
Definition search.hh:75