37 template <
class T,
class A>
41 for (
int i = 0 ; i < s.
entries() ; ++i) {
53 return home.ralloc(s);
71 int maximum = _indices[0];
72 int minimum = _indices[0];
73 for (
unsigned int i = 1 ; i < n ; i++) {
74 if (_indices[i] > maximum) maximum = _indices[i];
75 if (_indices[i] < minimum) minimum = _indices[i];
77 indices.resize(home, maximum-minimum+1, minimum);
80 for (
unsigned int i = 0 ; i < n ; i++) {
91 indices(home, other.indices) {}
101 template <
class View>
110 template <
class View>
120 template <
class View>
130 for (
unsigned int i = 1 ; i < n ; i++) {
131 if (vs[i] > maximum) maximum = vs[i];
132 if (vs[i] < minimum) minimum = vs[i];
134 values.resize(home, maximum-minimum+1, minimum);
137 for (
unsigned int i = 0 ; i < n ; i++) {
142 template <
class View>
147 template <
class View>
152 return sizeof(*this);
155 template <
class View>
163 template <
class View>
171 template <
class View>
178 template <
class View>
181 unsigned int seqsize)
184 unsigned int max_index = _indices[0];
185 for (
unsigned int i = 0 ; i <
n_indices ; i++) {
195 for (
unsigned int i = 0 ; i <
n_indices ; i++) {
201 template <
class View>
205 : n_indices(s.n_indices), seq_size(s.seq_size), n_seqs(s.n_seqs),
206 lookup_size(s.lookup_size) {
213 template <
class View>
219 return sizeof(*this);
223 template <
class View>
234 unsigned int seqNum = posIt /
seq_size;
235 unsigned int seqPos = posIt %
seq_size;
236 for (
unsigned int seq = 0 ; seq <
n_seqs ; seq++) {
240 if (
x[
getVal(seq, seqPos)].assigned()) {
246 for (
unsigned int i = 0 ; i <
seq_size ; i++) {
247 const View& xv =
x[firstSeq[i]];
248 const View& yv =
x[secondSeq[i]];
249 if ((!xv.assigned() && !yv.assigned())
250 || (xv.assigned() && yv.assigned() && xv.
val() == yv.
val())) {
267 template <
class View>
275 template <
class View>
284 template <
class View>
291 template <
class View>
294 unsigned int seqsize)
298 for (
unsigned int i = 0 ; i <
n_values ; i++)
302 template <
class View>
305 const ValueSequenceSymmetryImp<View>& vss)
311 for (
unsigned int i = 0 ; i <
n_values ; i++)
315 template <
class View>
320 return sizeof(*this);
323 template <
class View>
327 unsigned int seq = 0;
328 unsigned int pos = 0;
329 for (
unsigned int i = 0 ; i <
n_values ; i++) {
346 template <
class View>
350 return new (home) ValueSequenceSymmetryImp<View>(home, *
this);
Argument array for non-primitive types.
A Literal is a pair of variable index and value.
int _variable
Variable index. The ViewArray that the index is meant for is assumed to be known by context.
int _value
The value of the literal. For int and bool variables, this is the value itself; for set variables,...
Implementation of a single symmetry.
virtual ~SymmetryImp(void)
Unused destructor.
Implementation of a value sequence symmetry.
unsigned int n_seqs
Number of sequences in symmetry.
int * values
Set of sequences.
unsigned int seq_size
Size of each sequence in symmetry.
Support::BitSet< Space > dead_sequences
Which sequences are dead.
unsigned int n_values
Total number of values (n_seqs * seq_size)
Implementation of a value symmetry.
SymmetryImp< View > * copy(Space &home) const
Copy function.
ValueSymmetryImp(Space &home, int *vs, unsigned int n)
Constructor for creation.
Support::BitSetOffset< Space > values
Symmetric values.
Implementation of a variable sequence symmetry.
VariableSequenceSymmetryImp(Space &home, int *_indices, unsigned int n, unsigned int seqsize)
Constructor for creation.
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....
unsigned int seq_size
Size of each sequence in symmetry.
int * lookup
Map from variable's index to its sequence and position.
unsigned int lookup_size
Size of lookup.
unsigned int n_indices
Total number of indices (n_seqs * seq_size)
unsigned int n_seqs
Number of sequences in symmetry.
Implementation of a variable symmetry.
VariableSymmetryImp(Space &home, int *vs, unsigned int n)
Constructor for creation.
SymmetryImp< View > * copy(Space &home) const
Copy function.
Support::BitSetOffset< Space > indices
Symmetric variable indices.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
void free(T *b, long unsigned int n)
Delete n objects allocated from space heap starting at b.
Stack with arbitrary number of elements.
void push(const T &x)
Push element x on top of stack.
int entries(void) const
Return number of entries currently on stack.
virtual Val val(const Space &home, View x, int i)=0
Return value of view x at position i.
Symmetry breaking for integer variables.
ArgArray< T > dynamicStackToArgArray(const Support::DynamicStack< T, A > &s)
Convert a DynamicStack<T,A> into an ArgArray<T>
Gecode toplevel namespace
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntPropLevel ipl=IPL_DEF)
Post propagator for .
Post propagator for SetVar x