Generated on Tue Jan 26 2021 00:00:00 for Gecode by doxygen 1.9.1
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 
39 namespace 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  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  bool mayMoveDownwards(void);
99  void processCurrentNode(void);
101  };
102 
104  class UnhideAllCursor : public NodeCursor<VisualNode> {
105  public:
107  UnhideAllCursor(VisualNode* theNode,
110 
111  void processCurrentNode(void);
114  };
115 
117  class UnstopAllCursor : public NodeCursor<VisualNode> {
118  public:
120  UnstopAllCursor(VisualNode* theNode,
123 
124  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  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;
166  int failed;
168  int solved;
170  int choice;
172  int open;
173 
175  StatCursor(VisualNode* theNode,
177 
179 
180  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  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::@602::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
BranchLabelCursor(VisualNode *theNode, BestNode *curBest, int c_d, int a_d, bool clear, VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:256
A cursor that frees all memory.
Definition: nodecursor.hh:215
void processCurrentNode(void)
Dispose node.
Definition: nodecursor.hpp:292
DisposeCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:287
A cursor that marks failed subtrees as hidden.
Definition: nodecursor.hh:86
void processCurrentNode(void)
Process node.
Definition: nodecursor.hpp:130
HideFailedCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na, bool onlyDirtyNodes)
Constructor.
Definition: nodecursor.hpp:124
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
NextSolCursor(VisualNode *theNode, bool backwards, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:170
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
NodeCursor(Node *theNode, const typename Node::NodeAllocator &na)
Construct cursor, initially set to theNode.
Definition: nodecursor.hpp:38
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
StatCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:225
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
UnhideAllCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:142
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
UnstopAllCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:156
Node class that supports visual layout
Definition: visualnode.hh:125
const unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance)
Definition: search.hh:115
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
Definition: search.hh:113