Generated on Sat Feb 7 2015 02:01:18 for Gecode by doxygen 1.8.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  * Last modified:
10  * $Date: 2013-05-06 09:02:17 +0200 (Mon, 06 May 2013) $ by $Author: tack $
11  * $Revision: 13613 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
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_GIST_NODECURSOR_HH
39 #define GECODE_GIST_NODECURSOR_HH
40 
42 
43 namespace Gecode { namespace Gist {
44 
46  template<class Node>
47  class NodeCursor {
48  private:
50  Node* _startNode;
52  Node* _node;
54  unsigned int _alternative;
55  protected:
57  const typename Node::NodeAllocator& na;
59  void node(Node* n);
61  Node* startNode(void);
62  public:
64  NodeCursor(Node* theNode, const typename Node::NodeAllocator& na);
66  Node* node(void);
68  unsigned int alternative(void);
70  void alternative(unsigned int a);
71 
73 
74  bool mayMoveUpwards(void);
77  void moveUpwards(void);
79  bool mayMoveDownwards(void);
81  void moveDownwards(void);
83  bool mayMoveSidewards(void);
85  void moveSidewards(void);
87  };
88 
90  class HideFailedCursor : public NodeCursor<VisualNode> {
91  private:
92  bool onlyDirty;
93  public:
97  bool onlyDirtyNodes);
99 
100  bool mayMoveDownwards(void);
103  void processCurrentNode(void);
105  };
106 
108  class UnhideAllCursor : public NodeCursor<VisualNode> {
109  public:
111  UnhideAllCursor(VisualNode* theNode,
114 
115  void processCurrentNode(void);
118  };
119 
121  class UnstopAllCursor : public NodeCursor<VisualNode> {
122  public:
124  UnstopAllCursor(VisualNode* theNode,
127 
128  void processCurrentNode(void);
131  };
132 
134  class NextSolCursor : public NodeCursor<VisualNode> {
135  private:
137  bool back;
139  bool notOnSol(void);
140  public:
142  NextSolCursor(VisualNode* theNode, bool backwards,
145 
146  void processCurrentNode(void);
149  bool mayMoveUpwards(void);
151  bool mayMoveDownwards(void);
153  void moveDownwards(void);
155  bool mayMoveSidewards(void);
157  void moveSidewards(void);
159  };
160 
162  class StatCursor : public NodeCursor<VisualNode> {
163  private:
165  int curDepth;
166  public:
168  int depth;
170  int failed;
172  int solved;
174  int choice;
176  int open;
177 
179  StatCursor(VisualNode* theNode,
181 
183 
184  void processCurrentNode(void);
187  void moveDownwards(void);
189  void moveUpwards(void);
191 
192  };
193 
195  class BranchLabelCursor : public NodeCursor<VisualNode> {
196  private:
200  BestNode* _curBest;
202  int _c_d;
204  int _a_d;
206  bool _clear;
207  public:
209  BranchLabelCursor(VisualNode* theNode, BestNode* curBest,
210  int c_d, int a_d, bool clear,
213 
214  void processCurrentNode(void);
216  };
217 
219  class DisposeCursor : public NodeCursor<VisualNode> {
220  public:
222  DisposeCursor(VisualNode* theNode,
224 
226 
227  void processCurrentNode(void);
230 
231  };
232 
233 }}
234 
236 
237 #endif
238 
239 // STATISTICS: gist-any
bool mayMoveDownwards(void)
Test if cursor may move to the first child node.
Definition: nodecursor.hpp:93
bool mayMoveDownwards(void)
Test if the cursor may move to the first child node.
Definition: nodecursor.hpp:119
BranchLabelCursor(VisualNode *theNode, BestNode *curBest, int c_d, int a_d, bool clear, VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:260
Static reference to the currently best space.
Definition: spacenode.hh:84
void moveUpwards(void)
Move cursor to the parent node.
Definition: nodecursor.hpp:76
NodeAllocatorBase< VisualNode > NodeAllocator
Definition: node.hh:147
void moveDownwards(void)
Move cursor to the first child node.
Definition: nodecursor.hpp:99
int depth
Depth of the search tree.
Definition: nodecursor.hh:168
bool mayMoveSidewards(void)
Test if cursor may move to the first sibling.
Definition: nodecursor.hpp:106
void moveSidewards(void)
Move cursor to the first sibling.
Definition: nodecursor.hpp:219
Base class for nodes of the search tree.
Definition: node.hh:110
Node allocator.
Definition: node.hh:52
DisposeCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:291
A cursor that marks failed subtrees as hidden.
Definition: nodecursor.hh:90
void processCurrentNode(void)
Process node.
Definition: nodecursor.hpp:151
void processCurrentNode(void)
Process node.
Definition: nodecursor.hpp:134
A cursor that collects statistics.
Definition: nodecursor.hh:162
bool mayMoveUpwards(void)
Test if the cursor may move to the parent node.
Definition: nodecursor.hpp:70
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
HideFailedCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na, bool onlyDirtyNodes)
Constructor.
Definition: nodecursor.hpp:128
void moveDownwards(void)
Move cursor to the first child node.
Definition: nodecursor.hpp:247
const Node::NodeAllocator & na
The node allocator.
Definition: nodecursor.hh:57
void moveUpwards(void)
Move cursor to the parent node.
Definition: nodecursor.hpp:254
const unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
Definition: search.hh:99
void processCurrentNode(void)
Process node.
Definition: nodecursor.hpp:165
void moveDownwards(void)
Move cursor to the first child node.
Definition: nodecursor.hpp:199
void processCurrentNode(void)
Dispose node.
Definition: nodecursor.hpp:296
Node * startNode(void)
Return start node.
Definition: nodecursor.hpp:62
A cursor that frees all memory.
Definition: nodecursor.hh:219
StatCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:229
UnhideAllCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:146
void moveSidewards(void)
Move cursor to the first sibling.
Definition: nodecursor.hpp:113
A cursor that marks all nodes in the tree as not stopping.
Definition: nodecursor.hh:121
bool mayMoveDownwards(void)
Test if cursor may move to the first child node.
Definition: nodecursor.hpp:192
int open
Number of open nodes.
Definition: nodecursor.hh:176
A cursor that can be run over a tree.
Definition: nodecursor.hh:47
A cursor that marks all nodes in the tree as not hidden.
Definition: nodecursor.hh:108
Node class that supports visual layout
Definition: visualnode.hh:129
int choice
Number of choice nodes.
Definition: nodecursor.hh:174
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
Definition: search.hh:97
A cursor that finds the next solution.
Definition: nodecursor.hh:134
int failed
Number of failed nodes.
Definition: nodecursor.hh:170
bool mayMoveSidewards(void)
Test if cursor may move to the first sibling.
Definition: nodecursor.hpp:208
void processCurrentNode(void)
Do nothing.
Definition: nodecursor.hpp:179
Node * node(void)
Return current node.
Definition: nodecursor.hpp:50
UnstopAllCursor(VisualNode *theNode, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:160
NodeCursor(Node *theNode, const typename Node::NodeAllocator &na)
Construct cursor, initially set to theNode.
Definition: nodecursor.hpp:42
Gecode toplevel namespace
unsigned int alternative(void)
Return current alternative.
Definition: nodecursor.hpp:54
void processCurrentNode(void)
Collect statistics.
Definition: nodecursor.hpp:235
bool mayMoveUpwards(void)
Test if the cursor may move to the parent node.
Definition: nodecursor.hpp:187
A cursor that labels branches.
Definition: nodecursor.hh:195
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
int solved
Number of solved nodes.
Definition: nodecursor.hh:172
NextSolCursor(VisualNode *theNode, bool backwards, const VisualNode::NodeAllocator &na)
Constructor.
Definition: nodecursor.hpp:174