45 template<
class VA,
class VB,
class Ops>
52 ModEvent me = x0.lq(home,ops.fnroot(x1.max()));
57 ModEvent me = x0.gq(home,ops.cnroot(x1.min()));
62 ModEvent me = x1.lq(home,ops.pow(x0.max()));
67 ModEvent me = x1.gq(home,ops.pow(x0.min()));
75 template<
class VA,
class VB,
class Ops>
81 template<
class VA,
class VB,
class Ops>
88 assert(!
x1.assigned());
94 template<
class VA,
class VB,
class Ops>
100 template<
class VA,
class VB,
class Ops>
106 template<
class VA,
class VB,
class Ops>
123 assert((x0.
min() < 0) && (0 < x0.
max()));
125 assert(x1.
min() >= 0);
126 int u = ops.fnroot(x1.
max());
130 ops.pow(-x0.
min()))));
132 assert((x1.
min() < 0) && (0 < x1.
max()));
150 if (
static_cast<unsigned int>(
ops.exp()) >=
sizeof(
int) * CHAR_BIT) {
155 ops.exp(
ops.even() ? 2 : 1);
158 if (
ops.exp() == 0) {
161 }
else if (
ops.exp() == 1) {
166 assert(
ops.exp() != 0);
180 if ((
x0.min() >= 0) || ((
x1.min() >= 0) && !
ops.even()))
183 if (
ops.even() && (
x0.max() <= 0))
187 if (!
ops.even() && ((
x0.max() <= 0) || (
x1.max() <= 0)))
194 assert((
x0.min() < 0) && (
x0.max() > 0));
198 ops.pow(
x0.max()))));
223 if ((
x0.min() >= 0) || ((
x1.min() >= 0) && !
ops.even()))
227 if (
ops.even() && (
x0.max() <= 0))
231 if (!
ops.even() && ((
x0.max() <= 0) || (
x1.max() <= 0)))
238 if (
x0.assigned() &&
x1.assigned())
239 return (
ops.pow(
x0.val()) ==
x1.val()) ?
277 return ops.fnroot(
x);
293 return -
ops.fnroot(-
x);
295 return ops.fnroot(
x);
304 template<
class VA,
class VB,
class Ops>
310 template<
class VA,
class VB,
class Ops>
316 if (!
x0.assigned()) {
317 assert(!
x1.assigned());
323 template<
class VA,
class VB,
class Ops>
329 template<
class VA,
class VB,
class Ops>
335 template<
class VA,
class VB,
class Ops>
346 template<
class VA,
class VB,
class Ops>
351 return x0.assigned() ?
387 if (
static_cast<unsigned int>(
ops.exp()) >=
sizeof(
int) * CHAR_BIT) {
392 ops.exp(
ops.even() ? 2 : 1);
395 if (
ops.exp() == 0) {
398 }
else if (
ops.exp() == 1) {
403 assert(
ops.exp() != 0);
417 if ((
x0.min() >= 0) || ((
x1.min() >= 0) && !
ops.even()))
420 if (
ops.even() && (
x0.max() <= 0))
424 if (!
ops.even() && ((
x0.max() <= 0) || (
x1.max() <= 0)))
431 assert((
x0.min() < 0) && (
x0.max() > 0));
435 ops.pow(
x0.max()))));
471 if ((
x0.min() >= 0) || ((
x1.min() >= 0) && !
ops.even()))
475 if (
ops.even() && (
x0.max() <= 0))
479 if (!
ops.even() && ((
x0.max() <= 0) || (
x1.max() <= 0)))
486 if (
x0.assigned() &&
x1.assigned())
487 return (
ops.pow(
x0.val()) ==
x1.val()) ?
497 Positive<ViewValues<IntView> >
pos(i);
498 Negative<ViewValues<IntView> >
neg(j);
503 Map<Minus,ValuesMapPow<Ops>,
true> sm(m,vmp);
505 Map<Minus,ValuesMapPow<Ops>,
true> > u(sp,sm);
Base-class for both propagators and branchers.
BinaryPropagator(Space &home, BinaryPropagator &p)
Home class for posting propagators
virtual Actor * copy(Space &home)
Copy propagator during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, IntView x0, IntView x1, Ops ops)
Post propagator.
PowBnd(Space &home, PowBnd &p)
Constructor for cloning p.
static ExecStatus post(Home home, IntView x0, IntView x1, Ops ops)
Post propagator.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
PowDom(Space &home, PowDom< Ops > &p)
Constructor for cloning p.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Bounds consistent positive power propagator.
static ExecStatus post(Home home, VA x0, VB x1, Ops ops)
Post propagator.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
PowPlusBnd(Home home, VA x0, VB x1, const Ops &ops)
Constructor for posting.
Domain consistent positive power propagator.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ExecStatus post(Home home, VA x0, VB x1, Ops ops)
Post propagator.
PowPlusDom(Home home, VA x0, VB x1, const Ops &ops)
Constructor for posting.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Mapping integer (must be an n-th power) to n-th root (signed)
ValuesMapNrootSigned(const Ops &o)
Initialize with operations o.
int val(int x) const
Perform mapping.
Mapping integer (must be an n-th power) to n-th root.
int val(int x) const
Perform mapping.
ValuesMapNroot(const Ops &o)
Initialize with operations o.
Mapping integer to power.
ValuesMapPow(const Ops &o)
Initialize with operations o.
int val(int x) const
Perform mapping.
Integer view for integer variables.
int min(void) const
Return minimum of domain.
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
int med(void) const
Return median of domain (greatest element not greater than the median)
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
int max(void) const
Return maximum of domain.
static ExecStatus post(Home home, View0 x0, View1 x1)
Post bounds consistent propagator .
static ExecStatus post(Home home, View0 x0, View1 x1)
Post domain consistent propagator .
Value iterator for integer views.
Value iterator for mapping values of a value iterator.
MixBinaryPropagator(Space &home, MixBinaryPropagator &p)
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
ModEventDelta med
A set of modification events (used during propagation)
Propagator for ternary union
static ModEvent me(const ModEventDelta &med)
ExecStatus ES_NOFIX_PARTIAL(Propagator &p, const ModEventDelta &med)
Propagator p has not computed partial fixpoint
ExecStatus ES_SUBSUMED(Propagator &p)
Propagator p is subsumed
int ModEventDelta
Modification event deltas.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
Numerical (arithmetic) propagators.
bool pos(const View &x)
Test whether x is postive.
ExecStatus prop_pow_plus_bnd(Space &home, VA x0, VB x1, const Ops &ops)
ExecStatus prop_pow_bnd(Space &home, IntView x0, IntView x1, const Ops &ops)
bool neg(const View &x)
Test whether x is negative.
const int min
Smallest allowed integer value.
const int max
Largest allowed integer value.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl=IPL_DEF)
Post propagator for .
@ ES_OK
Execution is okay.
@ ES_FIX
Propagation has computed fixpoint.
@ ES_FAILED
Execution has resulted in failure.
@ ES_NOFIX
Propagation has not computed fixpoint.
Post propagator for SetVar x
int ModEvent
Type for modification events.