38 namespace Gecode {
namespace Int {
namespace LDSB {
41 template <
class T,
class A>
54 return home.ralloc(s);
68 : indices(home, 0, 0) {
72 int maximum = _indices[0];
73 int minimum = _indices[0];
74 for (
unsigned int i = 1 ;
i <
n ;
i++) {
75 if (_indices[
i] > maximum) maximum = _indices[
i];
76 if (_indices[
i] < minimum) minimum = _indices[
i];
78 indices.resize(home, maximum-minimum+1, minimum);
81 for (
unsigned int i = 0 ;
i <
n ;
i++) {
82 indices.set(_indices[
i]);
92 indices(home, other.indices) {}
98 indices.dispose(home);
102 template <
class View>
111 template <
class View>
123 template <
class View>
133 for (
unsigned int i = 1 ;
i <
n ;
i++) {
134 if (vs[
i] > maximum) maximum = vs[
i];
135 if (vs[
i] < minimum) minimum = vs[
i];
137 values.resize(home, maximum-minimum+1, minimum);
140 for (
unsigned int i = 0 ;
i <
n ;
i++) {
145 template <
class View>
150 template <
class View>
155 return sizeof(*this);
158 template <
class View>
166 template <
class View>
176 template <
class View>
180 return indices[sequence*seq_size +
position];
183 template <
class View>
186 unsigned int seqsize)
187 : n_indices(n), seq_size(seqsize), n_seqs(n/seqsize) {
188 indices = home.
alloc<
unsigned int>(n_indices);
189 unsigned int max_index = _indices[0];
190 for (
unsigned int i = 0 ;
i < n_indices ;
i++) {
191 indices[
i] = _indices[
i];
192 if (indices[
i] > max_index)
193 max_index = indices[
i];
196 lookup_size = max_index+1;
197 lookup = home.
alloc<
int>(lookup_size);
198 for (
unsigned int i = 0 ;
i < lookup_size ;
i++)
200 for (
unsigned int i = 0 ;
i < n_indices ;
i++) {
201 if (lookup[indices[
i]] == -1)
202 lookup[indices[
i]] =
i;
206 template <
class View>
210 : n_indices(s.n_indices), seq_size(s.seq_size), n_seqs(s.n_seqs),
211 lookup_size(s.lookup_size) {
213 indices = home.
alloc<
unsigned int>(n_indices);
214 memcpy(indices, s.
indices, n_indices *
sizeof(
int));
215 lookup = home.
alloc<
int>(lookup_size);
216 memcpy(lookup, s.
lookup, lookup_size *
sizeof(
int));
219 template <
class View>
223 home.
free<
unsigned int>(indices, n_indices);
224 home.
free<
int>(lookup, lookup_size);
225 return sizeof(*this);
229 template <
class View>
239 unsigned int seqNum = posIt / seq_size;
240 unsigned int seqPos = posIt % seq_size;
241 for (
unsigned int seq = 0 ; seq < n_seqs ; seq++) {
245 if (x[getVal(seq, seqPos)].
assigned()) {
249 const unsigned int *firstSeq = &indices[seqNum*seq_size];
250 const unsigned int *secondSeq = &indices[seq*seq_size];
251 for (
unsigned int i = 0 ;
i < seq_size ;
i++) {
252 const View& xv = x[firstSeq[
i]];
253 const View& yv = x[secondSeq[
i]];
254 if ((!xv.assigned() && !yv.assigned())
255 || (xv.assigned() && yv.assigned() && xv.val() == yv.val())) {
272 template <
class View>
280 template <
class View>
289 template <
class View>
296 template <
class View>
299 unsigned int seqsize)
300 : n_values(n), seq_size(seqsize), n_seqs(n/seqsize),
301 dead_sequences(home, n_seqs) {
303 for (
unsigned int i = 0 ;
i < n_values ;
i++)
307 template <
class View>
311 : n_values(vss.n_values),
312 seq_size(vss.seq_size),
314 dead_sequences(home, vss.dead_sequences) {
316 for (
unsigned int i = 0 ;
i < n_values ;
i++)
320 template <
class View>
325 return sizeof(*this);
328 template <
class View>
332 unsigned int seq = 0;
333 unsigned int pos = 0;
334 for (
unsigned int i = 0 ;
i < n_values ;
i++) {
336 dead_sequences.set(seq);
338 while (pos < seq_size) {
344 if (pos == seq_size) {
351 template <
class View>
virtual size_t dispose(Space &home)
Disposal.
A Literal is a pair of variable index and value.
ValueSymmetryImp(Space &home, int *vs, unsigned int n)
Constructor for creation.
int getVal(unsigned int sequence, unsigned int position) const
Get the value in the specified sequence at the specified position. (Both are zero-based.)
VariableSymmetryImp(Space &home, int *vs, unsigned int n)
Constructor for creation.
bool pos(const View &x)
Test whether x is postive.
Implementation of a variable sequence symmetry.
SymmetryImp< View > * copy(Space &home, bool share) const
Copy function.
int * lookup
Map from variable's index to its sequence and position.
int _value
The value of the literal. For int and bool variables, this is the value itself; for set variables...
int _variable
Variable index. The ViewArray that the index is meant for is assumed to be known by context...
Heap heap
The single global heap.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntConLevel)
Post propagator for .
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
Argument array for non-primitive types.
virtual size_t dispose(Space &home)
Disposal.
unsigned int * indices
Array of variable indices.
int getVal(unsigned int sequence, unsigned int position) const
Get the value in the specified sequence at the specified position. (Both are zero-based.)
Implementation of a value symmetry.
virtual size_t dispose(Space &home)
Disposal.
void free(T *b, long unsigned int n)
Delete n objects allocated from space heap starting at b.
double position(const Space &home, IntVar x, int i)
void values(Home home, const IntVarArgs &x, IntSet y, IntConLevel icl=ICL_DEF)
Post constraint .
Implementation of a single symmetry.
void update(Literal)
Left-branch update.
Node * x
Pointer to corresponding Boolean expression node.
bool assigned(View x, int v)
Whether x is assigned to value v.
Implementation of a variable symmetry.
virtual ArgArray< Literal > symmetric(Literal, const ViewArray< View > &) const
Compute symmetric literals.
Stack with arbitrary number of elements.
void update(Literal)
Left-branch update.
SymmetryImp< View > * copy(Space &home, bool share) const
Copy function.
Implementation of a value sequence symmetry.
int entries(void) const
Return number of entries currently on stack.
void update(Literal)
Search left-branch update.
Gecode toplevel namespace
SymmetryImp< View > * copy(Space &home, bool share) const
Copy function.
ArgArray< T > dynamicStackToArgArray(const Support::DynamicStack< T, A > &s)
Convert a DynamicStack into an ArgArray
virtual size_t dispose(Space &home)
Disposal.
SymmetryImp< View > * copy(Space &home, bool share) const
Copy function.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
void update(Literal)
Left-branch update.
void push(const T &x)
Push element x on top of stack.
VariableSequenceSymmetryImp(Space &home, int *_indices, unsigned int n, unsigned int seqsize)
Constructor for creation.
int * values
Set of sequences.