/usr/include/gecode/gist/nodecursor.hh is in libgecode-dev 4.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Guido Tack <tack@gecode.org>
*
* Copyright:
* Guido Tack, 2006
*
* Last modified:
* $Date: 2013-05-06 09:02:17 +0200 (Mon, 06 May 2013) $ by $Author: tack $
* $Revision: 13613 $
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef GECODE_GIST_NODECURSOR_HH
#define GECODE_GIST_NODECURSOR_HH
#include <gecode/gist/visualnode.hh>
namespace Gecode { namespace Gist {
/// \brief A cursor that can be run over a tree
template<class Node>
class NodeCursor {
private:
/// The node where the iteration starts
Node* _startNode;
/// The current node
Node* _node;
/// The current alternative
unsigned int _alternative;
protected:
/// The node allocator
const typename Node::NodeAllocator& na;
/// Set current node to \a n
void node(Node* n);
/// Return start node
Node* startNode(void);
public:
/// Construct cursor, initially set to \a theNode
NodeCursor(Node* theNode, const typename Node::NodeAllocator& na);
/// Return current node
Node* node(void);
/// Return current alternative
unsigned int alternative(void);
/// Set current alternative
void alternative(unsigned int a);
/// \name Cursor interface
//@{
/// Test if the cursor may move to the parent node
bool mayMoveUpwards(void);
/// Move cursor to the parent node
void moveUpwards(void);
/// Test if cursor may move to the first child node
bool mayMoveDownwards(void);
/// Move cursor to the first child node
void moveDownwards(void);
/// Test if cursor may move to the first sibling
bool mayMoveSidewards(void);
/// Move cursor to the first sibling
void moveSidewards(void);
//@}
};
/// \brief A cursor that marks failed subtrees as hidden
class HideFailedCursor : public NodeCursor<VisualNode> {
private:
bool onlyDirty;
public:
/// Constructor
HideFailedCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na,
bool onlyDirtyNodes);
/// \name Cursor interface
//@{
/// Test if the cursor may move to the first child node
bool mayMoveDownwards(void);
/// Process node
void processCurrentNode(void);
//@}
};
/// \brief A cursor that marks all nodes in the tree as not hidden
class UnhideAllCursor : public NodeCursor<VisualNode> {
public:
/// Constructor
UnhideAllCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na);
/// \name Cursor interface
//@{
/// Process node
void processCurrentNode(void);
//@}
};
/// \brief A cursor that marks all nodes in the tree as not stopping
class UnstopAllCursor : public NodeCursor<VisualNode> {
public:
/// Constructor
UnstopAllCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na);
/// \name Cursor interface
//@{
/// Process node
void processCurrentNode(void);
//@}
};
/// \brief A cursor that finds the next solution
class NextSolCursor : public NodeCursor<VisualNode> {
private:
/// Whether to search backwards
bool back;
/// Whether the current node is not a solution
bool notOnSol(void);
public:
/// Constructor
NextSolCursor(VisualNode* theNode, bool backwards,
const VisualNode::NodeAllocator& na);
/// \name Cursor interface
//@{
/// Do nothing
void processCurrentNode(void);
/// Test if the cursor may move to the parent node
bool mayMoveUpwards(void);
/// Test if cursor may move to the first child node
bool mayMoveDownwards(void);
/// Move cursor to the first child node
void moveDownwards(void);
/// Test if cursor may move to the first sibling
bool mayMoveSidewards(void);
/// Move cursor to the first sibling
void moveSidewards(void);
//@}
};
/// \brief A cursor that collects statistics
class StatCursor : public NodeCursor<VisualNode> {
private:
/// Current depth
int curDepth;
public:
/// Depth of the search tree
int depth;
/// Number of failed nodes
int failed;
/// Number of solved nodes
int solved;
/// Number of choice nodes
int choice;
/// Number of open nodes
int open;
/// Constructor
StatCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na);
/// \name Cursor interface
//@{
/// Collect statistics
void processCurrentNode(void);
/// Move cursor to the first child node
void moveDownwards(void);
/// Move cursor to the parent node
void moveUpwards(void);
//@}
};
/// \brief A cursor that labels branches
class BranchLabelCursor : public NodeCursor<VisualNode> {
private:
/// The node allocator
VisualNode::NodeAllocator& _na;
/// Current best solution
BestNode* _curBest;
/// Recomputation distance
int _c_d;
/// Adaptive rcomputation distance
int _a_d;
/// Whether to clear labels
bool _clear;
public:
/// Constructor
BranchLabelCursor(VisualNode* theNode, BestNode* curBest,
int c_d, int a_d, bool clear,
VisualNode::NodeAllocator& na);
/// \name Cursor interface
//@{
void processCurrentNode(void);
//@}
};
/// \brief A cursor that frees all memory
class DisposeCursor : public NodeCursor<VisualNode> {
public:
/// Constructor
DisposeCursor(VisualNode* theNode,
const VisualNode::NodeAllocator& na);
/// \name Cursor interface
//@{
/// Dispose node
void processCurrentNode(void);
//@}
};
}}
#include <gecode/gist/nodecursor.hpp>
#endif
// STATISTICS: gist-any
|