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>
104 template<
class VA,
class VB,
class Ops>
110 template<
class VA,
class VB,
class Ops>
127 assert((x0.
min() < 0) && (0 < x0.
max()));
129 assert(x1.
min() >= 0);
130 int u = ops.fnroot(x1.
max());
134 ops.pow(-x0.
min()))));
136 assert((x1.
min() < 0) && (0 < x1.
max()));
154 if (static_cast<unsigned int>(ops.exp()) >=
sizeof(
int) * CHAR_BIT) {
159 ops.exp(ops.even() ? 2 : 1);
162 if (ops.exp() == 0) {
165 }
else if (ops.exp() == 1) {
170 assert(ops.exp() != 0);
184 if ((x0.
min() >= 0) || ((x1.
min() >= 0) && !ops.even()))
187 if (ops.even() && (x0.
max() <= 0))
191 if (!ops.even() && ((x0.
max() <= 0) || (x1.
max() <= 0)))
198 assert((x0.
min() < 0) && (x0.
max() > 0));
202 ops.pow(x0.
max()))));
281 return ops.fnroot(x);
297 return -ops.fnroot(-x);
299 return ops.fnroot(x);
308 template<
class VA,
class VB,
class Ops>
314 template<
class VA,
class VB,
class Ops>
320 if (!x0.assigned()) {
321 assert(!x1.assigned());
327 template<
class VA,
class VB,
class Ops>
333 template<
class VA,
class VB,
class Ops>
339 template<
class VA,
class VB,
class Ops>
350 template<
class VA,
class VB,
class Ops>
355 return x0.assigned() ?
391 if (static_cast<unsigned int>(ops.exp()) >=
sizeof(
int) * CHAR_BIT) {
396 ops.exp(ops.even() ? 2 : 1);
399 if (ops.exp() == 0) {
402 }
else if (ops.exp() == 1) {
407 assert(ops.exp() != 0);
421 if ((x0.
min() >= 0) || ((x1.
min() >= 0) && !ops.even()))
424 if (ops.even() && (x0.
max() <= 0))
428 if (!ops.even() && ((x0.
max() <= 0) || (x1.
max() <= 0)))
435 assert((x0.
min() < 0) && (x0.
max() > 0));
439 ops.pow(x0.
max()))));
500 using namespace Iter::Values;
501 Positive<ViewValues<IntView> >
pos(
i);
502 Negative<ViewValues<IntView> >
neg(j);
507 Map<Minus,ValuesMapPow<Ops>,
true> sm(m,vmp);
509 Map<Minus,ValuesMapPow<Ops>,
true> >
u(sp,sm);
520 using namespace Iter::Values;
525 Map<ViewValues<IntView>,ValuesMapNroot<Ops>,
true> >
u(mi,sj);
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
int val(void) const
Return assigned value (only if assigned)
#define GECODE_REWRITE(prop, post)
Rewrite propagator by executing post function.
ExecStatus ES_SUBSUMED(Propagator &p)
const FloatNum max
Largest allowed float value.
ModEvent eq(Space &home, int n)
Restrict domain values to be equal to n.
Propagator for ternary union
Mapping integer (must be an n-th power) to n-th root.
ExecStatus ES_NOFIX_PARTIAL(Propagator &p, const ModEventDelta &med)
Propagator p has not computed partial fixpoint
static ExecStatus post(Home home, View0 x0, View1 x1)
Post domain consistent propagator .
int ModEvent
Type for modification events.
static ExecStatus post(Home home, VA x0, VB x1, Ops ops)
Post propagator.
Bounds consistent power propagator.
ValuesMapNroot(const Ops &o)
Initialize with operations o.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Value iterator for integer views.
Propagation has computed fixpoint.
static PropCost unary(PropCost::Mod m)
Single variable for modifier pcm.
const int max
Largest allowed integer value.
PowPlusBnd(Home home, VA x0, VB x1, const Ops &ops)
Constructor for posting.
const int min
Smallest allowed integer value.
Base-class for both propagators and branchers.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
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.
bool same(const CachedView< View > &x, const CachedView< View > &y)
int p
Number of positive literals for node type.
Mapping integer (must be an n-th power) to n-th root (signed)
Gecode::IntArgs i(4, 1, 2, 3, 4)
static ExecStatus post(Home home, VA x0, VB x1, Ops ops)
Post propagator.
Execution has resulted in failure.
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)
const Gecode::PropCond PC_INT_BND
Propagate when minimum or maximum of a view changes.
const Gecode::ModEvent ME_INT_VAL
Domain operation has resulted in a value (assigned variable)
ModEventDelta med
A set of modification events (used during propagation)
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
static ExecStatus post(Home home, IntView x0, IntView x1, Ops ops)
Post propagator.
Bounds consistent positive power propagator.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
const Gecode::PropCond PC_INT_DOM
Propagate when domain changes.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
int min(void) const
Return minimum of domain.
Value iterator for mapping values of a value iterator.
union Gecode::@585::NNF::@62 u
Union depending on nodetype t.
ValuesMapNrootSigned(const Ops &o)
Initialize with operations o.
ExecStatus prop_pow_plus_bnd(Space &home, VA x0, VB x1, const Ops &ops)
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Mapping integer to power.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
Domain consistent power propagator.
ModEvent inter_v(Space &home, I &i, bool depends=true)
Intersect domain with values described by i.
Post propagator for SetVar SetOpType SetVar SetRelType r
Domain consistent positive power propagator.
Gecode::IntArgs v1(4, Gecode::Int::Limits::min+4, 0, 1, Gecode::Int::Limits::max)
Integer view for integer variables.
bool assigned(void) const
Test whether view is assigned.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
PowDom(Space &home, PowDom< Ops > &p)
Constructor for cloning p.
const Gecode::ModEvent ME_INT_DOM
Domain operation has changed the domain.
PowPlusDom(Home home, VA x0, VB x1, const Ops &ops)
Constructor for posting.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
static ModEvent me(const ModEventDelta &med)
Return modification event for view type in med.
bool pos(const View &x)
Test whether x is postive.
bool me_modified(ModEvent me)
Check whether modification event me describes variable modification.
static ExecStatus post(Home home, IntView x0, IntView x1, Ops ops)
Post propagator.
ModEvent gq(Space &home, int n)
Restrict domain values to be greater or equal than n.
Post propagator for SetVar x
Propagation has not computed fixpoint.
int val(int x) const
Perform mapping.
Gecode toplevel namespace
int max(void) const
Return maximum of domain.
int val(int x) const
Perform mapping.
ValuesMapPow(const Ops &o)
Initialize with operations o.
ExecStatus prop_pow_bnd(Space &home, IntView x0, IntView x1, const Ops &ops)
int val(int x) const
Perform mapping.
PowBnd(Space &home, PowBnd &p)
Constructor for cloning p.
int ModEventDelta
Modification event deltas.
Home class for posting propagators
static PropCost binary(PropCost::Mod m)
Two variables for modifier pcm.
bool me_failed(ModEvent me)
Check whether modification event me is failed.
bool neg(const View &x)
Test whether x is negative.