43 #ifdef GECODE_HAS_SET_VARS
46 #ifdef GECODE_HAS_FLOAT_VARS
51 namespace Gecode {
namespace FlatZinc {
60 std::map<std::string,poster>::iterator
i = r.find(ce.
id);
63 std::string(
"Constraint ")+ce.
id+
" not found");
65 i->second(s, ce, ce.
ann);
71 r[
"gecode_" + id] =
p;
83 void p_distinctOffset(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
86 AST::Array* offs = ce.args->a[0]->getArray();
88 for (
int i=offs->
a.size();
i--; ) {
89 oa[
i] = offs->
a[
i]->getInt();
95 void p_all_equal(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
96 IntVarArgs va = s.arg2intvarargs(ce[0]);
100 void p_int_CMP(FlatZincSpace& s,
IntRelType irt,
const ConExpr& ce,
102 if (ce[0]->isIntVar()) {
103 if (ce[1]->isIntVar()) {
104 rel(s, s.arg2IntVar(ce[0]), irt, s.arg2IntVar(ce[1]),
107 rel(s, s.arg2IntVar(ce[0]), irt, ce[1]->getInt(), s.ann2ipl(ann));
110 rel(s, s.arg2IntVar(ce[1]),
swap(irt), ce[0]->getInt(),
114 void p_int_eq(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
115 p_int_CMP(s,
IRT_EQ, ce, ann);
117 void p_int_ne(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
118 p_int_CMP(s,
IRT_NQ, ce, ann);
120 void p_int_ge(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
121 p_int_CMP(s,
IRT_GQ, ce, ann);
123 void p_int_gt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
124 p_int_CMP(s,
IRT_GR, ce, ann);
126 void p_int_le(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
127 p_int_CMP(s,
IRT_LQ, ce, ann);
129 void p_int_lt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
130 p_int_CMP(s,
IRT_LE, ce, ann);
133 const ConExpr& ce, AST::Node* ann) {
134 if (rm ==
RM_EQV && ce[2]->isBool()) {
135 if (ce[2]->getBool()) {
136 p_int_CMP(s, irt, ce, ann);
138 p_int_CMP(s,
neg(irt), ce, ann);
142 if (ce[0]->isIntVar()) {
143 if (ce[1]->isIntVar()) {
144 rel(s, s.arg2IntVar(ce[0]), irt, s.arg2IntVar(ce[1]),
145 Reify(s.arg2BoolVar(ce[2]), rm), s.ann2ipl(ann));
147 rel(s, s.arg2IntVar(ce[0]), irt, ce[1]->getInt(),
148 Reify(s.arg2BoolVar(ce[2]), rm), s.ann2ipl(ann));
151 rel(s, s.arg2IntVar(ce[1]),
swap(irt), ce[0]->getInt(),
152 Reify(s.arg2BoolVar(ce[2]), rm), s.ann2ipl(ann));
157 void p_int_eq_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
160 void p_int_ne_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
163 void p_int_ge_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
166 void p_int_gt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
169 void p_int_le_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
172 void p_int_lt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
176 void p_int_eq_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
179 void p_int_ne_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
182 void p_int_ge_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
185 void p_int_gt_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
188 void p_int_le_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
191 void p_int_lt_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
196 void p_int_lin_CMP(FlatZincSpace& s,
IntRelType irt,
const ConExpr& ce,
198 IntArgs ia = s.arg2intargs(ce[0]);
200 if (s.isBoolArray(ce[1],singleIntVar)) {
201 if (singleIntVar != -1) {
202 if (
std::abs(ia[singleIntVar]) == 1 && ce[2]->getInt() == 0) {
203 IntVar siv = s.arg2IntVar(ce[1]->getArray()->
a[singleIntVar]);
204 BoolVarArgs iv = s.arg2boolvarargs(ce[1], 0, singleIntVar);
205 IntArgs ia_tmp(ia.size()-1);
207 for (
int i=0;
i<ia.
size();
i++) {
208 if (
i != singleIntVar)
209 ia_tmp[
count++] = ia[singleIntVar] == -1 ? ia[
i] : -ia[
i];
212 linear(s, ia_tmp, iv,
t, siv, s.ann2ipl(ann));
214 IntVarArgs iv = s.arg2intvarargs(ce[1]);
215 linear(s, ia, iv, irt, ce[2]->getInt(), s.ann2ipl(ann));
218 BoolVarArgs iv = s.arg2boolvarargs(ce[1]);
219 linear(s, ia, iv, irt, ce[2]->getInt(), s.ann2ipl(ann));
222 IntVarArgs iv = s.arg2intvarargs(ce[1]);
223 linear(s, ia, iv, irt, ce[2]->getInt(), s.ann2ipl(ann));
227 const ConExpr& ce, AST::Node* ann) {
228 if (rm ==
RM_EQV && ce[2]->isBool()) {
229 if (ce[2]->getBool()) {
230 p_int_lin_CMP(s, irt, ce, ann);
232 p_int_lin_CMP(s,
neg(irt), ce, ann);
236 IntArgs ia = s.arg2intargs(ce[0]);
238 if (s.isBoolArray(ce[1],singleIntVar)) {
239 if (singleIntVar != -1) {
240 if (
std::abs(ia[singleIntVar]) == 1 && ce[2]->getInt() == 0) {
241 IntVar siv = s.arg2IntVar(ce[1]->getArray()->
a[singleIntVar]);
242 BoolVarArgs iv = s.arg2boolvarargs(ce[1], 0, singleIntVar);
243 IntArgs ia_tmp(ia.size()-1);
245 for (
int i=0;
i<ia.
size();
i++) {
246 if (
i != singleIntVar)
247 ia_tmp[
count++] = ia[singleIntVar] == -1 ? ia[
i] : -ia[
i];
250 linear(s, ia_tmp, iv,
t, siv, Reify(s.arg2BoolVar(ce[3]), rm),
253 IntVarArgs iv = s.arg2intvarargs(ce[1]);
254 linear(s, ia, iv, irt, ce[2]->getInt(),
255 Reify(s.arg2BoolVar(ce[3]), rm), s.ann2ipl(ann));
258 BoolVarArgs iv = s.arg2boolvarargs(ce[1]);
259 linear(s, ia, iv, irt, ce[2]->getInt(),
260 Reify(s.arg2BoolVar(ce[3]), rm), s.ann2ipl(ann));
263 IntVarArgs iv = s.arg2intvarargs(ce[1]);
264 linear(s, ia, iv, irt, ce[2]->getInt(),
265 Reify(s.arg2BoolVar(ce[3]), rm),
269 void p_int_lin_eq(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
270 p_int_lin_CMP(s,
IRT_EQ, ce, ann);
272 void p_int_lin_eq_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
275 void p_int_lin_eq_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
278 void p_int_lin_ne(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
279 p_int_lin_CMP(s,
IRT_NQ, ce, ann);
281 void p_int_lin_ne_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
284 void p_int_lin_ne_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
287 void p_int_lin_le(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
288 p_int_lin_CMP(s,
IRT_LQ, ce, ann);
290 void p_int_lin_le_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
293 void p_int_lin_le_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
296 void p_int_lin_lt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
297 p_int_lin_CMP(s,
IRT_LE, ce, ann);
299 void p_int_lin_lt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
302 void p_int_lin_lt_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
305 void p_int_lin_ge(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
306 p_int_lin_CMP(s,
IRT_GQ, ce, ann);
308 void p_int_lin_ge_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
311 void p_int_lin_ge_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
314 void p_int_lin_gt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
315 p_int_lin_CMP(s,
IRT_GR, ce, ann);
317 void p_int_lin_gt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
320 void p_int_lin_gt_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
324 void p_bool_lin_CMP(FlatZincSpace& s,
IntRelType irt,
const ConExpr& ce,
326 IntArgs ia = s.arg2intargs(ce[0]);
327 BoolVarArgs iv = s.arg2boolvarargs(ce[1]);
328 if (ce[2]->isIntVar())
329 linear(s, ia, iv, irt, s.iv[ce[2]->getIntVar()], s.ann2ipl(ann));
331 linear(s, ia, iv, irt, ce[2]->getInt(), s.ann2ipl(ann));
334 const ConExpr& ce, AST::Node* ann) {
335 if (rm ==
RM_EQV && ce[2]->isBool()) {
336 if (ce[2]->getBool()) {
337 p_bool_lin_CMP(s, irt, ce, ann);
339 p_bool_lin_CMP(s,
neg(irt), ce, ann);
343 IntArgs ia = s.arg2intargs(ce[0]);
344 BoolVarArgs iv = s.arg2boolvarargs(ce[1]);
345 if (ce[2]->isIntVar())
346 linear(s, ia, iv, irt, s.iv[ce[2]->getIntVar()],
347 Reify(s.arg2BoolVar(ce[3]), rm),
350 linear(s, ia, iv, irt, ce[2]->getInt(),
351 Reify(s.arg2BoolVar(ce[3]), rm),
354 void p_bool_lin_eq(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
355 p_bool_lin_CMP(s,
IRT_EQ, ce, ann);
357 void p_bool_lin_eq_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
361 void p_bool_lin_eq_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
365 void p_bool_lin_ne(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
366 p_bool_lin_CMP(s,
IRT_NQ, ce, ann);
368 void p_bool_lin_ne_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
372 void p_bool_lin_ne_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
376 void p_bool_lin_le(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
377 p_bool_lin_CMP(s,
IRT_LQ, ce, ann);
379 void p_bool_lin_le_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
383 void p_bool_lin_le_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
387 void p_bool_lin_lt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
389 p_bool_lin_CMP(s,
IRT_LE, ce, ann);
391 void p_bool_lin_lt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
395 void p_bool_lin_lt_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
399 void p_bool_lin_ge(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
400 p_bool_lin_CMP(s,
IRT_GQ, ce, ann);
402 void p_bool_lin_ge_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
406 void p_bool_lin_ge_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
410 void p_bool_lin_gt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
411 p_bool_lin_CMP(s,
IRT_GR, ce, ann);
413 void p_bool_lin_gt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
417 void p_bool_lin_gt_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
424 void p_int_plus(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
425 if (!ce[0]->isIntVar()) {
426 rel(s, ce[0]->getInt() + s.arg2IntVar(ce[1])
427 == s.arg2IntVar(ce[2]), s.ann2ipl(ann));
428 }
else if (!ce[1]->isIntVar()) {
429 rel(s, s.arg2IntVar(ce[0]) + ce[1]->getInt()
430 == s.arg2IntVar(ce[2]), s.ann2ipl(ann));
431 }
else if (!ce[2]->isIntVar()) {
432 rel(s, s.arg2IntVar(ce[0]) + s.arg2IntVar(ce[1])
433 == ce[2]->getInt(), s.ann2ipl(ann));
435 rel(s, s.arg2IntVar(ce[0]) + s.arg2IntVar(ce[1])
436 == s.arg2IntVar(ce[2]), s.ann2ipl(ann));
440 void p_int_minus(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
441 if (!ce[0]->isIntVar()) {
442 rel(s, ce[0]->getInt() - s.arg2IntVar(ce[1])
443 == s.arg2IntVar(ce[2]), s.ann2ipl(ann));
444 }
else if (!ce[1]->isIntVar()) {
445 rel(s, s.arg2IntVar(ce[0]) - ce[1]->getInt()
446 == s.arg2IntVar(ce[2]), s.ann2ipl(ann));
447 }
else if (!ce[2]->isIntVar()) {
448 rel(s, s.arg2IntVar(ce[0]) - s.arg2IntVar(ce[1])
449 == ce[2]->getInt(), s.ann2ipl(ann));
451 rel(s, s.arg2IntVar(ce[0]) - s.arg2IntVar(ce[1])
452 == s.arg2IntVar(ce[2]), s.ann2ipl(ann));
456 void p_int_times(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
457 IntVar x0 = s.arg2IntVar(ce[0]);
458 IntVar x1 = s.arg2IntVar(ce[1]);
459 IntVar x2 = s.arg2IntVar(ce[2]);
460 mult(s, x0, x1, x2, s.ann2ipl(ann));
462 void p_int_pow(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
463 IntVar x0 = s.arg2IntVar(ce[0]);
464 IntVar x2 = s.arg2IntVar(ce[2]);
465 pow(s, x0, ce[1]->getInt(), x2, s.ann2ipl(ann));
467 void p_int_div(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
468 IntVar x0 = s.arg2IntVar(ce[0]);
469 IntVar x1 = s.arg2IntVar(ce[1]);
470 IntVar x2 = s.arg2IntVar(ce[2]);
471 div(s,x0,x1,x2, s.ann2ipl(ann));
473 void p_int_mod(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
474 IntVar x0 = s.arg2IntVar(ce[0]);
475 IntVar x1 = s.arg2IntVar(ce[1]);
476 IntVar x2 = s.arg2IntVar(ce[2]);
477 mod(s,x0,x1,x2, s.ann2ipl(ann));
480 void p_int_min(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
481 IntVar x0 = s.arg2IntVar(ce[0]);
482 IntVar x1 = s.arg2IntVar(ce[1]);
483 IntVar x2 = s.arg2IntVar(ce[2]);
484 min(s, x0, x1, x2, s.ann2ipl(ann));
486 void p_int_max(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
487 IntVar x0 = s.arg2IntVar(ce[0]);
488 IntVar x1 = s.arg2IntVar(ce[1]);
489 IntVar x2 = s.arg2IntVar(ce[2]);
490 max(s, x0, x1, x2, s.ann2ipl(ann));
492 void p_int_negate(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
493 IntVar x0 = s.arg2IntVar(ce[0]);
494 IntVar x1 = s.arg2IntVar(ce[1]);
495 rel(s, x0 == -x1, s.ann2ipl(ann));
499 void p_bool_CMP(FlatZincSpace& s,
IntRelType irt,
const ConExpr& ce,
501 rel(s, s.arg2BoolVar(ce[0]), irt, s.arg2BoolVar(ce[1]),
505 const ConExpr& ce, AST::Node* ann) {
506 rel(s, s.arg2BoolVar(ce[0]), irt, s.arg2BoolVar(ce[1]),
507 Reify(s.arg2BoolVar(ce[2]), rm), s.ann2ipl(ann));
509 void p_bool_eq(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
510 p_bool_CMP(s,
IRT_EQ, ce, ann);
512 void p_bool_eq_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
515 void p_bool_eq_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
518 void p_bool_ne(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
519 p_bool_CMP(s,
IRT_NQ, ce, ann);
521 void p_bool_ne_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
524 void p_bool_ne_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
527 void p_bool_ge(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
528 p_bool_CMP(s,
IRT_GQ, ce, ann);
530 void p_bool_ge_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
533 void p_bool_ge_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
536 void p_bool_le(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
537 p_bool_CMP(s,
IRT_LQ, ce, ann);
539 void p_bool_le_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
542 void p_bool_le_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
545 void p_bool_gt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
546 p_bool_CMP(s,
IRT_GR, ce, ann);
548 void p_bool_gt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
551 void p_bool_gt_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
554 void p_bool_lt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
555 p_bool_CMP(s,
IRT_LE, ce, ann);
557 void p_bool_lt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
560 void p_bool_lt_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
564 #define BOOL_OP(op) \
565 BoolVar b0 = s.arg2BoolVar(ce[0]); \
566 BoolVar b1 = s.arg2BoolVar(ce[1]); \
567 if (ce[2]->isBool()) { \
568 rel(s, b0, op, b1, ce[2]->getBool(), s.ann2ipl(ann)); \
570 rel(s, b0, op, b1, s.bv[ce[2]->getBoolVar()], s.ann2ipl(ann)); \
573 #define BOOL_ARRAY_OP(op) \
574 BoolVarArgs bv = s.arg2boolvarargs(ce[0]); \
575 if (ce.size()==1) { \
576 rel(s, op, bv, 1, s.ann2ipl(ann)); \
577 } else if (ce[1]->isBool()) { \
578 rel(s, op, bv, ce[1]->getBool(), s.ann2ipl(ann)); \
580 rel(s, op, bv, s.bv[ce[1]->getBoolVar()], s.ann2ipl(ann)); \
583 void p_bool_or(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
586 void p_bool_or_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
587 BoolVar b0 = s.arg2BoolVar(ce[0]);
588 BoolVar
b1 = s.arg2BoolVar(ce[1]);
589 BoolVar
b2 = s.arg2BoolVar(ce[2]);
593 void p_bool_and(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
596 void p_bool_and_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
597 BoolVar b0 = s.arg2BoolVar(ce[0]);
598 BoolVar
b1 = s.arg2BoolVar(ce[1]);
599 BoolVar
b2 = s.arg2BoolVar(ce[2]);
603 void p_array_bool_and(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
607 void p_array_bool_and_imp(FlatZincSpace& s,
const ConExpr& ce,
610 BoolVarArgs bv = s.arg2boolvarargs(ce[0]);
611 BoolVar
b1 = s.arg2BoolVar(ce[1]);
612 for (
unsigned int i=bv.
size();
i--;)
615 void p_array_bool_or(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
619 void p_array_bool_or_imp(FlatZincSpace& s,
const ConExpr& ce,
622 BoolVarArgs bv = s.arg2boolvarargs(ce[0]);
623 BoolVar
b1 = s.arg2BoolVar(ce[1]);
626 void p_array_bool_xor(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann)
630 void p_array_bool_xor_imp(FlatZincSpace& s,
const ConExpr& ce,
633 BoolVarArgs bv = s.arg2boolvarargs(ce[0]);
636 rel(s, s.arg2BoolVar(ce[1]),
BOT_IMP, tmp, 1);
638 void p_array_bool_clause(FlatZincSpace& s,
const ConExpr& ce,
640 BoolVarArgs bvp = s.arg2boolvarargs(ce[0]);
641 BoolVarArgs bvn = s.arg2boolvarargs(ce[1]);
644 void p_array_bool_clause_reif(FlatZincSpace& s,
const ConExpr& ce,
646 BoolVarArgs bvp = s.arg2boolvarargs(ce[0]);
647 BoolVarArgs bvn = s.arg2boolvarargs(ce[1]);
648 BoolVar b0 = s.arg2BoolVar(ce[2]);
651 void p_array_bool_clause_imp(FlatZincSpace& s,
const ConExpr& ce,
653 BoolVarArgs bvp = s.arg2boolvarargs(ce[0]);
654 BoolVarArgs bvn = s.arg2boolvarargs(ce[1]);
655 BoolVar b0 = s.arg2BoolVar(ce[2]);
658 void p_bool_xor(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
661 void p_bool_xor_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
662 BoolVar b0 = s.arg2BoolVar(ce[0]);
663 BoolVar
b1 = s.arg2BoolVar(ce[1]);
664 BoolVar
b2 = s.arg2BoolVar(ce[2]);
670 void p_bool_l_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
671 BoolVar b0 = s.arg2BoolVar(ce[0]);
672 BoolVar
b1 = s.arg2BoolVar(ce[1]);
673 if (ce[2]->isBool()) {
674 rel(s,
b1,
BOT_IMP, b0, ce[2]->getBool(), s.ann2ipl(ann));
676 rel(s,
b1,
BOT_IMP, b0, s.bv[ce[2]->getBoolVar()], s.ann2ipl(ann));
679 void p_bool_r_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
682 void p_bool_not(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
683 BoolVar x0 = s.arg2BoolVar(ce[0]);
684 BoolVar x1 = s.arg2BoolVar(ce[1]);
689 void p_array_int_element(FlatZincSpace& s,
const ConExpr& ce,
691 bool isConstant =
true;
692 AST::Array*
a = ce[1]->getArray();
693 for (
int i=
a->a.size();
i--;) {
694 if (!
a->a[
i]->isInt()) {
699 IntVar selector = s.arg2IntVar(ce[0]);
700 rel(s, selector > 0);
703 element(s, sia, selector, s.arg2IntVar(ce[2]), s.ann2ipl(ann));
705 IntVarArgs iv = s.arg2intvarargs(ce[1], 1);
706 element(s, iv, selector, s.arg2IntVar(ce[2]), s.ann2ipl(ann));
709 void p_array_bool_element(FlatZincSpace& s,
const ConExpr& ce,
711 bool isConstant =
true;
712 AST::Array*
a = ce[1]->getArray();
713 for (
int i=
a->a.size();
i--;) {
714 if (!
a->a[
i]->isBool()) {
719 IntVar selector = s.arg2IntVar(ce[0]);
720 rel(s, selector > 0);
723 element(s, sia, selector, s.arg2BoolVar(ce[2]), s.ann2ipl(ann));
725 BoolVarArgs iv = s.arg2boolvarargs(ce[1], 1);
726 element(s, iv, selector, s.arg2BoolVar(ce[2]), s.ann2ipl(ann));
731 void p_bool2int(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
732 BoolVar x0 = s.arg2BoolVar(ce[0]);
733 IntVar x1 = s.arg2IntVar(ce[1]);
734 if (ce[0]->isBoolVar() && ce[1]->isIntVar()) {
735 s.aliasBool2Int(ce[1]->getIntVar(), ce[0]->getBoolVar());
737 channel(s, x0, x1, s.ann2ipl(ann));
740 void p_int_in(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
741 IntSet
d = s.arg2intset(ce[1]);
742 if (ce[0]->isBoolVar()) {
744 Iter::Ranges::Singleton sr(0,1);
745 Iter::Ranges::Inter<IntSetRanges,Iter::Ranges::Singleton>
i(dr,sr);
747 if (d01.size() == 0) {
750 rel(s, s.arg2BoolVar(ce[0]),
IRT_GQ, d01.min());
751 rel(s, s.arg2BoolVar(ce[0]),
IRT_LQ, d01.max());
754 dom(s, s.arg2IntVar(ce[0]),
d);
757 void p_int_in_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
758 IntSet
d = s.arg2intset(ce[1]);
759 if (ce[0]->isBoolVar()) {
761 Iter::Ranges::Singleton sr(0,1);
762 Iter::Ranges::Inter<IntSetRanges,Iter::Ranges::Singleton>
i(dr,sr);
764 if (d01.size() == 0) {
765 rel(s, s.arg2BoolVar(ce[2]) == 0);
766 }
else if (d01.max() == 0) {
767 rel(s, s.arg2BoolVar(ce[2]) == !s.arg2BoolVar(ce[0]));
768 }
else if (d01.min() == 1) {
769 rel(s, s.arg2BoolVar(ce[2]) == s.arg2BoolVar(ce[0]));
771 rel(s, s.arg2BoolVar(ce[2]) == 1);
774 dom(s, s.arg2IntVar(ce[0]),
d, s.arg2BoolVar(ce[2]));
777 void p_int_in_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
778 IntSet
d = s.arg2intset(ce[1]);
779 if (ce[0]->isBoolVar()) {
781 Iter::Ranges::Singleton sr(0,1);
782 Iter::Ranges::Inter<IntSetRanges,Iter::Ranges::Singleton>
i(dr,sr);
784 if (d01.size() == 0) {
785 rel(s, s.arg2BoolVar(ce[2]) == 0);
786 }
else if (d01.max() == 0) {
787 rel(s, s.arg2BoolVar(ce[2]) >> !s.arg2BoolVar(ce[0]));
788 }
else if (d01.min() == 1) {
789 rel(s, s.arg2BoolVar(ce[2]) >> s.arg2BoolVar(ce[0]));
792 dom(s, s.arg2IntVar(ce[0]),
d, Reify(s.arg2BoolVar(ce[2]),
RM_IMP));
798 void p_abs(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
799 IntVar x0 = s.arg2IntVar(ce[0]);
800 IntVar x1 = s.arg2IntVar(ce[1]);
801 abs(s, x0, x1, s.ann2ipl(ann));
804 void p_array_int_lt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
805 IntVarArgs iv0 = s.arg2intvarargs(ce[0]);
806 IntVarArgs iv1 = s.arg2intvarargs(ce[1]);
807 rel(s, iv0,
IRT_LE, iv1, s.ann2ipl(ann));
810 void p_array_int_lq(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
811 IntVarArgs iv0 = s.arg2intvarargs(ce[0]);
812 IntVarArgs iv1 = s.arg2intvarargs(ce[1]);
813 rel(s, iv0,
IRT_LQ, iv1, s.ann2ipl(ann));
816 void p_array_bool_lt(FlatZincSpace& s,
const ConExpr& ce,
818 BoolVarArgs bv0 = s.arg2boolvarargs(ce[0]);
819 BoolVarArgs bv1 = s.arg2boolvarargs(ce[1]);
820 rel(s, bv0,
IRT_LE, bv1, s.ann2ipl(ann));
823 void p_array_bool_lq(FlatZincSpace& s,
const ConExpr& ce,
825 BoolVarArgs bv0 = s.arg2boolvarargs(ce[0]);
826 BoolVarArgs bv1 = s.arg2boolvarargs(ce[1]);
827 rel(s, bv0,
IRT_LQ, bv1, s.ann2ipl(ann));
830 void p_count(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
831 IntVarArgs iv = s.arg2intvarargs(ce[0]);
832 if (!ce[1]->isIntVar()) {
833 if (!ce[2]->isIntVar()) {
834 count(s, iv, ce[1]->getInt(),
IRT_EQ, ce[2]->getInt(),
837 count(s, iv, ce[1]->getInt(),
IRT_EQ, s.arg2IntVar(ce[2]),
840 }
else if (!ce[2]->isIntVar()) {
841 count(s, iv, s.arg2IntVar(ce[1]),
IRT_EQ, ce[2]->getInt(),
844 count(s, iv, s.arg2IntVar(ce[1]),
IRT_EQ, s.arg2IntVar(ce[2]),
849 void p_count_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
850 IntVarArgs iv = s.arg2intvarargs(ce[0]);
851 IntVar
x = s.arg2IntVar(ce[1]);
852 IntVar
y = s.arg2IntVar(ce[2]);
853 BoolVar
b = s.arg2BoolVar(ce[3]);
858 void p_count_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
859 IntVarArgs iv = s.arg2intvarargs(ce[0]);
860 IntVar
x = s.arg2IntVar(ce[1]);
861 IntVar
y = s.arg2IntVar(ce[2]);
862 BoolVar
b = s.arg2BoolVar(ce[3]);
869 FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
870 IntVarArgs iv = s.arg2intvarargs(ce[1]);
871 count(s, iv, ce[2]->getInt(), irt, ce[0]->getInt(), s.ann2ipl(ann));
874 void p_at_most(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
875 count_rel(
IRT_LQ, s, ce, ann);
878 void p_at_least(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
879 count_rel(
IRT_GQ, s, ce, ann);
882 void p_bin_packing_load(FlatZincSpace& s,
const ConExpr& ce,
884 int minIdx = ce[3]->getInt();
885 IntVarArgs load = s.arg2intvarargs(ce[0]);
887 IntVarArgs bin = s.arg2intvarargs(ce[1]);
888 for (
int i=bin.
size();
i--;)
889 rel(s, bin[
i] >= minIdx);
891 for (
int i=minIdx;
i--;)
893 }
else if (minIdx < 0) {
894 IntVarArgs bin2(bin.size());
895 for (
int i=bin.
size();
i--;)
896 bin2[
i] =
expr(s, bin[
i]-minIdx, s.ann2ipl(ann));
900 IntArgs sizes = s.arg2intargs(ce[2]);
902 IntVarArgs allvars =
l + bin;
904 binpacking(s, allvars.slice(0,1,
l.size()), allvars.slice(
l.size(),1,bin.size()),
905 sizes, s.ann2ipl(ann));
908 void p_global_cardinality(FlatZincSpace& s,
const ConExpr& ce,
910 IntVarArgs iv0 = s.arg2intvarargs(ce[0]);
911 IntArgs cover = s.arg2intargs(ce[1]);
912 IntVarArgs iv1 = s.arg2intvarargs(ce[2]);
915 IntSet cover_s(cover);
916 IntSetRanges cover_r(cover_s);
917 IntVarRanges* iv0_ri = re.alloc<IntVarRanges>(iv0.size());
918 for (
int i=iv0.
size();
i--;)
919 iv0_ri[
i] = IntVarRanges(iv0[
i]);
920 Iter::Ranges::NaryUnion iv0_r(re,iv0_ri,iv0.size());
921 Iter::Ranges::Diff<Iter::Ranges::NaryUnion,IntSetRanges>
922 extra_r(iv0_r,cover_r);
923 Iter::Ranges::ToValues<Iter::Ranges::Diff<
924 Iter::Ranges::NaryUnion,IntSetRanges> > extra(extra_r);
925 for (; extra(); ++extra) {
926 cover << extra.val();
927 iv1 << IntVar(s,0,iv0.size());
933 IntVarArgs allvars = iv0+iv1;
935 count(s, allvars.slice(0,1,iv0.size()),
936 allvars.slice(iv0.size(),1,iv1.size()),
940 count(s, iv0, iv1, cover, ipl);
944 void p_global_cardinality_closed(FlatZincSpace& s,
const ConExpr& ce,
946 IntVarArgs iv0 = s.arg2intvarargs(ce[0]);
947 IntArgs cover = s.arg2intargs(ce[1]);
948 IntVarArgs iv1 = s.arg2intvarargs(ce[2]);
953 IntVarArgs allvars = iv0+iv1;
955 count(s, allvars.slice(0,1,iv0.size()),
956 allvars.slice(iv0.size(),1,iv1.size()),
960 count(s, iv0, iv1, cover, ipl);
964 void p_global_cardinality_low_up(FlatZincSpace& s,
const ConExpr& ce,
966 IntVarArgs
x = s.arg2intvarargs(ce[0]);
967 IntArgs cover = s.arg2intargs(ce[1]);
969 IntArgs lbound = s.arg2intargs(ce[2]);
970 IntArgs ubound = s.arg2intargs(ce[3]);
972 for (
int i=cover.
size();
i--;)
973 y[
i] = IntSet(lbound[
i],ubound[
i]);
975 IntSet cover_s(cover);
977 IntVarRanges* xrs = re.alloc<IntVarRanges>(
x.size());
978 for (
int i=
x.size();
i--;)
980 Iter::Ranges::NaryUnion
u(re, xrs,
x.size());
981 Iter::Ranges::ToValues<Iter::Ranges::NaryUnion> uv(
u);
983 if (!cover_s.in(uv.val())) {
985 y << IntSet(0,
x.size());
995 void p_global_cardinality_low_up_closed(FlatZincSpace& s,
998 IntVarArgs
x = s.arg2intvarargs(ce[0]);
999 IntArgs cover = s.arg2intargs(ce[1]);
1001 IntArgs lbound = s.arg2intargs(ce[2]);
1002 IntArgs ubound = s.arg2intargs(ce[3]);
1004 for (
int i=cover.
size();
i--;)
1005 y[
i] = IntSet(lbound[
i],ubound[
i]);
1013 void p_minimum(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1014 IntVarArgs iv = s.arg2intvarargs(ce[1]);
1015 min(s, iv, s.arg2IntVar(ce[0]), s.ann2ipl(ann));
1018 void p_maximum(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1019 IntVarArgs iv = s.arg2intvarargs(ce[1]);
1020 max(s, iv, s.arg2IntVar(ce[0]), s.ann2ipl(ann));
1023 void p_minimum_arg(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1024 IntVarArgs iv = s.arg2intvarargs(ce[0]);
1025 int offset = ce[1]->getInt();
1026 argmin(s, iv, offset, s.arg2IntVar(ce[2]),
true, s.ann2ipl(ann));
1029 void p_maximum_arg(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1030 IntVarArgs iv = s.arg2intvarargs(ce[0]);
1031 int offset = ce[1]->getInt();
1032 argmax(s, iv, offset, s.arg2IntVar(ce[2]),
true, s.ann2ipl(ann));
1035 void p_minimum_arg_bool(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1036 BoolVarArgs bv = s.arg2boolvarargs(ce[0]);
1037 int offset = ce[1]->getInt();
1038 argmin(s, bv, offset, s.arg2IntVar(ce[2]),
true, s.ann2ipl(ann));
1041 void p_maximum_arg_bool(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1042 BoolVarArgs bv = s.arg2boolvarargs(ce[0]);
1043 int offset = ce[1]->getInt();
1044 argmax(s, bv, offset, s.arg2IntVar(ce[2]),
true, s.ann2ipl(ann));
1047 void p_regular(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1048 IntVarArgs iv = s.arg2intvarargs(ce[0]);
1049 int q = ce[1]->getInt();
1050 int symbols = ce[2]->getInt();
1051 IntArgs
d = s.arg2intargs(ce[3]);
1052 int q0 = ce[4]->getInt();
1055 for (
int i=1;
i<=q;
i++) {
1056 for (
int j=1; j<=symbols; j++) {
1057 if (
d[(
i-1)*symbols+(j-1)] > 0)
1063 DFA::Transition*
t = re.alloc<DFA::Transition>(noOfTrans+1);
1065 for (
int i=1;
i<=q;
i++) {
1066 for (
int j=1; j<=symbols; j++) {
1067 if (
d[(
i-1)*symbols+(j-1)] > 0) {
1068 t[noOfTrans].i_state =
i;
1069 t[noOfTrans].symbol = j;
1070 t[noOfTrans].o_state =
d[(
i-1)*symbols+(j-1)];
1075 t[noOfTrans].i_state = -1;
1078 AST::SetLit* sl = ce[5]->getSet();
1081 f = static_cast<int*>(
heap.
ralloc(
sizeof(
int)*(sl->max-sl->min+2)));
1082 for (
int i=sl->min; i<=sl->
max;
i++)
1084 f[sl->max-sl->min+1] = -1;
1086 f = static_cast<int*>(
heap.
ralloc(
sizeof(
int)*(sl->s.size()+1)));
1087 for (
int j=sl->s.size(); j--; )
1089 f[sl->s.size()] = -1;
1095 extensional(s, iv, s.getSharedDFA(dfa), s.ann2ipl(ann));
1099 p_sort(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1100 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1101 IntVarArgs
y = s.arg2intvarargs(ce[1]);
1102 IntVarArgs xy(
x.size()+
y.size());
1103 for (
int i=
x.size();
i--;)
1105 for (
int i=
y.size();
i--;)
1106 xy[
i+
x.size()] =
y[
i];
1108 for (
int i=
x.size();
i--;)
1110 for (
int i=
y.size();
i--;)
1111 y[
i] = xy[
i+
x.size()];
1116 p_inverse_offsets(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1117 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1119 int xoff = ce[1]->getInt();
1120 IntVarArgs
y = s.arg2intvarargs(ce[2]);
1122 int yoff = ce[3]->getInt();
1123 channel(s,
x, xoff,
y, yoff, s.ann2ipl(ann));
1127 p_increasing_int(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1128 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1133 p_increasing_bool(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1134 BoolVarArgs
x = s.arg2boolvarargs(ce[0]);
1139 p_decreasing_int(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1140 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1145 p_decreasing_bool(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1146 BoolVarArgs
x = s.arg2boolvarargs(ce[0]);
1151 p_table_int(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1152 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1153 IntArgs tuples = s.arg2intargs(ce[1]);
1154 TupleSet ts = s.arg2tupleset(tuples,
x.size());
1159 p_table_int_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1160 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1161 IntArgs tuples = s.arg2intargs(ce[1]);
1162 TupleSet ts = s.arg2tupleset(tuples,
x.size());
1167 p_table_int_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1168 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1169 IntArgs tuples = s.arg2intargs(ce[1]);
1170 TupleSet ts = s.arg2tupleset(tuples,
x.size());
1175 p_table_bool(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1176 BoolVarArgs
x = s.arg2boolvarargs(ce[0]);
1177 IntArgs tuples = s.arg2boolargs(ce[1]);
1178 TupleSet ts = s.arg2tupleset(tuples,
x.size());
1183 p_table_bool_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1184 BoolVarArgs
x = s.arg2boolvarargs(ce[0]);
1185 IntArgs tuples = s.arg2boolargs(ce[1]);
1186 TupleSet ts = s.arg2tupleset(tuples,
x.size());
1191 p_table_bool_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1192 BoolVarArgs
x = s.arg2boolvarargs(ce[0]);
1193 IntArgs tuples = s.arg2boolargs(ce[1]);
1194 TupleSet ts = s.arg2tupleset(tuples,
x.size());
1198 void p_cumulative_opt(FlatZincSpace& s,
const ConExpr& ce,
1200 IntVarArgs start = s.arg2intvarargs(ce[0]);
1201 IntArgs duration = s.arg2intargs(ce[1]);
1202 IntArgs height = s.arg2intargs(ce[2]);
1203 BoolVarArgs
opt = s.arg2boolvarargs(ce[3]);
1204 int bound = ce[4]->getInt();
1206 cumulative(s,bound,start,duration,height,
opt,s.ann2ipl(ann));
1209 void p_cumulatives(FlatZincSpace& s,
const ConExpr& ce,
1211 IntVarArgs start = s.arg2intvarargs(ce[0]);
1212 IntVarArgs duration = s.arg2intvarargs(ce[1]);
1213 IntVarArgs height = s.arg2intvarargs(ce[2]);
1214 int n = start.size();
1215 IntVar bound = s.arg2IntVar(ce[3]);
1221 rel(s, height[0] <= bound);
1227 for (
int i=2;
i<
n;
i++) {
1228 if (height[
i].
min() < minHeight) {
1229 minHeight2 = minHeight;
1230 minHeight = height[
i].min();
1231 }
else if (height[
i].
min() < minHeight2) {
1232 minHeight2 = height[
i].min();
1236 (minHeight > bound.max()/2) ||
1237 (minHeight2 > bound.max()/2 && minHeight+minHeight2>bound.max());
1239 rel(s, bound >=
max(height));
1241 if (duration.assigned()) {
1242 IntArgs durationI(
n);
1244 durationI[
i] = duration[
i].val();
1246 unary(s,start,durationI);
1250 end[
i] =
expr(s,start[
i]+duration[
i]);
1252 unary(s,start,duration,end);
1254 }
else if (height.assigned()) {
1257 heightI[
i] = height[
i].val();
1258 if (duration.assigned()) {
1259 IntArgs durationI(
n);
1261 durationI[
i] = duration[
i].val();
1262 cumulative(s, bound, start, durationI, heightI);
1265 for (
int i =
n;
i--; )
1266 end[
i] =
expr(s,start[
i]+duration[
i]);
1267 cumulative(s, bound, start, duration, end, heightI);
1269 }
else if (bound.assigned()) {
1271 IntArgs limit({bound.val()});
1274 end[
i] =
expr(s,start[
i]+duration[
i]);
1275 cumulatives(s, machine, start, duration, end, height, limit,
true,
1280 IntVarArgs end(start.size());
1281 for (
int i = start.
size();
i--; ) {
1284 end[
i] =
expr(s, start[
i] + duration[
i]);
1286 for (
int time =
min; time <
max; ++time) {
1287 IntVarArgs
x(start.size());
1288 for (
int i = start.
size();
i--; ) {
1289 IntVar overlaps =
channel(s,
expr(s, (start[
i] <= time) &&
1291 x[
i] =
expr(s, overlaps * height[
i]);
1298 void p_among_seq_int(FlatZincSpace& s,
const ConExpr& ce,
1300 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1301 IntSet S = s.arg2intset(ce[1]);
1302 int q = ce[2]->getInt();
1303 int l = ce[3]->getInt();
1304 int u = ce[4]->getInt();
1309 void p_among_seq_bool(FlatZincSpace& s,
const ConExpr& ce,
1311 BoolVarArgs
x = s.arg2boolvarargs(ce[0]);
1312 bool val = ce[1]->getBool();
1313 int q = ce[2]->getInt();
1314 int l = ce[3]->getInt();
1315 int u = ce[4]->getInt();
1321 void p_schedule_unary(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
1322 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1323 IntArgs
p = s.arg2intargs(ce[1]);
1328 void p_schedule_unary_optional(FlatZincSpace& s,
const ConExpr& ce,
1330 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1331 IntArgs
p = s.arg2intargs(ce[1]);
1332 BoolVarArgs m = s.arg2boolvarargs(ce[2]);
1337 void p_circuit(FlatZincSpace& s,
const ConExpr& ce, AST::Node *ann) {
1338 int off = ce[0]->getInt();
1339 IntVarArgs xv = s.arg2intvarargs(ce[1]);
1341 circuit(s,off,xv,s.ann2ipl(ann));
1343 void p_circuit_cost_array(FlatZincSpace& s,
const ConExpr& ce,
1345 IntArgs
c = s.arg2intargs(ce[0]);
1346 IntVarArgs xv = s.arg2intvarargs(ce[1]);
1347 IntVarArgs yv = s.arg2intvarargs(ce[2]);
1348 IntVar
z = s.arg2IntVar(ce[3]);
1352 void p_circuit_cost(FlatZincSpace& s,
const ConExpr& ce, AST::Node *ann) {
1353 IntArgs
c = s.arg2intargs(ce[0]);
1354 IntVarArgs xv = s.arg2intvarargs(ce[1]);
1355 IntVar
z = s.arg2IntVar(ce[2]);
1360 void p_nooverlap(FlatZincSpace& s,
const ConExpr& ce, AST::Node *ann) {
1361 IntVarArgs x0 = s.arg2intvarargs(ce[0]);
1362 IntVarArgs w = s.arg2intvarargs(ce[1]);
1363 IntVarArgs y0 = s.arg2intvarargs(ce[2]);
1364 IntVarArgs h = s.arg2intvarargs(ce[3]);
1365 if (w.assigned() && h.assigned()) {
1366 IntArgs iw(w.size());
1367 for (
int i=w.
size();
i--;)
1369 IntArgs ih(h.size());
1370 for (
int i=h.
size();
i--;)
1372 nooverlap(s,x0,iw,y0,ih,s.ann2ipl(ann));
1374 int miny = y0[0].min();
1375 int maxy = y0[0].max();
1377 for (
int i=1;
i<y0.
size();
i++) {
1382 int minx = x0[0].min();
1383 int maxx = x0[0].max();
1385 for (
int i=1;
i<x0.
size();
i++) {
1395 IntVarArgs x1(x0.size()), y1(y0.size());
1396 for (
int i=x0.
size();
i--; )
1397 x1[
i] =
expr(s, x0[
i] + w[
i]);
1398 for (
int i=y0.
size();
i--; )
1399 y1[
i] =
expr(s, y0[
i] + h[
i]);
1400 nooverlap(s,x0,w,x1,y0,h,y1,s.ann2ipl(ann));
1404 void p_precede(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1405 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1406 int p_s = ce[1]->getInt();
1407 int p_t = ce[2]->getInt();
1408 precede(s,
x,p_s,p_t,s.ann2ipl(ann));
1411 void p_nvalue(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1412 IntVarArgs
x = s.arg2intvarargs(ce[1]);
1413 if (ce[0]->isIntVar()) {
1414 IntVar
y = s.arg2IntVar(ce[0]);
1421 void p_among(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1422 IntVarArgs
x = s.arg2intvarargs(ce[1]);
1423 IntSet
v = s.arg2intset(ce[2]);
1424 if (ce[0]->isIntVar()) {
1425 IntVar
n = s.arg2IntVar(ce[0]);
1434 void p_member_int(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1435 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1436 IntVar
y = s.arg2IntVar(ce[1]);
1439 void p_member_int_reif(FlatZincSpace& s,
const ConExpr& ce,
1441 IntVarArgs
x = s.arg2intvarargs(ce[0]);
1442 IntVar
y = s.arg2IntVar(ce[1]);
1443 BoolVar
b = s.arg2BoolVar(ce[2]);
1446 void p_member_bool(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1447 BoolVarArgs
x = s.arg2boolvarargs(ce[0]);
1448 BoolVar
y = s.arg2BoolVar(ce[1]);
1451 void p_member_bool_reif(FlatZincSpace& s,
const ConExpr& ce,
1453 BoolVarArgs
x = s.arg2boolvarargs(ce[0]);
1454 BoolVar
y = s.arg2BoolVar(ce[1]);
1455 member(s,
x,
y,s.arg2BoolVar(ce[2]),s.ann2ipl(ann));
1462 registry().
add(
"all_different_offset", &p_distinctOffset);
1483 registry().
add(
"int_lin_eq_reif", &p_int_lin_eq_reif);
1484 registry().
add(
"int_lin_eq_imp", &p_int_lin_eq_imp);
1486 registry().
add(
"int_lin_ne_reif", &p_int_lin_ne_reif);
1487 registry().
add(
"int_lin_ne_imp", &p_int_lin_ne_imp);
1489 registry().
add(
"int_lin_le_reif", &p_int_lin_le_reif);
1490 registry().
add(
"int_lin_le_imp", &p_int_lin_le_imp);
1492 registry().
add(
"int_lin_lt_reif", &p_int_lin_lt_reif);
1493 registry().
add(
"int_lin_lt_imp", &p_int_lin_lt_imp);
1495 registry().
add(
"int_lin_ge_reif", &p_int_lin_ge_reif);
1496 registry().
add(
"int_lin_ge_imp", &p_int_lin_ge_imp);
1498 registry().
add(
"int_lin_gt_reif", &p_int_lin_gt_reif);
1499 registry().
add(
"int_lin_gt_imp", &p_int_lin_gt_imp);
1534 registry().
add(
"array_bool_and", &p_array_bool_and);
1535 registry().
add(
"array_bool_and_imp", &p_array_bool_and_imp);
1536 registry().
add(
"array_bool_or", &p_array_bool_or);
1537 registry().
add(
"array_bool_or_imp", &p_array_bool_or_imp);
1538 registry().
add(
"array_bool_xor", &p_array_bool_xor);
1539 registry().
add(
"array_bool_xor_imp", &p_array_bool_xor_imp);
1540 registry().
add(
"bool_clause", &p_array_bool_clause);
1541 registry().
add(
"bool_clause_reif", &p_array_bool_clause_reif);
1542 registry().
add(
"bool_clause_imp", &p_array_bool_clause_imp);
1546 registry().
add(
"array_int_element", &p_array_int_element);
1547 registry().
add(
"array_var_int_element", &p_array_int_element);
1548 registry().
add(
"array_bool_element", &p_array_bool_element);
1549 registry().
add(
"array_var_bool_element", &p_array_bool_element);
1554 #ifndef GECODE_HAS_SET_VARS
1562 registry().
add(
"array_bool_lt", &p_array_bool_lt);
1563 registry().
add(
"array_bool_lq", &p_array_bool_lq);
1569 registry().
add(
"gecode_bin_packing_load", &p_bin_packing_load);
1570 registry().
add(
"gecode_global_cardinality", &p_global_cardinality);
1571 registry().
add(
"gecode_global_cardinality_closed",
1572 &p_global_cardinality_closed);
1574 &p_global_cardinality_low_up);
1575 registry().
add(
"global_cardinality_low_up_closed",
1576 &p_global_cardinality_low_up_closed);
1579 registry().
add(
"gecode_minimum_arg_int_offset", &p_minimum_arg);
1580 registry().
add(
"gecode_maximum_arg_int_offset", &p_maximum_arg);
1581 registry().
add(
"gecode_minimum_arg_bool_offset", &p_minimum_arg_bool);
1582 registry().
add(
"gecode_maximum_arg_bool_offset", &p_maximum_arg_bool);
1586 registry().
add(
"inverse_offsets", &p_inverse_offsets);
1587 registry().
add(
"increasing_int", &p_increasing_int);
1588 registry().
add(
"increasing_bool", &p_increasing_bool);
1589 registry().
add(
"decreasing_int", &p_decreasing_int);
1590 registry().
add(
"decreasing_bool", &p_decreasing_bool);
1592 registry().
add(
"gecode_table_int_reif", &p_table_int_reif);
1593 registry().
add(
"gecode_table_int_imp", &p_table_int_imp);
1594 registry().
add(
"gecode_table_bool", &p_table_bool);
1595 registry().
add(
"gecode_table_bool_reif", &p_table_bool_reif);
1596 registry().
add(
"gecode_table_bool_imp", &p_table_bool_imp);
1598 registry().
add(
"gecode_among_seq_int", &p_among_seq_int);
1599 registry().
add(
"gecode_among_seq_bool", &p_among_seq_bool);
1608 registry().
add(
"bool_lin_eq_reif", &p_bool_lin_eq_reif);
1609 registry().
add(
"bool_lin_eq_imp", &p_bool_lin_eq_imp);
1610 registry().
add(
"bool_lin_ne_reif", &p_bool_lin_ne_reif);
1611 registry().
add(
"bool_lin_ne_imp", &p_bool_lin_ne_imp);
1612 registry().
add(
"bool_lin_le_reif", &p_bool_lin_le_reif);
1613 registry().
add(
"bool_lin_le_imp", &p_bool_lin_le_imp);
1614 registry().
add(
"bool_lin_lt_reif", &p_bool_lin_lt_reif);
1615 registry().
add(
"bool_lin_lt_imp", &p_bool_lin_lt_imp);
1616 registry().
add(
"bool_lin_ge_reif", &p_bool_lin_ge_reif);
1617 registry().
add(
"bool_lin_ge_imp", &p_bool_lin_ge_imp);
1618 registry().
add(
"bool_lin_gt_reif", &p_bool_lin_gt_reif);
1619 registry().
add(
"bool_lin_gt_imp", &p_bool_lin_gt_imp);
1621 registry().
add(
"gecode_schedule_unary", &p_schedule_unary);
1622 registry().
add(
"gecode_schedule_unary_optional", &p_schedule_unary_optional);
1623 registry().
add(
"gecode_schedule_cumulative_optional", &p_cumulative_opt);
1626 registry().
add(
"gecode_circuit_cost_array", &p_circuit_cost_array);
1627 registry().
add(
"gecode_circuit_cost", &p_circuit_cost);
1633 registry().
add(
"gecode_member_int_reif",&p_member_int_reif);
1635 registry().
add(
"gecode_member_bool_reif",&p_member_bool_reif);
1638 IntPoster __int_poster;
1640 #ifdef GECODE_HAS_SET_VARS
1642 const ConExpr& ce, AST::Node *) {
1643 rel(s, s.arg2SetVar(ce[0]),
op, s.arg2SetVar(ce[1]),
1644 SRT_EQ, s.arg2SetVar(ce[2]));
1646 void p_set_union(FlatZincSpace& s,
const ConExpr& ce, AST::Node *ann) {
1649 void p_set_intersect(FlatZincSpace& s,
const ConExpr& ce, AST::Node *ann) {
1652 void p_set_diff(FlatZincSpace& s,
const ConExpr& ce, AST::Node *ann) {
1656 void p_set_symdiff(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
1657 SetVar
x = s.arg2SetVar(ce[0]);
1658 SetVar
y = s.arg2SetVar(ce[1]);
1660 SetVarLubRanges xub(
x);
1665 SetVarLubRanges yub(
y);
1673 void p_array_set_OP(FlatZincSpace& s,
SetOpType op,
1674 const ConExpr& ce, AST::Node *) {
1675 SetVarArgs xs = s.arg2setvarargs(ce[0]);
1676 rel(s,
op, xs, s.arg2SetVar(ce[1]));
1678 void p_array_set_union(FlatZincSpace& s,
const ConExpr& ce, AST::Node *ann) {
1681 void p_array_set_partition(FlatZincSpace& s,
const ConExpr& ce, AST::Node *ann) {
1686 void p_set_rel(FlatZincSpace& s,
SetRelType srt,
const ConExpr& ce) {
1687 rel(s, s.arg2SetVar(ce[0]), srt, s.arg2SetVar(ce[1]));
1690 void p_set_eq(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1691 p_set_rel(s,
SRT_EQ, ce);
1693 void p_set_ne(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1694 p_set_rel(s,
SRT_NQ, ce);
1696 void p_set_subset(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1699 void p_set_superset(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1702 void p_set_le(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1703 p_set_rel(s,
SRT_LQ, ce);
1705 void p_set_lt(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1706 p_set_rel(s,
SRT_LE, ce);
1708 void p_set_card(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1709 if (!ce[1]->isIntVar()) {
1710 cardinality(s, s.arg2SetVar(ce[0]), ce[1]->getInt(),
1713 cardinality(s, s.arg2SetVar(ce[0]), s.arg2IntVar(ce[1]));
1716 void p_set_in(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1717 if (!ce[1]->isSetVar()) {
1718 IntSet
d = s.arg2intset(ce[1]);
1719 if (ce[0]->isBoolVar()) {
1721 Iter::Ranges::Singleton sr(0,1);
1722 Iter::Ranges::Inter<IntSetRanges,Iter::Ranges::Singleton>
i(dr,sr);
1724 if (d01.size() == 0) {
1727 rel(s, s.arg2BoolVar(ce[0]),
IRT_GQ, d01.min());
1728 rel(s, s.arg2BoolVar(ce[0]),
IRT_LQ, d01.max());
1731 dom(s, s.arg2IntVar(ce[0]),
d);
1734 if (!ce[0]->isIntVar()) {
1735 dom(s, s.arg2SetVar(ce[1]),
SRT_SUP, ce[0]->getInt());
1737 rel(s, s.arg2SetVar(ce[1]),
SRT_SUP, s.arg2IntVar(ce[0]));
1741 void p_set_rel_reif(FlatZincSpace& s,
SetRelType srt,
const ConExpr& ce) {
1742 rel(s, s.arg2SetVar(ce[0]), srt, s.arg2SetVar(ce[1]),
1743 s.arg2BoolVar(ce[2]));
1746 void p_set_eq_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1747 p_set_rel_reif(s,
SRT_EQ,ce);
1749 void p_set_le_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1750 p_set_rel_reif(s,
SRT_LQ,ce);
1752 void p_set_lt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1753 p_set_rel_reif(s,
SRT_LE,ce);
1755 void p_set_ne_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1756 p_set_rel_reif(s,
SRT_NQ,ce);
1758 void p_set_subset_reif(FlatZincSpace& s,
const ConExpr& ce,
1762 void p_set_superset_reif(FlatZincSpace& s,
const ConExpr& ce,
1766 void p_set_in_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann,
ReifyMode rm) {
1767 if (!ce[1]->isSetVar()) {
1769 p_int_in_reif(s,ce,ann);
1772 p_int_in_imp(s,ce,ann);
1775 if (!ce[0]->isIntVar()) {
1776 dom(s, s.arg2SetVar(ce[1]),
SRT_SUP, ce[0]->getInt(),
1777 Reify(s.arg2BoolVar(ce[2]),rm));
1779 rel(s, s.arg2SetVar(ce[1]),
SRT_SUP, s.arg2IntVar(ce[0]),
1780 Reify(s.arg2BoolVar(ce[2]),rm));
1784 void p_set_in_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1785 p_set_in_reif(s,ce,ann,
RM_EQV);
1787 void p_set_in_imp(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
1788 p_set_in_reif(s,ce,ann,
RM_IMP);
1790 void p_set_disjoint(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1791 rel(s, s.arg2SetVar(ce[0]),
SRT_DISJ, s.arg2SetVar(ce[1]));
1794 void p_link_set_to_booleans(FlatZincSpace& s,
const ConExpr& ce,
1796 SetVar
x = s.arg2SetVar(ce[0]);
1797 int idx = ce[2]->getInt();
1800 BoolVarArgs
y = s.arg2boolvarargs(ce[1],idx);
1805 void p_array_set_element(FlatZincSpace& s,
const ConExpr& ce,
1807 bool isConstant =
true;
1808 AST::Array*
a = ce[1]->getArray();
1809 for (
int i=
a->a.size();
i--;) {
1810 if (
a->a[
i]->isSetVar()) {
1815 IntVar selector = s.arg2IntVar(ce[0]);
1816 rel(s, selector > 0);
1819 element(s, sv, selector, s.arg2SetVar(ce[2]));
1821 SetVarArgs sv = s.arg2setvarargs(ce[1], 1);
1822 element(s, sv, selector, s.arg2SetVar(ce[2]));
1826 void p_array_set_element_op(FlatZincSpace& s,
const ConExpr& ce,
1828 const IntSet& universe =
1830 bool isConstant =
true;
1831 AST::Array*
a = ce[1]->getArray();
1832 for (
int i=
a->a.size();
i--;) {
1833 if (
a->a[
i]->isSetVar()) {
1838 SetVar selector = s.arg2SetVar(ce[0]);
1842 element(s,
op, sv, selector, s.arg2SetVar(ce[2]), universe);
1844 SetVarArgs sv = s.arg2setvarargs(ce[1], 1);
1845 element(s,
op, sv, selector, s.arg2SetVar(ce[2]), universe);
1849 void p_array_set_element_union(FlatZincSpace& s,
const ConExpr& ce,
1851 p_array_set_element_op(s, ce, ann,
SOT_UNION);
1854 void p_array_set_element_intersect(FlatZincSpace& s,
const ConExpr& ce,
1856 p_array_set_element_op(s, ce, ann,
SOT_INTER);
1859 void p_array_set_element_intersect_in(FlatZincSpace& s,
1862 IntSet
d = s.arg2intset(ce[3]);
1863 p_array_set_element_op(s, ce, ann,
SOT_INTER,
d);
1866 void p_array_set_element_partition(FlatZincSpace& s,
const ConExpr& ce,
1868 p_array_set_element_op(s, ce, ann,
SOT_DUNION);
1871 void p_set_convex(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1872 convex(s, s.arg2SetVar(ce[0]));
1875 void p_array_set_seq(FlatZincSpace& s,
const ConExpr& ce, AST::Node *) {
1876 SetVarArgs sv = s.arg2setvarargs(ce[0]);
1880 void p_array_set_seq_union(FlatZincSpace& s,
const ConExpr& ce,
1882 SetVarArgs sv = s.arg2setvarargs(ce[0]);
1883 sequence(s, sv, s.arg2SetVar(ce[1]));
1886 void p_int_set_channel(FlatZincSpace& s,
const ConExpr& ce,
1888 int xoff=ce[1]->getInt();
1890 int yoff=ce[3]->getInt();
1892 IntVarArgs xv = s.arg2intvarargs(ce[0], xoff);
1893 SetVarArgs yv = s.arg2setvarargs(ce[2], yoff, 1, IntSet(0, xoff-1));
1894 IntSet xd(yoff,yv.size()-1);
1895 for (
int i=xoff;
i<xv.
size();
i++) {
1898 IntSet yd(xoff,xv.size()-1);
1899 for (
int i=yoff;
i<yv.
size();
i++) {
1905 void p_range(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
1906 int xoff=ce[1]->getInt();
1908 IntVarArgs xv = s.arg2intvarargs(ce[0],xoff);
1912 void p_weights(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
1913 IntArgs e = s.arg2intargs(ce[0]);
1914 IntArgs w = s.arg2intargs(ce[1]);
1915 SetVar
x = s.arg2SetVar(ce[2]);
1916 IntVar
y = s.arg2IntVar(ce[3]);
1920 void p_inverse_set(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
1921 int xoff = ce[2]->getInt();
1922 int yoff = ce[3]->getInt();
1923 SetVarArgs
x = s.arg2setvarargs(ce[0],xoff);
1924 SetVarArgs
y = s.arg2setvarargs(ce[1],yoff);
1928 void p_precede_set(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
1929 SetVarArgs
x = s.arg2setvarargs(ce[0]);
1930 int p_s = ce[1]->getInt();
1931 int p_t = ce[2]->getInt();
1944 registry().
add(
"array_set_element", &p_array_set_element);
1945 registry().
add(
"array_var_set_element", &p_array_set_element);
1946 registry().
add(
"set_intersect", &p_set_intersect);
1958 registry().
add(
"set_subset_reif", &p_set_subset_reif);
1959 registry().
add(
"set_superset_reif", &p_set_superset_reif);
1964 &p_link_set_to_booleans);
1966 registry().
add(
"array_set_union", &p_array_set_union);
1967 registry().
add(
"array_set_partition", &p_array_set_partition);
1969 registry().
add(
"array_set_seq", &p_array_set_seq);
1970 registry().
add(
"array_set_seq_union", &p_array_set_seq_union);
1972 &p_array_set_element_union);
1973 registry().
add(
"gecode_array_set_element_intersect",
1974 &p_array_set_element_intersect);
1975 registry().
add(
"gecode_array_set_element_intersect_in",
1976 &p_array_set_element_intersect_in);
1977 registry().
add(
"gecode_array_set_element_partition",
1978 &p_array_set_element_partition);
1980 &p_int_set_channel);
1985 registry().
add(
"gecode_inverse_set", &p_inverse_set);
1986 registry().
add(
"gecode_precede_set", &p_precede_set);
1989 SetPoster __set_poster;
1992 #ifdef GECODE_HAS_FLOAT_VARS
1994 void p_int2float(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
1995 IntVar x0 = s.arg2IntVar(ce[0]);
1996 FloatVar x1 = s.arg2FloatVar(ce[1]);
2000 void p_float_lin_cmp(FlatZincSpace& s,
FloatRelType frt,
2001 const ConExpr& ce, AST::Node*) {
2002 FloatValArgs fa = s.arg2floatargs(ce[0]);
2003 FloatVarArgs fv = s.arg2floatvarargs(ce[1]);
2004 linear(s, fa, fv, frt, ce[2]->getFloat());
2006 void p_float_lin_cmp_reif(FlatZincSpace& s,
FloatRelType frt,
2007 const ConExpr& ce, AST::Node*) {
2008 FloatValArgs fa = s.arg2floatargs(ce[0]);
2009 FloatVarArgs fv = s.arg2floatvarargs(ce[1]);
2010 linear(s, fa, fv, frt, ce[2]->getFloat(), s.arg2BoolVar(ce[3]));
2012 void p_float_lin_eq(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
2013 p_float_lin_cmp(s,
FRT_EQ,ce,ann);
2015 void p_float_lin_eq_reif(FlatZincSpace& s,
const ConExpr& ce,
2017 p_float_lin_cmp_reif(s,
FRT_EQ,ce,ann);
2019 void p_float_lin_le(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
2020 p_float_lin_cmp(s,
FRT_LQ,ce,ann);
2022 void p_float_lin_lt(FlatZincSpace& s,
const ConExpr& ce, AST::Node* ann) {
2023 p_float_lin_cmp(s,
FRT_LE,ce,ann);
2025 void p_float_lin_le_reif(FlatZincSpace& s,
const ConExpr& ce,
2027 p_float_lin_cmp_reif(s,
FRT_LQ,ce,ann);
2029 void p_float_lin_lt_reif(FlatZincSpace& s,
const ConExpr& ce,
2031 p_float_lin_cmp_reif(s,
FRT_LE,ce,ann);
2034 void p_float_times(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2035 FloatVar
x = s.arg2FloatVar(ce[0]);
2036 FloatVar
y = s.arg2FloatVar(ce[1]);
2037 FloatVar
z = s.arg2FloatVar(ce[2]);
2041 void p_float_div(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2042 FloatVar
x = s.arg2FloatVar(ce[0]);
2043 FloatVar
y = s.arg2FloatVar(ce[1]);
2044 FloatVar
z = s.arg2FloatVar(ce[2]);
2048 void p_float_plus(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2049 FloatVar
x = s.arg2FloatVar(ce[0]);
2050 FloatVar
y = s.arg2FloatVar(ce[1]);
2051 FloatVar
z = s.arg2FloatVar(ce[2]);
2055 void p_float_sqrt(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2056 FloatVar
x = s.arg2FloatVar(ce[0]);
2057 FloatVar
y = s.arg2FloatVar(ce[1]);
2061 void p_float_abs(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2062 FloatVar
x = s.arg2FloatVar(ce[0]);
2063 FloatVar
y = s.arg2FloatVar(ce[1]);
2067 void p_float_eq(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2068 FloatVar
x = s.arg2FloatVar(ce[0]);
2069 FloatVar
y = s.arg2FloatVar(ce[1]);
2072 void p_float_eq_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2073 FloatVar
x = s.arg2FloatVar(ce[0]);
2074 FloatVar
y = s.arg2FloatVar(ce[1]);
2075 BoolVar
b = s.arg2BoolVar(ce[2]);
2078 void p_float_le(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2079 FloatVar
x = s.arg2FloatVar(ce[0]);
2080 FloatVar
y = s.arg2FloatVar(ce[1]);
2083 void p_float_le_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2084 FloatVar
x = s.arg2FloatVar(ce[0]);
2085 FloatVar
y = s.arg2FloatVar(ce[1]);
2086 BoolVar
b = s.arg2BoolVar(ce[2]);
2089 void p_float_max(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2090 FloatVar
x = s.arg2FloatVar(ce[0]);
2091 FloatVar
y = s.arg2FloatVar(ce[1]);
2092 FloatVar
z = s.arg2FloatVar(ce[2]);
2095 void p_float_min(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2096 FloatVar
x = s.arg2FloatVar(ce[0]);
2097 FloatVar
y = s.arg2FloatVar(ce[1]);
2098 FloatVar
z = s.arg2FloatVar(ce[2]);
2101 void p_float_lt(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2102 FloatVar
x = s.arg2FloatVar(ce[0]);
2103 FloatVar
y = s.arg2FloatVar(ce[1]);
2108 void p_float_lt_reif(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2109 FloatVar
x = s.arg2FloatVar(ce[0]);
2110 FloatVar
y = s.arg2FloatVar(ce[1]);
2111 BoolVar
b = s.arg2BoolVar(ce[2]);
2114 rel(s,
b == (b0 && !
b1));
2119 void p_float_ne(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2120 FloatVar
x = s.arg2FloatVar(ce[0]);
2121 FloatVar
y = s.arg2FloatVar(ce[1]);
2125 #ifdef GECODE_HAS_MPFR
2126 #define P_FLOAT_OP(Op) \
2127 void p_float_ ## Op (FlatZincSpace& s, const ConExpr& ce, AST::Node*) {\
2128 FloatVar x = s.arg2FloatVar(ce[0]);\
2129 FloatVar y = s.arg2FloatVar(ce[1]);\
2144 void p_float_ln(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2145 FloatVar
x = s.arg2FloatVar(ce[0]);
2146 FloatVar
y = s.arg2FloatVar(ce[1]);
2149 void p_float_log10(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2150 FloatVar
x = s.arg2FloatVar(ce[0]);
2151 FloatVar
y = s.arg2FloatVar(ce[1]);
2154 void p_float_log2(FlatZincSpace& s,
const ConExpr& ce, AST::Node*) {
2155 FloatVar
x = s.arg2FloatVar(ce[0]);
2156 FloatVar
y = s.arg2FloatVar(ce[1]);
2182 registry().
add(
"float_lin_eq_reif",&p_float_lin_eq_reif);
2185 registry().
add(
"float_lin_le_reif",&p_float_lin_le_reif);
2186 registry().
add(
"float_lin_lt_reif",&p_float_lin_lt_reif);
2188 #ifdef GECODE_HAS_MPFR