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_SEQ_PATH_HH
39#define GECODE_SEARCH_SEQ_PATH_HH
40
41#include <algorithm>
42
43#include <gecode/search.hh>
47
48namespace Gecode { namespace Search { namespace Seq {
49
63 template<class Tracer>
65 friend class Search::NoGoodsProp;
66 public:
68 typedef typename Tracer::ID ID;
70 class Edge {
71 protected:
75 unsigned int _alt;
80 public:
82 Edge(void);
84 Edge(Space* s, Space* c, unsigned int nid);
85
87 Space* space(void) const;
89 void space(Space* s);
90
92 const Choice* choice(void) const;
93
95 unsigned int alt(void) const;
97 unsigned int truealt(void) const;
99 bool leftmost(void) const;
101 bool rightmost(void) const;
103 void next(void);
105 bool lao(void) const;
106
108 unsigned int nid(void) const;
109
111 void dispose(void);
112 };
113 protected:
117 unsigned int _ngdl;
118 public:
120 Path(unsigned int l);
122 unsigned int ngdl(void) const;
124 void ngdl(unsigned int l);
126 const Choice* push(Worker& stat, Space* s, Space* c, unsigned int nid);
128 void next(void);
130 Edge& top(void) const;
132 bool empty(void) const;
134 int lc(void) const;
136 void unwind(int l, Tracer& t);
138 void commit(Space* s, int i) const;
140 Space* recompute(unsigned int& d, unsigned int a_d, Worker& s,
141 Tracer& t);
143 Space* recompute(unsigned int& d, unsigned int a_d, Worker& s,
144 const Space* best, int& mark,
145 Tracer& t);
147 int entries(void) const;
149 void reset(void);
151 virtual void post(Space& home) const;
152 };
153
154}}}
155
157
158#endif
159
160// STATISTICS: search-seq
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
Space * space(void) const
Return space for edge.
Definition path.hpp:55
Space * _space
Space corresponding to this edge (might be nullptr).
Definition path.hh:73
unsigned int alt(void) const
Return number for alternatives.
Definition path.hpp:66
Edge(void)
Default constructor.
Definition path.hpp:46
bool rightmost(void) const
Test whether current alternative is rightmost.
Definition path.hpp:81
void next(void)
Move to next alternative.
Definition path.hpp:91
bool leftmost(void) const
Test whether current alternative is leftmost.
Definition path.hpp:76
bool lao(void) const
Test whether current alternative was LAO.
Definition path.hpp:86
void dispose(void)
Free memory for edge.
Definition path.hpp:109
unsigned int truealt(void) const
Return true number for alternatives (excluding lao optimization).
Definition path.hpp:71
ID _nid
Node identifier.
Definition path.hh:79
unsigned int nid(void) const
Return node identifier.
Definition path.hpp:103
const Choice * _choice
Choice.
Definition path.hh:77
const Choice * choice(void) const
Return choice.
Definition path.hpp:97
unsigned int _alt
Current alternative.
Definition path.hh:75
unsigned int _ngdl
Depth limit for no-good generation.
Definition path.hh:117
void unwind(int l, Tracer &t)
Unwind the stack up to position l (after failure).
Definition path.hpp:200
Tracer::ID ID
Node identity type.
Definition path.hh:68
bool empty(void) const
Test whether path is empty.
Definition path.hpp:172
int entries(void) const
Return number of entries on stack.
Definition path.hpp:194
int lc(void) const
Return position on stack of last copy.
Definition path.hpp:185
void next(void)
Generate path for next node.
Definition path.hpp:153
virtual void post(Space &home) const
Post no-goods.
Definition path.hpp:389
void commit(Space *s, int i) const
Commit space s as described by stack entry at position i.
Definition path.hpp:178
unsigned int ngdl(void) const
Return no-good depth limit.
Definition path.hpp:128
Support::DynamicStack< Edge, Heap > ds
Stack to store edge information.
Definition path.hh:115
Path(unsigned int l)
Initialize with no-good depth limit l.
Definition path.hpp:123
Edge & top(void) const
Provide access to topmost edge.
Definition path.hpp:165
void reset(void)
Reset stack.
Definition path.hpp:222
const Choice * push(Worker &stat, Space *s, Space *c, unsigned int nid)
Push space c (a clone of s or nullptr).
Definition path.hpp:140
Space * recompute(unsigned int &d, unsigned int a_d, Worker &s, Tracer &t)
Recompute space according to path.
Definition path.hpp:229
Search worker statistics
Definition worker.hh:44
Computation spaces.
Definition core.hpp:1775
Stack with arbitrary number of elements.
Search engines
Gecode toplevel namespace
#define GECODE_VTABLE_EXPORT
Definition support.hh:76