Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
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.
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.
BranchLabelCursor(VisualNode *theNode, BestNode *curBest, int c_d, int a_d, bool clear, VisualNode::NodeAllocator &na)
Constructor.
A cursor that frees all memory.
void processCurrentNode(void)
Dispose node.
DisposeCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
A cursor that marks failed subtrees as hidden.
Definition nodecursor.hh:86
void processCurrentNode(void)
Process node.
HideFailedCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na, bool onlyDirtyNodes)
Constructor.
bool mayMoveDownwards(void)
Test if the cursor may move to the first child node.
A cursor that finds the next solution.
void processCurrentNode(void)
Do nothing.
bool mayMoveUpwards(void)
Test if the cursor may move to the parent node.
NextSolCursor(VisualNode *theNode, bool backwards, const VisualNode::NodeAllocator &na)
Constructor.
void moveSidewards(void)
Move cursor to the first sibling.
bool mayMoveDownwards(void)
Test if cursor may move to the first child node.
bool mayMoveSidewards(void)
Test if cursor may move to the first sibling.
void moveDownwards(void)
Move cursor to the first child node.
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.
bool mayMoveUpwards(void)
Test if the cursor may move to the parent node.
NodeCursor(Node *theNode, const typename Node::NodeAllocator &na)
Construct cursor, initially set to theNode.
Node * node(void)
Return current node.
unsigned int alternative(void)
Return current alternative.
Node * startNode(void)
Return start node.
void moveSidewards(void)
Move cursor to the first sibling.
bool mayMoveSidewards(void)
Test if cursor may move to the first sibling.
void moveUpwards(void)
Move cursor to the parent node.
bool mayMoveDownwards(void)
Test if cursor may move to the first child node.
Base class for nodes of the search tree.
Definition node.hh:106
A cursor that collects statistics.
int choice
Number of choice nodes.
void moveDownwards(void)
Move cursor to the first child node.
int failed
Number of failed nodes.
StatCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
int depth
Depth of the search tree.
void processCurrentNode(void)
Collect statistics.
int open
Number of open nodes.
int solved
Number of solved nodes.
void moveUpwards(void)
Move cursor to the parent node.
A cursor that marks all nodes in the tree as not hidden.
UnhideAllCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
void processCurrentNode(void)
Process node.
A cursor that marks all nodes in the tree as not stopping.
void processCurrentNode(void)
Process node.
UnstopAllCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Node class that supports visual layout
Gecode toplevel namespace