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 unsigned long int restarts(void) const;
70 void restart(void);
72 void nogood(unsigned long int n);
76 void limit(const Statistics& s, unsigned long long int l);
78 void update(const Search::Statistics& s);
80 bool enginestopped(void) const;
82 Statistics metastatistics(void) const;
83 };
84
87 protected:
99 unsigned long int sslr;
105 bool best;
106 public:
108 RBS(Space* s, RestartStop* stop0, Engine* e0,
109 const Search::Statistics& stat, const Options& o, bool best);
111 virtual Space* next(void);
113 virtual Statistics statistics(void) const;
115 virtual bool stopped(void) const;
117 virtual void constrain(const Space& b);
119 virtual ~RBS(void);
120 };
121
122}}}
123
125
126#endif
127
128// STATISTICS: search-seq
Base class for cutoff generators for restart-based meta engine.
Definition search.hh:476
Search engine implementation interface
Definition search.hh:943
Search engine options
Definition search.hh:751
Engine for restart-based search.
Definition rbs.hh:86
RestartStop * stop
The stop control object.
Definition rbs.hh:97
bool best
Whether the engine performs best solution search.
Definition rbs.hh:105
Space * master
The master space to restart from.
Definition rbs.hh:91
virtual ~RBS(void)
Destructor.
bool restart
Whether a restart must be performed when next is called.
Definition rbs.hh:103
bool complete
Whether search for the next solution will be complete.
Definition rbs.hh:101
Engine * e
The actual engine.
Definition rbs.hh:89
Space * last
The last solution space (possibly nullptr).
Definition rbs.hh:93
unsigned long int sslr
How many solutions since the last restart.
Definition rbs.hh:99
RBS(Space *s, RestartStop *stop0, Engine *e0, const Search::Statistics &stat, const Options &o, bool best)
Constructor.
Definition rbs.hpp:97
virtual void constrain(const Space &b)
Constrain future solutions to be better than b.
Cutoff * co
The cutoff object.
Definition rbs.hh:95
virtual bool stopped(void) const
Check whether engine has been stopped.
virtual Space * next(void)
Return next solution (nullptr, if none exists or search has been stopped).
virtual Statistics statistics(void) const
Return statistics.
Stop-object for restart engine
Definition rbs.hh:48
unsigned long int restarts(void) const
Return current restart count.
Definition rbs.hpp:46
virtual bool stop(const Statistics &s, const Options &o)
Return true if meta engine must be stopped.
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
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
bool enginestopped(void) const
Return whether the engine has been stopped.
Definition rbs.hpp:84
Search engine statistics
Definition search.hh:151
Stop(void)
Default constructor.
Definition stop.hpp:45
Computation spaces.
Definition core.hpp:1775
A mutex for mutual exclausion among several threads.
Definition thread.hpp:78
SpaceStatus
Space status
Definition core.hpp:1714
Search engines
Gecode toplevel namespace
#define GECODE_SEARCH_EXPORT
Definition search.hh:71