Generated on for Gecode by doxygen 1.17.0
path.hh
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.dev>
5 *
6 * Contributing authors:
7 * Mikael Zayenz Lagerkvist <lagerkvist@gecode.dev>
8 *
9 * Copyright:
10 * Christian Schulte, 2003
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_PAR_PATH_HH
39#define GECODE_SEARCH_PAR_PATH_HH
40
41#include <algorithm>
42
43#include <gecode/search.hh>
47
48namespace Gecode { namespace Search { namespace Par {
49
63 template<class Tracer>
64 class Path : public NoGoods {
65 friend class Search::NoGoodsProp;
66 public:
68 typedef typename Tracer::ID ID;
70 class Edge {
71 protected:
75 unsigned int _alt;
77 unsigned int _alt_max;
82 public:
84 Edge(void);
86 Edge(Space* s, Space* c, unsigned int nid);
87
89 Space* space(void) const;
91 void space(Space* s);
92
94 const Choice* choice(void) const;
95
97 unsigned int alt(void) const;
99 unsigned int truealt(void) const;
101 bool rightmost(void) const;
103 bool lao(void) const;
105 bool work(void) const;
107 void next(void);
109 unsigned int steal(void);
110
112 unsigned int nid(void) const;
113
115 void dispose(void);
116 };
117 protected:
121 unsigned int _ngdl;
123 unsigned int n_work;
124 public:
126 Path(unsigned int l);
128 unsigned int ngdl(void) const;
130 void ngdl(unsigned int l);
132 const Choice* push(Worker& stat, Space* s, Space* c, unsigned int nid);
134 void next(void);
136 Edge& top(void) const;
138 bool empty(void) const;
140 int lc(void) const;
142 void unwind(int l, Tracer& t);
144 void commit(Space* s, int i) const;
146 Space* recompute(unsigned int& d, unsigned int a_d, Worker& s,
147 Tracer& t);
149 Space* recompute(unsigned int& d, unsigned int a_d, Worker& s,
150 const Space* best, int& mark,
151 Tracer& t);
153 int entries(void) const;
155 void reset(unsigned int l);
157 bool steal(void) const;
159 Space* steal(Worker& stat, unsigned long int& d,
160 Tracer& myt, Tracer& ot);
162 void virtual post(Space& home) const;
163 };
164
165}}}
166
168
169#endif
170
171// STATISTICS: search-par
Choice for performing commit
Definition core.hpp:1423
NoGoods(void)
Initialize.
Definition core.hpp:3121
No-good propagator.
Definition nogoods.hh:65
Search tree edge for recomputation
Definition path.hh:70
bool work(void) const
Test whether there is an alternative that can be stolen.
Definition path.hpp:95
void dispose(void)
Free memory for edge.
Definition path.hpp:118
Edge(void)
Default constructor.
Definition path.hpp:46
unsigned int truealt(void) const
Return true number for alternatives (excluding lao optimization).
Definition path.hpp:80
bool lao(void) const
Test whether current alternative was LAO.
Definition path.hpp:90
unsigned int nid(void) const
Return node identifier.
Definition path.hpp:74
const Choice * _choice
Choice.
Definition path.hh:79
unsigned int _alt_max
Number of alternatives left.
Definition path.hh:77
const Choice * choice(void) const
Return choice.
Definition path.hpp:112
Space * space(void) const
Return space for edge.
Definition path.hpp:57
unsigned int alt(void) const
Return number for alternatives.
Definition path.hpp:68
ID _nid
Node identifier.
Definition path.hh:81
unsigned int _alt
Current alternative.
Definition path.hh:75
bool rightmost(void) const
Test whether current alternative is rightmost.
Definition path.hpp:85
unsigned int steal(void)
Steal rightmost alternative and return its number.
Definition path.hpp:105
void next(void)
Move to next alternative.
Definition path.hpp:100
Space * _space
Space corresponding to this edge (might be nullptr).
Definition path.hh:73
void reset(unsigned int l)
Reset stack and set no-good depth limit to l.
Definition path.hpp:241
unsigned int ngdl(void) const
Return no-good depth limit.
Definition path.hpp:137
void unwind(int l, Tracer &t)
Unwind the stack up to position l (after failure).
Definition path.hpp:214
Tracer::ID ID
Identity type.
Definition path.hh:68
unsigned int n_work
Number of edges that have work for stealing.
Definition path.hh:123
const Choice * push(Worker &stat, Space *s, Space *c, unsigned int nid)
Push space c (a clone of s or nullptr).
Definition path.hpp:149
Path(unsigned int l)
Initialize with no-good depth limit l.
Definition path.hpp:132
Support::DynamicStack< Edge, Heap > ds
Stack to store edge information.
Definition path.hh:119
void commit(Space *s, int i) const
Commit space s as described by stack entry at position i.
Definition path.hpp:192
void next(void)
Generate path for next node.
Definition path.hpp:164
bool empty(void) const
Test whether path is empty.
Definition path.hpp:186
virtual void post(Space &home) const
Post no-goods.
Definition path.hpp:453
unsigned int _ngdl
Depth limit for no-good generation.
Definition path.hh:121
int lc(void) const
Return position on stack of last copy.
Definition path.hpp:199
int entries(void) const
Return number of entries on stack.
Definition path.hpp:208
Edge & top(void) const
Provide access to topmost edge.
Definition path.hpp:179
bool steal(void) const
Make a quick check whether stealing might be feasible.
Definition path.hpp:250
Space * recompute(unsigned int &d, unsigned int a_d, Worker &s, Tracer &t)
Recompute space according to path.
Definition path.hpp:293
Search worker statistics
Definition worker.hh:44
Computation spaces.
Definition core.hpp:1775
Stack with arbitrary number of elements.
Search engines
Gecode toplevel namespace