Go to the documentation of this file.
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>
225 template<
class V0,
class V1,
class Idx,
class Val>
229 Idx
i = iv[
p].idx_next;
231 while (
v() && (
i != 0)) {
233 if (iv[
i].idx <
v.min()) {
234 iv[
i].mark();
i=iv[
i].idx_next; iv[
p].idx_next=
i;
235 }
else if (iv[
i].idx >
v.max()) {
238 p=
i;
i=iv[
i].idx_next;
243 iv[
i].mark();
i=iv[
i].idx_next;
247 template<
class V0,
class V1,
class Idx,
class Val>
251 Idx
i = iv[
p].val_next;
253 while (
v() && (
i != 0)) {
255 i=iv[
i].val_next; iv[
p].val_next=
i;
256 }
else if (iv[
i].val <
v.min()) {
257 iv[
i].mark();
i=iv[
i].val_next; iv[
p].val_next=
i;
258 }
else if (iv[
i].val >
v.max()) {
261 p=
i;
i=iv[
i].val_next;
266 iv[
i].mark();
i=iv[
i].val_next;
270 template<
class V0,
class V1,
class Idx,
class Val>
275 int*
v =
r.alloc<
int>(x0.size());
278 if (
c[
i.val()] != x1.val())
285 template<
class V0,
class V1,
class Idx,
class Val>
293 if (x1.assigned() && (iv == NULL)) {
298 if ((
static_cast<ValSize>(x1.size()) == s1) &&
299 (
static_cast<IdxSize>(x0.size()) != s0)) {
308 s1=
static_cast<ValSize>(x1.size());
310 assert(!x0.assigned());
314 if ((
static_cast<IdxSize>(x0.size()) == s0) &&
315 (
static_cast<ValSize>(x1.size()) != s1)) {
324 s0=
static_cast<IdxSize>(x0.size());
326 return (x0.assigned() || x1.assigned()) ?
330 bool assigned = x0.assigned() && x1.assigned();
340 if ((x1.min() <=
c[
v.val()]) && (x1.max() >=
c[
v.val()])) {
341 by_idx[
size].idx =
static_cast<Idx
>(
v.val());
342 by_idx[
size].val =
static_cast<Val
>(
c[
v.val()]);
349 Idx* by_val =
r.alloc<Idx>(
size);
350 if (x1.width() <= 128) {
351 int n_buckets =
static_cast<int>(x1.width());
352 int*
pos =
r.alloc<
int>(n_buckets);
353 int* buckets =
pos - x1.min();
354 for (
int i=n_buckets;
i--; )
357 buckets[by_idx[
i].val]++;
359 for (
int i=0;
i<n_buckets;
i++) {
364 by_val[buckets[by_idx[
i].val]++] =
i+1;
369 Support::quicksort<Idx>(by_val,
size,less);
372 for (Idx
i =
size-1;
i--; ) {
373 by_idx[
i].idx_next =
i+2;
374 iv[by_val[
i]].val_next = by_val[
i+1];
376 by_idx[
size-1].idx_next = 0;
377 iv[by_val[
size-1]].val_next = 0;
380 iv[0].val_next = by_val[0];
395 s0=
static_cast<IdxSize>(x0.size());
396 s1=
static_cast<ValSize>(x1.size());
400 s0=
static_cast<IdxSize>(x0.size());
401 s1=
static_cast<ValSize>(x1.size());
402 return (x0.assigned() || x1.assigned()) ?
408 template<
class V0,
class V1>
411 assert(
c.
size() > 0);
virtual Actor * copy(Space &home, bool share)
Perform copying during cloning.
void notice(Actor &a, ActorProperty p, bool duplicate=false)
Notice actor property.
Int(Space &home, bool shared, Int &p)
Constructor for cloning p.
ValSize s1
Size of x1 at last execution.
Value iterator for values in index-value map.
bool marked(void) const
Return whether this pair is marked for removal.
ByVal(const IdxVal *iv)
Initialize with index value pairs.
@ IT_SHRT
short integer type
IterIdxUnmark(IdxVal *iv)
Initialize with start.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Value iterator for indices in index-value map.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
ExecStatus ES_SUBSUMED(Propagator &p)
IterValUnmark(IdxVal *iv)
Initialize with start.
Val val(void) const
Return value of current index value pair.
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
unsigned int size(I &i)
Size of all ranges of range iterator i.
IterVal(IdxVal *iv)
Initialize with start.
bool assigned(View x, int v)
Whether x is assigned to value v.
Value iterator for array of integers
Gecode::IntArgs i(4, 1, 2, 3, 4)
Idx val(void) const
Return index of current index value pair.
Value iterator for integer views.
const FloatNum min
Smallest allowed float value.
Value iterator for values in index-value map.
Base-class for both propagators and branchers.
IdxSize s0
Size of x0 at last execution.
bool operator()(void) const
Test whether more pairs to be iterated.
Gecode::Support::IntTypeTraits< Idx >::utype IdxSize
Type for index size.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
Element propagator for array of integers
Gecode toplevel namespace
Base-class for propagators.
Range iterator for integer views.
Idx idx_next
The position of the next pair in index order.
virtual size_t dispose(Space &home)
Delete propagator and return its size.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
Val val(void) const
Return value of current index value pair.
Home class for posting propagators
Val val
The value Mark that this pair should be removed.
@ AP_DISPOSE
Actor must always be disposed.
void update(Space &home, bool share, SharedHandle &sh)
Updating during cloning.
void prune_val(void)
Prune values according to x1.
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Post propagator for SetVar SetOpType SetVar SetRelType r
T * alloc(long unsigned int n)
Allocate block of n objects of type T from space heap.
static ExecStatus post(Home home, IntSharedArray &i, V0 x0, V1 x1)
Post propagator for .
bool operator()(Idx &i, Idx &j)
Compare pairs at positions i and j.
void prune_idx(void)
Prune index according to x0.
ExecStatus post_int(Home home, IntSharedArray &c, V0 x0, V1 x1)
Post propagator with apropriate index and value types.
IdxVal * iv
The index-value data structure.
FloatNum size(void) const
Return size of float value (distance between maximum and minimum)
void operator++(void)
Move to next index value pair (next value)
bool operator()(void) const
Test whether more pairs to be iterated.
void operator++(void)
Move to next index value pair (next index)
Gecode::Support::IntTypeTraits< Val >::utype ValSize
Type for value size.
@ IT_CHAR
char integer type
IntType
Description of integer types.
bool shared(const IntSet &, VX)
@ ES_FIX
Propagation has computed fixpoint.
Idx val_next
The position of the next pair in value order.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high binary)
bool operator()(void) const
Test whether more pairs to be iterated.
void ignore(Actor &a, ActorProperty p, bool duplicate=false)
Ignore actor property.
virtual void reschedule(Space &home)
Schedule function.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
static ExecStatus assigned_val(Space &home, IntSharedArray &c, V0 x0, V1 x1)
Prune when x1 is assigned.
virtual size_t dispose(Space &home)
Delete actor and return its size.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Gecode::FloatVal c(-8, 8)
IntType s_type(signed int n)
Return type required to represent n.
int n
Number of negative literals for node type.
@ ES_FAILED
Execution has resulted in failure.
void operator++(void)
Move to next index value pair (next value)
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
int ModEventDelta
Modification event deltas.
@ ES_NOFIX
Propagation has not computed fixpoint.
bool pos(const View &x)
Test whether x is postive.
@ ES_OK
Execution is okay.
Sorting pointers to (index,value) pairs in value order.
int p
Number of positive literals for node type.
IntSharedArray c
Shared array of integer values.
const FloatNum max
Largest allowed float value.
bool marked(void *p)
Check whether p is marked.
Linked index-value pairs.