Generated on Thu Jul 21 2022 00:00:00 for Gecode by doxygen 1.9.5
nodecursor.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.org>
5 *
6 * Copyright:
7 * Guido Tack, 2006
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_GIST_NODECURSOR_HH
35#define GECODE_GIST_NODECURSOR_HH
36
38
39namespace Gecode { namespace Gist {
40
42 template<class Node>
43 class NodeCursor {
44 private:
46 Node* _startNode;
48 Node* _node;
50 unsigned int _alternative;
51 protected:
53 const typename Node::NodeAllocator& na;
55 void node(Node* n);
57 Node* startNode(void);
58 public:
60 NodeCursor(Node* theNode, const typename Node::NodeAllocator& na);
62 Node* node(void);
64 unsigned int alternative(void);
66 void alternative(unsigned int a);
67
69
70
71 bool mayMoveUpwards(void);
73 void moveUpwards(void);
75 bool mayMoveDownwards(void);
77 void moveDownwards(void);
79 bool mayMoveSidewards(void);
81 void moveSidewards(void);
83 };
84
86 class HideFailedCursor : public NodeCursor<VisualNode> {
87 private:
88 bool onlyDirty;
89 public:
93 bool onlyDirtyNodes);
95
96
97 bool mayMoveDownwards(void);
99 void processCurrentNode(void);
101 };
102
104 class UnhideAllCursor : public NodeCursor<VisualNode> {
105 public:
110
111
112 void processCurrentNode(void);
114 };
115
117 class UnstopAllCursor : public NodeCursor<VisualNode> {
118 public:
123
124
125 void processCurrentNode(void);
127 };
128
130 class NextSolCursor : public NodeCursor<VisualNode> {
131 private:
133 bool back;
135 bool notOnSol(void);
136 public:
138 NextSolCursor(VisualNode* theNode, bool backwards,
141
142
143 void processCurrentNode(void);
145 bool mayMoveUpwards(void);
147 bool mayMoveDownwards(void);
149 void moveDownwards(void);
151 bool mayMoveSidewards(void);
153 void moveSidewards(void);
155 };
156
158 class StatCursor : public NodeCursor<VisualNode> {
159 private:
161 int curDepth;
162 public:
164 int depth;
172 int open;
173
175 StatCursor(VisualNode* theNode,
177
179
180
181 void processCurrentNode(void);
183 void moveDownwards(void);
185 void moveUpwards(void);
187
188 };
189
191 class BranchLabelCursor : public NodeCursor<VisualNode> {
192 private:
196 BestNode* _curBest;
198 int _c_d;
200 int _a_d;
202 bool _clear;
203 public:
205 BranchLabelCursor(VisualNode* theNode, BestNode* curBest,
206 int c_d, int a_d, bool clear,
209
210 void processCurrentNode(void);
212 };
213
215 class DisposeCursor : public NodeCursor<VisualNode> {
216 public:
218 DisposeCursor(VisualNode* theNode,
220
222
223
224 void processCurrentNode(void);
226
227 };
228
229}}
230
232
233#endif
234
235// STATISTICS: gist-any
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:234
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Static reference to the currently best space.
Definition: spacenode.hh:80
A cursor that labels branches.
Definition: nodecursor.hh:191
A cursor that frees all memory.
Definition: nodecursor.hh:215
void processCurrentNode(void)
Dispose node.
Definition: nodecursor.hpp:292
A cursor that marks failed subtrees as hidden.
Definition: nodecursor.hh:86
void processCurrentNode(void)
Process node.
Definition: nodecursor.hpp:130
bool mayMoveDownwards(void)
Test if the cursor may move to the first child node.
Definition: nodecursor.hpp:115
A cursor that finds the next solution.
Definition: nodecursor.hh:130
void processCurrentNode(void)
Do nothing.
Definition: nodecursor.hpp:175
bool mayMoveUpwards(void)
Test if the cursor may move to the parent node.
Definition: nodecursor.hpp:183
void moveSidewards(void)
Move cursor to the first sibling.
Definition: nodecursor.hpp:215
bool mayMoveDownwards(void)
Test if cursor may move to the first child node.
Definition: nodecursor.hpp:188
bool mayMoveSidewards(void)
Test if cursor may move to the first sibling.
Definition: nodecursor.hpp:204
void moveDownwards(void)
Move cursor to the first child node.
Definition: nodecursor.hpp:195
A cursor that can be run over a tree.
Definition: nodecursor.hh:43
const Node::NodeAllocator & na
The node allocator.
Definition: nodecursor.hh:53
void moveDownwards(void)
Move cursor to the first child node.
Definition: nodecursor.hpp:95
bool mayMoveUpwards(void)
Test if the cursor may move to the parent node.
Definition: nodecursor.hpp:66
Node * node(void)
Return current node.
Definition: nodecursor.hpp:46
unsigned int alternative(void)
Return current alternative.
Definition: nodecursor.hpp:50
Node * startNode(void)
Return start node.
Definition: nodecursor.hpp:58
void moveSidewards(void)
Move cursor to the first sibling.
Definition: nodecursor.hpp:109
bool mayMoveSidewards(void)
Test if cursor may move to the first sibling.
Definition: nodecursor.hpp:102
void moveUpwards(void)
Move cursor to the parent node.
Definition: nodecursor.hpp:72
bool mayMoveDownwards(void)
Test if cursor may move to the first child node.
Definition: nodecursor.hpp:89
Base class for nodes of the search tree.
Definition: node.hh:106
A cursor that collects statistics.
Definition: nodecursor.hh:158
int choice
Number of choice nodes.
Definition: nodecursor.hh:170
void moveDownwards(void)
Move cursor to the first child node.
Definition: nodecursor.hpp:243
int failed
Number of failed nodes.
Definition: nodecursor.hh:166
int depth
Depth of the search tree.
Definition: nodecursor.hh:164
void processCurrentNode(void)
Collect statistics.
Definition: nodecursor.hpp:231
int open
Number of open nodes.
Definition: nodecursor.hh:172
int solved
Number of solved nodes.
Definition: nodecursor.hh:168
void moveUpwards(void)
Move cursor to the parent node.
Definition: nodecursor.hpp:250
A cursor that marks all nodes in the tree as not hidden.
Definition: nodecursor.hh:104
void processCurrentNode(void)
Process node.
Definition: nodecursor.hpp:147
A cursor that marks all nodes in the tree as not stopping.
Definition: nodecursor.hh:117
void processCurrentNode(void)
Process node.
Definition: nodecursor.hpp:161
Node class that supports visual layout
Definition: visualnode.hh:125
Gecode toplevel namespace