Generated on Sat Feb 7 2015 02:01:18 for Gecode by doxygen 1.8.9.1
node.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2003
8  *
9  * Last modified:
10  * $Date: 2011-09-08 14:34:40 +0200 (Thu, 08 Sep 2011) $ by $Author: schulte $
11  * $Revision: 12395 $
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 namespace Gecode { namespace Int { namespace ViewValGraph {
39 
40  /*
41  * Nodes
42  *
43  */
44 
45  template<class View>
47  Node<View>::Node(void) : min(0) {
48  // Must be initialized such that the node is considered unvisited initially
49  }
50  template<class View>
52  Node<View>::edge_fst(void) const {
53  return static_cast<Edge<View>*>(BiLink::next());
54  }
55  template<class View>
57  Node<View>::edge_lst(void) const {
58  return static_cast<Edge<View>*>(static_cast<BiLink*>(const_cast<Node<View>*>(this)));
59  }
60  template<class View>
61  forceinline void
62  Node<View>::operator delete(void*, size_t) {}
63  template<class View>
64  forceinline void
65  Node<View>::operator delete(void*,Space&) {}
66  template<class View>
67  forceinline void*
68  Node<View>::operator new(size_t s, Space& home) {
69  return home.ralloc(s);
70  }
71 
72  /*
73  * Value nodes
74  *
75  */
76 
77 
78  template<class View>
81  : _val(v), _matching(NULL) {}
82  template<class View>
85  : _val(v), _matching(NULL), _next_val(n) {}
86  template<class View>
87  forceinline int
88  ValNode<View>::val(void) const {
89  return _val;
90  }
91  template<class View>
92  forceinline void
94  _matching = m;
95  }
96  template<class View>
99  return _matching;
100  }
101  template<class View>
104  return &_next_val;
105  }
106  template<class View>
109  return _next_val;
110  }
111  template<class View>
112  forceinline void
114  _next_val = n;
115  }
116 
117 
118 
119  /*
120  * View nodes
121  *
122  */
123 
124  template<class View>
127  : _view(View(NULL)) {}
128  template<class View>
131  : _size(x.size()), _view(x) {}
132  template<class View>
135  return _val_edges;
136  }
137  template<class View>
140  return &_val_edges;
141  }
142  template<class View>
143  forceinline bool
144  ViewNode<View>::fake(void) const {
145  return _view.varimp() == NULL;
146  }
147  template<class View>
148  forceinline View
149  ViewNode<View>::view(void) const {
150  return _view;
151  }
152  template<class View>
153  forceinline bool
155  return _size != _view.size();
156  }
157  template<class View>
158  forceinline void
160  _size = _view.size();
161  }
162  template<class View>
163  forceinline bool
166  }
167 
168 }}}
169 
170 // STATISTICS: int-prop
171 
Edge< View > * edge_fst(void) const
Return first edge (organized by bi-links)
Definition: node.hpp:52
Edge< View > * val_edges(void) const
Return first edge of all value edges.
Definition: node.hpp:134
void update(void)
Update size of view after change.
Definition: node.hpp:159
Edges in view-value graph.
ValNode< View > * next_val(void) const
Return next value node.
Definition: node.hpp:108
Computation spaces.
Definition: core.hpp:1362
ValNode< View > ** next_val_ref(void)
Return pointer to next value node fields.
Definition: node.hpp:103
int val(void) const
Return value of node.
Definition: node.hpp:88
View view(void) const
Return view.
Definition: node.hpp:149
ViewNode(void)
Initialize node for a non-view.
Definition: node.hpp:126
int n
Number of negative literals for node type.
Definition: bool-expr.cpp:238
unsigned int size(I &i)
Size of all ranges of range iterator i.
Edge< View > * edge_lst(void) const
Return last edge (organized by bi-links)
Definition: node.hpp:57
bool fake(void) const
Test whether node has a fake view.
Definition: node.hpp:144
ValNode(int v)
Initialize with value v.
Definition: node.hpp:80
const int v[7]
Definition: distinct.cpp:207
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition: arithmetic.cpp:75
Edge< View > * matching(void) const
Return matching edge (NULL if unmatched)
Definition: node.hpp:98
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Edge< View > ** val_edges_ref(void)
Return pointer to first edge fields of all value edges.
Definition: node.hpp:139
Value nodes in view-value graph.
bool changed(void) const
Return whether view has changed its size.
Definition: node.hpp:154
#define forceinline
Definition: config.hpp:132
Gecode toplevel namespace
Node(void)
Initialize.
Definition: node.hpp:47
Base-class for nodes (both view and value nodes)
bool matched(void) const
Whether the node is matched.
Definition: node.hpp:164