34namespace Gecode {
namespace Int {
namespace LDSB {
37 template <
class T,
class A>
53 return home.ralloc(s);
67 : indices(home, 0, 0) {
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) {}
97 indices.dispose(home);
101 template <
class View>
105 if (indices.valid(
l._variable)) {
106 indices.clear(
l._variable);
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)
182 : n_indices(
n), seq_size(seqsize), n_seqs(
n/seqsize) {
184 unsigned int max_index = _indices[0];
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>
217 home.
free<
unsigned int>(indices, n_indices);
218 home.
free<
int>(lookup, lookup_size);
219 return sizeof(*this);
223 template <
class View>
229 if (
l._variable < (
int)lookup_size) {
230 int posIt = lookup[
l._variable];
234 unsigned int seqNum = posIt / seq_size;
235 unsigned int seqPos = posIt % seq_size;
236 for (
unsigned int seq = 0 ; seq < n_seqs ; seq++) {
244 const unsigned int *firstSeq = &indices[seqNum*seq_size];
245 const unsigned int *secondSeq = &indices[seq*seq_size];
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)
295 : n_values(
n), seq_size(seqsize), n_seqs(
n/seqsize),
296 dead_sequences(home, n_seqs) {
302 template <
class View>
306 : n_values(vss.n_values),
307 seq_size(vss.seq_size),
309 dead_sequences(home, vss.dead_sequences) {
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++) {
331 dead_sequences.set(seq);
333 while (
pos < seq_size) {
339 if (
pos == seq_size) {
346 template <
class View>
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
Argument array for non-primitive types.
A Literal is a pair of variable index and value.
Implementation of a single symmetry.
virtual ~SymmetryImp(void)
Unused destructor.
Implementation of a value sequence symmetry.
int getVal(unsigned int sequence, unsigned int position) const
Get the value in the specified sequence at the specified position. (Both are zero-based....
int * values
Set of sequences.
SymmetryImp< View > * copy(Space &home) const
Copy function.
void update(Literal)
Left-branch update.
virtual size_t dispose(Space &home)
Disposal.
unsigned int n_values
Total number of values (n_seqs * seq_size)
Implementation of a value symmetry.
virtual size_t dispose(Space &home)
Disposal.
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.
void update(Literal)
Left-branch update.
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....
virtual size_t dispose(Space &home)
Disposal.
SymmetryImp< View > * copy(Space &home) const
Copy function.
int * lookup
Map from variable's index to its sequence and position.
void update(Literal)
Search left-branch update.
unsigned int lookup_size
Size of lookup.
unsigned int n_indices
Total number of indices (n_seqs * seq_size)
virtual ArgArray< Literal > symmetric(Literal, const ViewArray< View > &) const
Compute symmetric literals.
Implementation of a variable symmetry.
VariableSymmetryImp(Space &home, int *vs, unsigned int n)
Constructor for creation.
void update(Literal)
Left-branch update.
SymmetryImp< View > * copy(Space &home) const
Copy function.
Support::BitSetOffset< Space > indices
Symmetric variable indices.
virtual size_t dispose(Space &home)
Disposal.
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.
bool pos(const View &x)
Test whether x is postive.
ArgArray< T > dynamicStackToArgArray(const Support::DynamicStack< T, A > &s)
Convert a DynamicStack<T,A> into an ArgArray<T>
bool assigned(View x, int v)
Whether x is assigned to value v.
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 .
void values(Home home, const IntVarArgs &x, IntSet y, IntPropLevel ipl=IPL_DEF)
Post constraint .
Post propagator for SetVar x
Gecode::IntArgs i({1, 2, 3, 4})
double position(const Space &home, IntVar x, int i)