Generated on for Gecode by doxygen 1.17.0
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 * 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
39namespace Gecode { namespace Search { namespace Seq {
40
41 forceinline
43 : l(0U), m_stop(s), e_stopped(false) {}
44
45 forceinline unsigned long int
47 Support::Lock lock(m);
48 return m_stat.restart;
49 }
50
51 forceinline void
53 Support::Lock lock(m);
54 m_stat.restart++;
55 }
56
57 forceinline void
58 RestartStop::nogood(unsigned long int n) {
59 Support::Lock lock(m);
60 m_stat.nogood += n;
61 }
62
63 forceinline SpaceStatus
65 Support::Lock lock(m);
66 return s->status(m_stat);
67 }
68
69 forceinline void
70 RestartStop::limit(const Search::Statistics& s, unsigned long long int l0) {
71 Support::Lock lock(m);
72 l = l0;
73 m_stat += s;
74 e_stopped = false;
75 }
76
77 forceinline void
79 Support::Lock lock(m);
80 m_stat += s;
81 }
82
83 forceinline bool
85 Support::Lock lock(m);
86 return e_stopped;
87 }
88
89 forceinline Statistics
91 Support::Lock lock(m);
92 return m_stat;
93 }
94
95
96 forceinline
98 Engine* e0, const Search::Statistics& stat, const Options& opt,
99 bool best0)
100 : e(e0), master(s), last(nullptr), co(opt.cutoff), stop(stop0),
101 sslr(0),
102 complete(true), restart(false), best(best0) {
103 stop->limit(stat,(*co)());
104 }
105
106}}}
107
108// STATISTICS: search-seq
Search engine implementation interface
Definition search.hh:943
Search engine options
Definition search.hh:751
unsigned long long int limit(void) const
Return current limit.
Definition stop.hpp:160
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
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
Cutoff * co
The cutoff object.
Definition rbs.hh:95
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 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 lock as a scoped frontend for a mutex.
Definition thread.hpp:114
SpaceStatus status(StatusStatistics &stat)
Query space status.
SpaceStatus
Space status
Definition core.hpp:1714
Search engines
Gecode toplevel namespace