Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.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.org>
5 *
6 * Copyright:
7 * Christian Schulte, 2003
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#ifndef __GECODE_SEARCH_SEQ_PATH_HH__
35#define __GECODE_SEARCH_SEQ_PATH_HH__
36
37#include <algorithm>
38
39#include <gecode/search.hh>
43
44namespace Gecode { namespace Search { namespace Seq {
45
59 template<class Tracer>
61 friend class Search::NoGoodsProp;
62 public:
64 typedef typename Tracer::ID ID;
66 class Edge {
67 protected:
71 unsigned int _alt;
76 public:
78 Edge(void);
80 Edge(Space* s, Space* c, unsigned int nid);
81
83 Space* space(void) const;
85 void space(Space* s);
86
88 const Choice* choice(void) const;
89
91 unsigned int alt(void) const;
93 unsigned int truealt(void) const;
95 bool leftmost(void) const;
97 bool rightmost(void) const;
99 void next(void);
101 bool lao(void) const;
102
104 unsigned int nid(void) const;
105
107 void dispose(void);
108 };
109 protected:
113 unsigned int _ngdl;
114 public:
116 Path(unsigned int l);
118 unsigned int ngdl(void) const;
120 void ngdl(unsigned int l);
122 const Choice* push(Worker& stat, Space* s, Space* c, unsigned int nid);
124 void next(void);
126 Edge& top(void) const;
128 bool empty(void) const;
130 int lc(void) const;
132 void unwind(int l, Tracer& t);
134 void commit(Space* s, int i) const;
136 Space* recompute(unsigned int& d, unsigned int a_d, Worker& s,
137 Tracer& t);
139 Space* recompute(unsigned int& d, unsigned int a_d, Worker& s,
140 const Space& best, int& mark,
141 Tracer& t);
143 int entries(void) const;
145 void reset(void);
147 virtual void post(Space& home) const;
148 };
149
150}}}
151
153
154#endif
155
156// STATISTICS: search-seq
Choice for performing commit
Definition core.hpp:1414
NoGoods(void)
Initialize.
Definition core.hpp:3056
No-good propagator.
Definition nogoods.hh:65
Search tree edge for recomputation
Definition path.hh:66
Space * space(void) const
Return space for edge.
Definition path.hpp:51
Space * _space
Space corresponding to this edge (might be NULL)
Definition path.hh:69
unsigned int alt(void) const
Return number for alternatives.
Definition path.hpp:62
Edge(void)
Default constructor.
Definition path.hpp:42
bool rightmost(void) const
Test whether current alternative is rightmost.
Definition path.hpp:77
void next(void)
Move to next alternative.
Definition path.hpp:87
bool leftmost(void) const
Test whether current alternative is leftmost.
Definition path.hpp:72
bool lao(void) const
Test whether current alternative was LAO.
Definition path.hpp:82
void dispose(void)
Free memory for edge.
Definition path.hpp:105
unsigned int truealt(void) const
Return true number for alternatives (excluding lao optimization)
Definition path.hpp:67
ID _nid
Node identifier.
Definition path.hh:75
unsigned int nid(void) const
Return node identifier.
Definition path.hpp:99
const Choice * _choice
Choice.
Definition path.hh:73
const Choice * choice(void) const
Return choice.
Definition path.hpp:93
unsigned int _alt
Current alternative.
Definition path.hh:71
unsigned int _ngdl
Depth limit for no-good generation.
Definition path.hh:113
void unwind(int l, Tracer &t)
Unwind the stack up to position l (after failure)
Definition path.hpp:196
Tracer::ID ID
Node identity type.
Definition path.hh:64
bool empty(void) const
Test whether path is empty.
Definition path.hpp:168
int entries(void) const
Return number of entries on stack.
Definition path.hpp:190
int lc(void) const
Return position on stack of last copy.
Definition path.hpp:181
void next(void)
Generate path for next node.
Definition path.hpp:149
virtual void post(Space &home) const
Post no-goods.
Definition path.hpp:385
void commit(Space *s, int i) const
Commit space s as described by stack entry at position i.
Definition path.hpp:174
unsigned int ngdl(void) const
Return no-good depth limit.
Definition path.hpp:124
Support::DynamicStack< Edge, Heap > ds
Stack to store edge information.
Definition path.hh:111
Path(unsigned int l)
Initialize with no-good depth limit l.
Definition path.hpp:119
Edge & top(void) const
Provide access to topmost edge.
Definition path.hpp:161
void reset(void)
Reset stack.
Definition path.hpp:218
const Choice * push(Worker &stat, Space *s, Space *c, unsigned int nid)
Push space c (a clone of s or NULL)
Definition path.hpp:136
Space * recompute(unsigned int &d, unsigned int a_d, Worker &s, Tracer &t)
Recompute space according to path.
Definition path.hpp:225
Search worker statistics
Definition worker.hh:44
Computation spaces.
Definition core.hpp:1744
Stack with arbitrary number of elements.
Search engines
Gecode toplevel namespace
#define GECODE_VTABLE_EXPORT
Definition support.hh:72