Go to the documentation of this file.
43 namespace Gecode {
namespace Int {
namespace Arithmetic {
49 template<
class VA,
class VB,
class Ops>
56 ModEvent me = x0.lq(home,ops.fnroot(x1.max()));
61 ModEvent me = x0.gq(home,ops.cnroot(x1.min()));
66 ModEvent me = x1.lq(home,ops.pow(x0.max()));
71 ModEvent me = x1.gq(home,ops.pow(x0.min()));
79 template<
class VA,
class VB,
class Ops>
85 template<
class VA,
class VB,
class Ops>
92 assert(!x1.assigned());
98 template<
class VA,
class VB,
class Ops>
105 template<
class VA,
class VB,
class Ops>
111 template<
class VA,
class VB,
class Ops>
128 assert((x0.
min() < 0) && (0 < x0.
max()));
130 assert(x1.
min() >= 0);
131 int u = ops.fnroot(x1.
max());
135 ops.pow(-x0.
min()))));
137 assert((x1.
min() < 0) && (0 < x1.
max()));
155 if (
static_cast<unsigned int>(ops.exp()) >=
sizeof(
int) * CHAR_BIT) {
160 ops.exp(ops.even() ? 2 : 1);
163 if (ops.exp() == 0) {
166 }
else if (ops.exp() == 1) {
171 assert(ops.exp() != 0);
185 if ((x0.
min() >= 0) || ((x1.
min() >= 0) && !ops.even()))
188 if (ops.even() && (x0.
max() <= 0))
192 if (!ops.even() && ((x0.
max() <= 0) || (x1.
max() <= 0)))
199 assert((x0.
min() < 0) && (x0.
max() > 0));
203 ops.pow(x0.
max()))));
228 if ((x0.min() >= 0) || ((x1.min() >= 0) && !ops.even()))
230 ::
post(home(*
this),x0,x1,ops)));
232 if (ops.even() && (x0.max() <= 0))
236 if (!ops.even() && ((x0.max() <= 0) || (x1.max() <= 0)))
243 if (x0.assigned() && x1.assigned())
244 return (ops.pow(x0.val()) == x1.val()) ?
282 return ops.fnroot(
x);
298 return -
ops.fnroot(-
x);
300 return ops.fnroot(
x);
309 template<
class VA,
class VB,
class Ops>
315 template<
class VA,
class VB,
class Ops>
321 if (!x0.assigned()) {
322 assert(!x1.assigned());
328 template<
class VA,
class VB,
class Ops>
335 template<
class VA,
class VB,
class Ops>
341 template<
class VA,
class VB,
class Ops>
352 template<
class VA,
class VB,
class Ops>
357 return x0.assigned() ?
393 if (
static_cast<unsigned int>(ops.exp()) >=
sizeof(
int) * CHAR_BIT) {
398 ops.exp(ops.even() ? 2 : 1);
401 if (ops.exp() == 0) {
404 }
else if (ops.exp() == 1) {
409 assert(ops.exp() != 0);
423 if ((x0.
min() >= 0) || ((x1.
min() >= 0) && !ops.even()))
426 if (ops.even() && (x0.
max() <= 0))
430 if (!ops.even() && ((x0.
max() <= 0) || (x1.
max() <= 0)))
437 assert((x0.
min() < 0) && (x0.
max() > 0));
441 ops.pow(x0.
max()))));
477 if ((x0.min() >= 0) || ((x1.min() >= 0) && !ops.even()))
479 ::
post(home(*
this),x0,x1,ops)));
481 if (ops.even() && (x0.max() <= 0))
485 if (!ops.even() && ((x0.max() <= 0) || (x1.max() <= 0)))
492 if (x0.assigned() && x1.assigned())
493 return (ops.pow(x0.val()) == x1.val()) ?
502 using namespace Iter::Values;
503 Positive<ViewValues<IntView> >
pos(
i);
504 Negative<ViewValues<IntView> >
neg(j);
509 Map<Minus,ValuesMapPow<Ops>,
true>
sm(m,vmp);
511 Map<Minus,ValuesMapPow<Ops>,
true> >
u(sp,
sm);
522 using namespace Iter::Values;
Post propagator for SetVar x
Propagator for ternary union
bool me_failed(ModEvent me)
Check whether modification event me is failed.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
bool pos(const View &x)
Test whether x is postive.
ValuesMapNrootSigned(const Ops &o)
Initialize with operations o.
ExecStatus ES_SUBSUMED(Propagator &p)
int val(int x) const
Perform mapping.
int min(void) const
Return minimum of domain.
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
Domain consistent positive power propagator.
PowBnd(Space &home, bool share, PowBnd &p)
Constructor for cloning p.
ExecStatus prop_pow_plus_bnd(Space &home, VA x0, VB x1, const Ops &ops)
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::IntArgs v1(4, Gecode::Int::Limits::min+4, 0, 1, Gecode::Int::Limits::max)
Value iterator for mapping values of a value iterator.
bool same(const CachedView< View > &x, const CachedView< View > &y)
Value iterator for integer views.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
static ExecStatus post(Home home, View0 x0, View1 x1)
Post domain consistent propagator .
ExecStatus ES_NOFIX_PARTIAL(Propagator &p, const ModEventDelta &med)
Propagator p has not computed partial fixpoint
Base-class for both propagators and branchers.
static ExecStatus post(Home home, VA x0, VB x1, Ops ops)
Post propagator.
static ExecStatus post(Home home, IntView x0, IntView x1, Ops ops)
Post propagator.
Mapping integer (must be an n-th power) to n-th root.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
union Gecode::@579::NNF::@61 u
Union depending on nodetype t.
int val(int x) const
Perform mapping.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
PowPlusBnd(Home home, VA x0, VB x1, const Ops &ops)
Constructor for posting.
static ExecStatus post(Home home, VA x0, VB x1, Ops ops)
Post propagator.
Gecode toplevel namespace
int max(void) const
Return maximum of domain.
static ExecStatus post(Home home, View0 x0, View1 x1)
Post bounds consistent propagator .
#define GECODE_ES_CHECK(es)
Check whether execution status es is failed or subsumed, and forward failure or subsumption.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Home class for posting propagators
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
int val(int x) const
Perform mapping.
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
Domain consistent power propagator.
Post propagator for SetVar SetOpType SetVar SetRelType r
Mapping integer (must be an n-th power) to n-th root (signed)
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
TFE post(PropagatorGroup g)
Only post functions (but not propagators) from g are considered.
Bounds consistent power propagator.
ValuesMapPow(const Ops &o)
Initialize with operations o.
const int max
Largest allowed integer value.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
int ModEvent
Type for modification events.
PowPlusDom(Home home, VA x0, VB x1, const Ops &ops)
Constructor for posting.
ExecStatus prop_pow_bnd(Space &home, IntView x0, IntView x1, const Ops &ops)
PowDom(Space &home, bool share, PowDom< Ops > &p)
Constructor for cloning p.
Mapping integer to power.
static ExecStatus post(Home home, IntView x0, IntView x1, Ops ops)
Post propagator.
bool neg(const View &x)
Test whether x is negative.
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
IntPropLevel sm(IntPropLevel ipl)
Extract speed or memory from propagation level.
@ ES_FIX
Propagation has computed fixpoint.
Integer view for integer variables.
const int min
Smallest allowed integer value.
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
ModEvent lq(Space &home, int n)
Restrict domain values to be less or equal than n.
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
virtual Actor * copy(Space &home, bool share)
Copy propagator during cloning.
@ ES_FAILED
Execution has resulted in failure.
int med(void) const
Return median of domain (greatest element not greater than the median)
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
int ModEventDelta
Modification event deltas.
ValuesMapNroot(const Ops &o)
Initialize with operations o.
@ ES_NOFIX
Propagation has not computed fixpoint.
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
@ ES_OK
Execution is okay.
int p
Number of positive literals for node type.
const FloatNum max
Largest allowed float value.
Bounds consistent positive power propagator.
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.