38 namespace Gecode {
namespace Int {
namespace Element {
42 template<
class V0,
class V1,
class Idx,
class Val>
47 template<
class V0,
class V1,
class Idx,
class Val>
55 template<
class V0,
class V1,
class Idx,
class Val>
61 while ((i != 0) && iv[i].
marked())
65 template<
class V0,
class V1,
class Idx,
class Val>
70 template<
class V0,
class V1,
class Idx,
class Val>
79 template<
class V0,
class V1,
class Idx,
class Val>
88 template<
class V0,
class V1,
class Idx,
class Val>
91 :
iv(iv0),
i(
iv[0].val_next) {}
92 template<
class V0,
class V1,
class Idx,
class Val>
97 template<
class V0,
class V1,
class Idx,
class Val>
102 template<
class V0,
class V1,
class Idx,
class Val>
111 template<
class V0,
class V1,
class Idx,
class Val>
117 while ((i != 0) && iv[i].
marked())
121 template<
class V0,
class V1,
class Idx,
class Val>
126 template<
class V0,
class V1,
class Idx,
class Val>
135 template<
class V0,
class V1,
class Idx,
class Val>
145 template<
class V0,
class V1,
class Idx,
class Val>
149 template<
class V0,
class V1,
class Idx,
class Val>
160 template<
class V0,
class V1,
class Idx,
class Val>
169 template<
class V0,
class V1,
class Idx,
class Val>
177 return sizeof(*this);
180 template<
class V0,
class V1,
class Idx,
class Val>
185 }
else if (x1.assigned()) {
193 template<
class V0,
class V1,
class Idx,
class Val>
196 :
Propagator(home,share,p), s0(0), s1(0), iv(NULL) {
198 x0.update(home,share,p.
x0);
199 x1.update(home,share,p.
x1);
202 template<
class V0,
class V1,
class Idx,
class Val>
208 template<
class V0,
class V1,
class Idx,
class Val>
218 template<
class V0,
class V1,
class Idx,
class Val>
222 Idx
i = iv[
p].idx_next;
224 while (
v() && (i != 0)) {
226 if (iv[i].idx < v.
min()) {
227 iv[
i].mark(); i=iv[
i].idx_next; iv[
p].idx_next=
i;
228 }
else if (iv[i].idx > v.
max()) {
231 p=
i; i=iv[
i].idx_next;
236 iv[
i].mark(); i=iv[
i].idx_next;
240 template<
class V0,
class V1,
class Idx,
class Val>
244 Idx
i = iv[
p].val_next;
246 while (
v() && (i != 0)) {
248 i=iv[
i].val_next; iv[
p].val_next=
i;
249 }
else if (iv[i].val < v.
min()) {
250 iv[
i].mark(); i=iv[
i].val_next; iv[
p].val_next=
i;
251 }
else if (iv[i].val > v.
max()) {
254 p=
i; i=iv[
i].val_next;
259 iv[
i].mark(); i=iv[
i].val_next;
263 template<
class V0,
class V1,
class Idx,
class Val>
268 int*
v = r.
alloc<
int>(x0.size());
271 if (c[
i.val()] != x1.val())
278 template<
class V0,
class V1,
class Idx,
class Val>
286 if (x1.assigned() && (iv == NULL)) {
291 if ((static_cast<ValSize>(x1.size()) == s1) &&
292 (
static_cast<IdxSize>(x0.size()) != s0)) {
301 s1=
static_cast<ValSize>(x1.size());
303 assert(!x0.assigned());
307 if ((static_cast<IdxSize>(x0.size()) == s0) &&
308 (
static_cast<ValSize>(x1.size()) != s1)) {
317 s0=
static_cast<IdxSize>(x0.size());
319 return (x0.assigned() || x1.assigned()) ?
323 bool assigned = x0.assigned() && x1.assigned();
333 if ((x1.min() <=
c[
v.val()]) && (x1.max() >=
c[
v.val()])) {
334 by_idx[
size].idx =
static_cast<Idx
>(
v.val());
335 by_idx[
size].val =
static_cast<Val
>(
c[
v.val()]);
343 if (x1.width() <= 128) {
344 int n_buckets =
static_cast<int>(x1.width());
346 int* buckets = pos - x1.min();
347 for (
int i=n_buckets;
i--; )
349 for (Idx
i=size;
i--; )
350 buckets[by_idx[
i].val]++;
352 for (
int i=0;
i<n_buckets;
i++) {
353 int n=pos[
i]; pos[
i]=
p; p+=
n;
356 for (Idx
i=size;
i--; )
357 by_val[buckets[by_idx[
i].val]++] =
i+1;
359 for (Idx
i = size;
i--; )
362 Support::quicksort<Idx>(by_val,
size,less);
365 for (Idx
i = size-1;
i--; ) {
366 by_idx[
i].idx_next =
i+2;
367 iv[by_val[
i]].val_next = by_val[
i+1];
369 by_idx[size-1].idx_next = 0;
370 iv[by_val[size-1]].val_next = 0;
373 iv[0].val_next = by_val[0];
388 s0=
static_cast<IdxSize>(x0.size());
389 s1=
static_cast<ValSize>(x1.size());
393 s0=
static_cast<IdxSize>(x0.size());
394 s1=
static_cast<ValSize>(x1.size());
395 return (x0.assigned() || x1.assigned()) ?
401 template<
class V0,
class V1>
404 assert(c.
size() > 0);
410 for (
int i=1;
i<c.
size();
i++) {
bool marked(void *p)
Check whether p is marked.
IdxVal * iv
The index-value data structure.
Idx val(void) const
Return index of current index value pair.
IdxSize s0
Size of x0 at last execution.
Value iterator for values in index-value map.
ExecStatus ES_SUBSUMED(Propagator &p)
const FloatNum max
Largest allowed float value.
Linked index-value pairs.
Actor must always be disposed.
void operator++(void)
Move to next index value pair (next value)
T * alloc(long unsigned int n)
Allocate block of n objects of type T from region.
IterValUnmark(IdxVal *iv)
Initialize with start.
Value iterator for array of integers
Val val(void) const
Return value of current index value pair.
Int(Space &home, bool shared, Int &p)
Constructor for cloning p.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
IterVal(IdxVal *iv)
Initialize with start.
bool pos(const View &x)
Test whether x is postive.
Base-class for propagators.
bool operator()(void) const
Test whether more pairs to be iterated.
ValSize s1
Size of x1 at last execution.
Val val(void) const
Return value of current index value pair.
Value iterator for indices in index-value map.
Value iterator for integer views.
Propagation has computed fixpoint.
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
IntSharedArray c
Shared array of integer values.
Base-class for both propagators and branchers.
Range iterator for integer views.
virtual Actor * copy(Space &home, bool share)
Perform copying during cloning.
IntType s_type(signed int n)
Return type required to represent n.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
const FloatNum min
Smallest allowed float value.
int min(void) const
Return smallest value of range.
Gecode::IntArgs i(4, 1, 2, 3, 4)
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Const function (defined as high binary)
int n
Number of negative literals for node type.
Gecode::Support::IntTypeTraits< Val >::utype ValSize
Type for value size.
Val val
The value Mark that this pair should be removed.
Execution has resulted in failure.
Value iterator for values in index-value map.
Idx idx_next
The position of the next pair in index order.
bool operator()(void) const
Test whether more pairs to be iterated.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
void prune_val(void)
Prune values according to x1.
unsigned int size(I &i)
Size of all ranges of range iterator i.
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
int size(void) const
Return number of elements.
Gecode::Support::IntTypeTraits< Idx >::utype IdxSize
Type for index size.
static ExecStatus post(Home home, IntSharedArray &i, V0 x0, V1 x1)
Post propagator for .
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
void operator++(void)
Move to next index value pair (next index)
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
ByVal(const IdxVal *iv)
Initialize with index value pairs.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
bool operator()(void) const
Test whether more pairs to be iterated.
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
virtual size_t dispose(Space &home)
Delete actor and return its size.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
bool assigned(View x, int v)
Whether x is assigned to value v.
ExecStatus post_int(Home home, IntSharedArray &c, V0 x0, V1 x1)
Post propagator with apropriate index and value types.
Propagation has not computed fixpoint.
void prune_idx(void)
Prune index according to x0.
void operator++(void)
Move to next index value pair (next value)
bool shared(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether views share same variable.
IterIdxUnmark(IdxVal *iv)
Initialize with start.
Idx val_next
The position of the next pair in value order.
int max(void) const
Return largest value of range.
bool marked(void) const
Return whether this pair is marked for removal.
Gecode toplevel namespace
Sorting pointers to (index,value) pairs in value order.
IntType
Description of integer types.
int ModEventDelta
Modification event deltas.
Element propagator for array of integers
Home class for posting propagators
static ExecStatus assigned_val(Space &home, IntSharedArray &c, V0 x0, V1 x1)
Prune when x1 is assigned.
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
bool operator()(Idx &i, Idx &j)
Compare pairs at positions i and j.