00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef __GECODE_MINIMODEL_HH__
00043 #define __GECODE_MINIMODEL_HH__
00044
00045 #include <gecode/kernel.hh>
00046 #include <gecode/int.hh>
00047 #ifdef GECODE_HAS_SET_VARS
00048 #include <gecode/set.hh>
00049 #endif
00050 #ifdef GECODE_HAS_FLOAT_VARS
00051 #include <gecode/float.hh>
00052 #endif
00053
00054 #include <iostream>
00055
00056
00057
00058
00059
00060
00061 #if !defined(GECODE_STATIC_LIBS) && \
00062 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00063
00064 #ifdef GECODE_BUILD_MINIMODEL
00065 #define GECODE_MINIMODEL_EXPORT __declspec( dllexport )
00066 #else
00067 #define GECODE_MINIMODEL_EXPORT __declspec( dllimport )
00068 #endif
00069
00070 #else
00071
00072 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00073
00074 #define GECODE_MINIMODEL_EXPORT __attribute__ ((visibility("default")))
00075
00076 #else
00077
00078 #define GECODE_MINIMODEL_EXPORT
00079
00080 #endif
00081 #endif
00082
00083
00084 #ifndef GECODE_BUILD_MINIMODEL
00085 #define GECODE_LIBRARY_NAME "MiniModel"
00086 #include <gecode/support/auto-link.hpp>
00087 #endif
00088
00089 namespace Gecode {
00090
00092 namespace MiniModel {}
00093
00094 }
00095
00096 #include <gecode/minimodel/exception.hpp>
00097
00098 namespace Gecode {
00099
00100 class LinIntRel;
00101 #ifdef GECODE_HAS_SET_VARS
00102 class SetExpr;
00103 #endif
00104 #ifdef GECODE_HAS_FLOAT_VARS
00105 class LinFloatExpr;
00106 #endif
00107
00109 class NonLinIntExpr {
00110 public:
00112 virtual IntVar post(Home home, IntVar* ret, IntPropLevel ipl) const = 0;
00114 virtual void post(Home home, IntRelType irt, int c,
00115 IntPropLevel ipl) const = 0;
00117 virtual void post(Home home, IntRelType irt, int c,
00118 BoolVar b, IntPropLevel ipl) const = 0;
00120 virtual ~NonLinIntExpr(void) {}
00122 static IntVar result(Home home, IntVar* x) {
00123 if (x==NULL)
00124 return IntVar(home,Int::Limits::min,Int::Limits::max);
00125 return *x;
00126 }
00128 static IntVar result(Home home, IntVar* x, IntVar y) {
00129 if (x!=NULL)
00130 rel(home,*x,IRT_EQ,y);
00131 return y;
00132 }
00134 void* operator new(size_t size) { return heap.ralloc(size); }
00136 void operator delete(void* p, size_t) { heap.rfree(p); }
00137 };
00138
00140 class LinIntExpr {
00141 friend class LinIntRel;
00142 #ifdef GECODE_HAS_SET_VARS
00143 friend class SetExpr;
00144 #endif
00145 #ifdef GECODE_HAS_FLOAT_VARS
00146 friend class LinFloatExpr;
00147 #endif
00148 public:
00150 enum NodeType {
00151 NT_CONST,
00152 NT_VAR_INT,
00153 NT_VAR_BOOL,
00154 NT_NONLIN,
00155 NT_SUM_INT,
00156 NT_SUM_BOOL,
00157 NT_ADD,
00158 NT_SUB,
00159 NT_MUL
00160 };
00161 private:
00163 class Node;
00165 Node* n;
00166 public:
00168 GECODE_MINIMODEL_EXPORT
00169 LinIntExpr(void);
00171 GECODE_MINIMODEL_EXPORT
00172 LinIntExpr(int c);
00174 GECODE_MINIMODEL_EXPORT
00175 LinIntExpr(const IntVar& x, int a=1);
00177 GECODE_MINIMODEL_EXPORT
00178 LinIntExpr(const BoolVar& x, int a=1);
00180 GECODE_MINIMODEL_EXPORT
00181 explicit LinIntExpr(const IntVarArgs& x);
00183 GECODE_MINIMODEL_EXPORT
00184 LinIntExpr(const IntArgs& a, const IntVarArgs& x);
00186 GECODE_MINIMODEL_EXPORT
00187 explicit LinIntExpr(const BoolVarArgs& x);
00189 GECODE_MINIMODEL_EXPORT
00190 LinIntExpr(const IntArgs& a, const BoolVarArgs& x);
00192 GECODE_MINIMODEL_EXPORT
00193 LinIntExpr(const LinIntExpr& e);
00195 GECODE_MINIMODEL_EXPORT
00196 LinIntExpr(const LinIntExpr& e0, NodeType t, const LinIntExpr& e1);
00198 GECODE_MINIMODEL_EXPORT
00199 LinIntExpr(const LinIntExpr& e0, NodeType t, int c);
00201 GECODE_MINIMODEL_EXPORT
00202 LinIntExpr(int a, const LinIntExpr& e);
00204 GECODE_MINIMODEL_EXPORT
00205 explicit LinIntExpr(NonLinIntExpr* e);
00207 GECODE_MINIMODEL_EXPORT
00208 const LinIntExpr& operator =(const LinIntExpr& e);
00210 GECODE_MINIMODEL_EXPORT
00211 void post(Home home, IntRelType irt, IntPropLevel ipl) const;
00213 GECODE_MINIMODEL_EXPORT
00214 void post(Home home, IntRelType irt, const BoolVar& b,
00215 IntPropLevel ipl) const;
00217 GECODE_MINIMODEL_EXPORT
00218 IntVar post(Home home, IntPropLevel ipl) const;
00220 GECODE_MINIMODEL_EXPORT
00221 NonLinIntExpr* nle(void) const;
00223 GECODE_MINIMODEL_EXPORT
00224 ~LinIntExpr(void);
00225 };
00226
00227 class BoolExpr;
00228
00230 class LinIntRel {
00231 friend class BoolExpr;
00232 private:
00234 LinIntExpr e;
00236 IntRelType irt;
00238 static IntRelType neg(IntRelType irt);
00240 LinIntRel(void);
00241 public:
00243 LinIntRel(const LinIntExpr& l, IntRelType irt, const LinIntExpr& r);
00245 LinIntRel(const LinIntExpr& l, IntRelType irt, int r);
00247 LinIntRel(int l, IntRelType irt, const LinIntExpr& r);
00249 void post(Home home, bool t, IntPropLevel ipl) const;
00251 void post(Home home, const BoolVar& b, bool t, IntPropLevel ipl) const;
00252 };
00253
00272
00273 GECODE_MINIMODEL_EXPORT LinIntExpr
00274 operator +(int, const IntVar&);
00276 GECODE_MINIMODEL_EXPORT LinIntExpr
00277 operator +(int, const BoolVar&);
00279 GECODE_MINIMODEL_EXPORT LinIntExpr
00280 operator +(int, const LinIntExpr&);
00282 GECODE_MINIMODEL_EXPORT LinIntExpr
00283 operator +(const IntVar&, int);
00285 GECODE_MINIMODEL_EXPORT LinIntExpr
00286 operator +(const BoolVar&, int);
00288 GECODE_MINIMODEL_EXPORT LinIntExpr
00289 operator +(const LinIntExpr&, int);
00291 GECODE_MINIMODEL_EXPORT LinIntExpr
00292 operator +(const IntVar&, const IntVar&);
00294 GECODE_MINIMODEL_EXPORT LinIntExpr
00295 operator +(const IntVar&, const BoolVar&);
00297 GECODE_MINIMODEL_EXPORT LinIntExpr
00298 operator +(const BoolVar&, const IntVar&);
00300 GECODE_MINIMODEL_EXPORT LinIntExpr
00301 operator +(const BoolVar&, const BoolVar&);
00303 GECODE_MINIMODEL_EXPORT LinIntExpr
00304 operator +(const IntVar&, const LinIntExpr&);
00306 GECODE_MINIMODEL_EXPORT LinIntExpr
00307 operator +(const BoolVar&, const LinIntExpr&);
00309 GECODE_MINIMODEL_EXPORT LinIntExpr
00310 operator +(const LinIntExpr&, const IntVar&);
00312 GECODE_MINIMODEL_EXPORT LinIntExpr
00313 operator +(const LinIntExpr&, const BoolVar&);
00315 GECODE_MINIMODEL_EXPORT LinIntExpr
00316 operator +(const LinIntExpr&, const LinIntExpr&);
00317
00319 GECODE_MINIMODEL_EXPORT LinIntExpr
00320 operator -(int, const IntVar&);
00322 GECODE_MINIMODEL_EXPORT LinIntExpr
00323 operator -(int, const BoolVar&);
00325 GECODE_MINIMODEL_EXPORT LinIntExpr
00326 operator -(int, const LinIntExpr&);
00328 GECODE_MINIMODEL_EXPORT LinIntExpr
00329 operator -(const IntVar&, int);
00331 GECODE_MINIMODEL_EXPORT LinIntExpr
00332 operator -(const BoolVar&, int);
00334 GECODE_MINIMODEL_EXPORT LinIntExpr
00335 operator -(const LinIntExpr&, int);
00337 GECODE_MINIMODEL_EXPORT LinIntExpr
00338 operator -(const IntVar&, const IntVar&);
00340 GECODE_MINIMODEL_EXPORT LinIntExpr
00341 operator -(const IntVar&, const BoolVar&);
00343 GECODE_MINIMODEL_EXPORT LinIntExpr
00344 operator -(const BoolVar&, const IntVar&);
00346 GECODE_MINIMODEL_EXPORT LinIntExpr
00347 operator -(const BoolVar&, const BoolVar&);
00349 GECODE_MINIMODEL_EXPORT LinIntExpr
00350 operator -(const IntVar&, const LinIntExpr&);
00352 GECODE_MINIMODEL_EXPORT LinIntExpr
00353 operator -(const BoolVar&, const LinIntExpr&);
00355 GECODE_MINIMODEL_EXPORT LinIntExpr
00356 operator -(const LinIntExpr&, const IntVar&);
00358 GECODE_MINIMODEL_EXPORT LinIntExpr
00359 operator -(const LinIntExpr&, const BoolVar&);
00361 GECODE_MINIMODEL_EXPORT LinIntExpr
00362 operator -(const LinIntExpr&, const LinIntExpr&);
00363
00365 GECODE_MINIMODEL_EXPORT LinIntExpr
00366 operator -(const IntVar&);
00368 GECODE_MINIMODEL_EXPORT LinIntExpr
00369 operator -(const BoolVar&);
00371 GECODE_MINIMODEL_EXPORT LinIntExpr
00372 operator -(const LinIntExpr&);
00373
00375 GECODE_MINIMODEL_EXPORT LinIntExpr
00376 operator *(int, const IntVar&);
00378 GECODE_MINIMODEL_EXPORT LinIntExpr
00379 operator *(int, const BoolVar&);
00381 GECODE_MINIMODEL_EXPORT LinIntExpr
00382 operator *(const IntVar&, int);
00384 GECODE_MINIMODEL_EXPORT LinIntExpr
00385 operator *(const BoolVar&, int);
00387 GECODE_MINIMODEL_EXPORT LinIntExpr
00388 operator *(const LinIntExpr&, int);
00390 GECODE_MINIMODEL_EXPORT LinIntExpr
00391 operator *(int, const LinIntExpr&);
00392
00394 GECODE_MINIMODEL_EXPORT LinIntExpr
00395 sum(const IntVarArgs& x);
00397 GECODE_MINIMODEL_EXPORT LinIntExpr
00398 sum(const IntArgs& a, const IntVarArgs& x);
00400 GECODE_MINIMODEL_EXPORT LinIntExpr
00401 sum(const BoolVarArgs& x);
00403 GECODE_MINIMODEL_EXPORT LinIntExpr
00404 sum(const IntArgs& a, const BoolVarArgs& x);
00406 GECODE_MINIMODEL_EXPORT LinIntExpr
00407 sum(const IntArgs& args);
00408
00410 GECODE_MINIMODEL_EXPORT LinIntRel
00411 operator ==(int l, const IntVar& r);
00413 GECODE_MINIMODEL_EXPORT LinIntRel
00414 operator ==(int l, const BoolVar& r);
00416 GECODE_MINIMODEL_EXPORT LinIntRel
00417 operator ==(int l, const LinIntExpr& r);
00419 GECODE_MINIMODEL_EXPORT LinIntRel
00420 operator ==(const IntVar& l, int r);
00422 GECODE_MINIMODEL_EXPORT LinIntRel
00423 operator ==(const BoolVar& l, int r);
00425 GECODE_MINIMODEL_EXPORT LinIntRel
00426 operator ==(const LinIntExpr& l, int r);
00428 GECODE_MINIMODEL_EXPORT LinIntRel
00429 operator ==(const IntVar& l, const IntVar& r);
00431 GECODE_MINIMODEL_EXPORT LinIntRel
00432 operator ==(const IntVar& l, const BoolVar& r);
00434 GECODE_MINIMODEL_EXPORT LinIntRel
00435 operator ==(const BoolVar& l, const IntVar& r);
00437 GECODE_MINIMODEL_EXPORT LinIntRel
00438 operator ==(const BoolVar& l, const BoolVar& r);
00440 GECODE_MINIMODEL_EXPORT LinIntRel
00441 operator ==(const IntVar& l, const LinIntExpr& r);
00443 GECODE_MINIMODEL_EXPORT LinIntRel
00444 operator ==(const BoolVar& l, const LinIntExpr& r);
00446 GECODE_MINIMODEL_EXPORT LinIntRel
00447 operator ==(const LinIntExpr& l, const IntVar& r);
00449 GECODE_MINIMODEL_EXPORT LinIntRel
00450 operator ==(const LinIntExpr& l, const BoolVar& r);
00452 GECODE_MINIMODEL_EXPORT LinIntRel
00453 operator ==(const LinIntExpr& l, const LinIntExpr& r);
00454
00456 GECODE_MINIMODEL_EXPORT LinIntRel
00457 operator !=(int l, const IntVar& r);
00459 GECODE_MINIMODEL_EXPORT LinIntRel
00460 operator !=(int l, const BoolVar& r);
00462 GECODE_MINIMODEL_EXPORT LinIntRel
00463 operator !=(int l, const LinIntExpr& r);
00465 GECODE_MINIMODEL_EXPORT LinIntRel
00466 operator !=(const IntVar& l, int r);
00468 GECODE_MINIMODEL_EXPORT LinIntRel
00469 operator !=(const BoolVar& l, int r);
00471 GECODE_MINIMODEL_EXPORT LinIntRel
00472 operator !=(const LinIntExpr& l, int r);
00474 GECODE_MINIMODEL_EXPORT LinIntRel
00475 operator !=(const IntVar& l, const IntVar& r);
00477 GECODE_MINIMODEL_EXPORT LinIntRel
00478 operator !=(const IntVar& l, const BoolVar& r);
00480 GECODE_MINIMODEL_EXPORT LinIntRel
00481 operator !=(const BoolVar& l, const IntVar& r);
00483 GECODE_MINIMODEL_EXPORT LinIntRel
00484 operator !=(const BoolVar& l, const BoolVar& r);
00486 GECODE_MINIMODEL_EXPORT LinIntRel
00487 operator !=(const IntVar& l, const LinIntExpr& r);
00489 GECODE_MINIMODEL_EXPORT LinIntRel
00490 operator !=(const BoolVar& l, const LinIntExpr& r);
00492 GECODE_MINIMODEL_EXPORT LinIntRel
00493 operator !=(const LinIntExpr& l, const IntVar& r);
00495 GECODE_MINIMODEL_EXPORT LinIntRel
00496 operator !=(const LinIntExpr& l, const BoolVar& r);
00498 GECODE_MINIMODEL_EXPORT LinIntRel
00499 operator !=(const LinIntExpr& l, const LinIntExpr& r);
00500
00502 GECODE_MINIMODEL_EXPORT LinIntRel
00503 operator <(int l, const IntVar& r);
00505 GECODE_MINIMODEL_EXPORT LinIntRel
00506 operator <(int l, const BoolVar& r);
00508 GECODE_MINIMODEL_EXPORT LinIntRel
00509 operator <(int l, const LinIntExpr& r);
00511 GECODE_MINIMODEL_EXPORT LinIntRel
00512 operator <(const IntVar& l, int r);
00514 GECODE_MINIMODEL_EXPORT LinIntRel
00515 operator <(const BoolVar& l, int r);
00517 GECODE_MINIMODEL_EXPORT LinIntRel
00518 operator <(const LinIntExpr& l, int r);
00520 GECODE_MINIMODEL_EXPORT LinIntRel
00521 operator <(const IntVar& l, const IntVar& r);
00523 GECODE_MINIMODEL_EXPORT LinIntRel
00524 operator <(const IntVar& l, const BoolVar& r);
00526 GECODE_MINIMODEL_EXPORT LinIntRel
00527 operator <(const BoolVar& l, const IntVar& r);
00529 GECODE_MINIMODEL_EXPORT LinIntRel
00530 operator <(const BoolVar& l, const BoolVar& r);
00532 GECODE_MINIMODEL_EXPORT LinIntRel
00533 operator <(const IntVar& l, const LinIntExpr& r);
00535 GECODE_MINIMODEL_EXPORT LinIntRel
00536 operator <(const BoolVar& l, const LinIntExpr& r);
00538 GECODE_MINIMODEL_EXPORT LinIntRel
00539 operator <(const LinIntExpr& l, const IntVar& r);
00541 GECODE_MINIMODEL_EXPORT LinIntRel
00542 operator <(const LinIntExpr& l, const BoolVar& r);
00544 GECODE_MINIMODEL_EXPORT LinIntRel
00545 operator <(const LinIntExpr& l, const LinIntExpr& r);
00546
00548 GECODE_MINIMODEL_EXPORT LinIntRel
00549 operator <=(int l, const IntVar& r);
00551 GECODE_MINIMODEL_EXPORT LinIntRel
00552 operator <=(int l, const BoolVar& r);
00554 GECODE_MINIMODEL_EXPORT LinIntRel
00555 operator <=(int l, const LinIntExpr& r);
00557 GECODE_MINIMODEL_EXPORT LinIntRel
00558 operator <=(const IntVar& l, int r);
00560 GECODE_MINIMODEL_EXPORT LinIntRel
00561 operator <=(const BoolVar& l, int r);
00563 GECODE_MINIMODEL_EXPORT LinIntRel
00564 operator <=(const LinIntExpr& l, int r);
00566 GECODE_MINIMODEL_EXPORT LinIntRel
00567 operator <=(const IntVar& l, const IntVar& r);
00569 GECODE_MINIMODEL_EXPORT LinIntRel
00570 operator <=(const IntVar& l, const BoolVar& r);
00572 GECODE_MINIMODEL_EXPORT LinIntRel
00573 operator <=(const BoolVar& l, const IntVar& r);
00575 GECODE_MINIMODEL_EXPORT LinIntRel
00576 operator <=(const BoolVar& l, const BoolVar& r);
00578 GECODE_MINIMODEL_EXPORT LinIntRel
00579 operator <=(const IntVar& l, const LinIntExpr& r);
00581 GECODE_MINIMODEL_EXPORT LinIntRel
00582 operator <=(const BoolVar& l, const LinIntExpr& r);
00584 GECODE_MINIMODEL_EXPORT LinIntRel
00585 operator <=(const LinIntExpr& l, const IntVar& r);
00587 GECODE_MINIMODEL_EXPORT LinIntRel
00588 operator <=(const LinIntExpr& l, const BoolVar& r);
00590 GECODE_MINIMODEL_EXPORT LinIntRel
00591 operator <=(const LinIntExpr& l, const LinIntExpr& r);
00592
00594 GECODE_MINIMODEL_EXPORT LinIntRel
00595 operator >(int l, const IntVar& r);
00597 GECODE_MINIMODEL_EXPORT LinIntRel
00598 operator >(int l, const BoolVar& r);
00600 GECODE_MINIMODEL_EXPORT LinIntRel
00601 operator >(int l, const LinIntExpr& r);
00603 GECODE_MINIMODEL_EXPORT LinIntRel
00604 operator >(const IntVar& l, int r);
00606 GECODE_MINIMODEL_EXPORT LinIntRel
00607 operator >(const BoolVar& l, int r);
00609 GECODE_MINIMODEL_EXPORT LinIntRel
00610 operator >(const LinIntExpr& l, int r);
00612 GECODE_MINIMODEL_EXPORT LinIntRel
00613 operator >(const IntVar& l, const IntVar& r);
00615 GECODE_MINIMODEL_EXPORT LinIntRel
00616 operator >(const IntVar& l, const BoolVar& r);
00618 GECODE_MINIMODEL_EXPORT LinIntRel
00619 operator >(const BoolVar& l, const IntVar& r);
00621 GECODE_MINIMODEL_EXPORT LinIntRel
00622 operator >(const BoolVar& l, const BoolVar& r);
00624 GECODE_MINIMODEL_EXPORT LinIntRel
00625 operator >(const IntVar& l, const LinIntExpr& r);
00627 GECODE_MINIMODEL_EXPORT LinIntRel
00628 operator >(const BoolVar& l, const LinIntExpr& r);
00630 GECODE_MINIMODEL_EXPORT LinIntRel
00631 operator >(const LinIntExpr& l, const IntVar& r);
00633 GECODE_MINIMODEL_EXPORT LinIntRel
00634 operator >(const LinIntExpr& l, const BoolVar& r);
00636 GECODE_MINIMODEL_EXPORT LinIntRel
00637 operator >(const LinIntExpr& l, const LinIntExpr& r);
00638
00640 GECODE_MINIMODEL_EXPORT LinIntRel
00641 operator >=(int l, const IntVar& r);
00643 GECODE_MINIMODEL_EXPORT LinIntRel
00644 operator >=(int l, const BoolVar& r);
00646 GECODE_MINIMODEL_EXPORT LinIntRel
00647 operator >=(int l, const LinIntExpr& r);
00649 GECODE_MINIMODEL_EXPORT LinIntRel
00650 operator >=(const IntVar& l, int r);
00652 GECODE_MINIMODEL_EXPORT LinIntRel
00653 operator >=(const BoolVar& l, int r);
00655 GECODE_MINIMODEL_EXPORT LinIntRel
00656 operator >=(const LinIntExpr& l, int r);
00658 GECODE_MINIMODEL_EXPORT LinIntRel
00659 operator >=(const IntVar& l, const IntVar& r);
00661 GECODE_MINIMODEL_EXPORT LinIntRel
00662 operator >=(const IntVar& l, const BoolVar& r);
00664 GECODE_MINIMODEL_EXPORT LinIntRel
00665 operator >=(const BoolVar& l, const IntVar& r);
00667 GECODE_MINIMODEL_EXPORT LinIntRel
00668 operator >=(const BoolVar& l, const BoolVar& r);
00670 GECODE_MINIMODEL_EXPORT LinIntRel
00671 operator >=(const IntVar& l, const LinIntExpr& r);
00673 GECODE_MINIMODEL_EXPORT LinIntRel
00674 operator >=(const BoolVar& l, const LinIntExpr& r);
00676 GECODE_MINIMODEL_EXPORT LinIntRel
00677 operator >=(const LinIntExpr& l, const IntVar& r);
00679 GECODE_MINIMODEL_EXPORT LinIntRel
00680 operator >=(const LinIntExpr& l, const BoolVar& r);
00682 GECODE_MINIMODEL_EXPORT LinIntRel
00683 operator >=(const LinIntExpr& l, const LinIntExpr& r);
00685
00686 #ifdef GECODE_HAS_FLOAT_VARS
00687
00688 class NonLinFloatExpr {
00689 public:
00691 virtual FloatVar post(Home home, FloatVar* ret) const = 0;
00693 virtual void post(Home home, FloatRelType frt, FloatVal c) const = 0;
00695 virtual void post(Home home, FloatRelType frt, FloatVal c,
00696 BoolVar b) const = 0;
00698 virtual ~NonLinFloatExpr(void) {}
00700 static FloatVar result(Home home, FloatVar* x) {
00701 if (x == NULL)
00702 return FloatVar(home,Float::Limits::min,Float::Limits::max);
00703 return *x;
00704 }
00706 static FloatVar result(Home home, FloatVar* x, FloatVar y) {
00707 if (x!=NULL)
00708 rel(home,*x,FRT_EQ,y);
00709 return y;
00710 }
00712 void* operator new(size_t size) { return heap.ralloc(size); }
00714 void operator delete(void* p, size_t) { heap.rfree(p); }
00715 };
00716
00718 class LinFloatExpr {
00719 friend class LinFloatRel;
00720 public:
00722 enum NodeType {
00723 NT_CONST,
00724 NT_VAR,
00725 NT_NONLIN,
00726 NT_SUM,
00727 NT_ADD,
00728 NT_SUB,
00729 NT_MUL
00730 };
00731 private:
00733 class Node;
00734 Node* n;
00735 public:
00737 GECODE_MINIMODEL_EXPORT
00738 LinFloatExpr(void);
00740 GECODE_MINIMODEL_EXPORT
00741 LinFloatExpr(const FloatVal& c);
00743 GECODE_MINIMODEL_EXPORT
00744 LinFloatExpr(const FloatVar& x);
00746 GECODE_MINIMODEL_EXPORT
00747 LinFloatExpr(const FloatVar& x, FloatVal a);
00749 GECODE_MINIMODEL_EXPORT
00750 explicit LinFloatExpr(const FloatVarArgs& x);
00752 GECODE_MINIMODEL_EXPORT
00753 LinFloatExpr(const FloatValArgs& a, const FloatVarArgs& x);
00755 GECODE_MINIMODEL_EXPORT
00756 LinFloatExpr(const LinFloatExpr& e);
00758 GECODE_MINIMODEL_EXPORT
00759 LinFloatExpr(const LinFloatExpr& e0, NodeType t, const LinFloatExpr& e1);
00761 GECODE_MINIMODEL_EXPORT
00762 LinFloatExpr(const LinFloatExpr& e0, NodeType t, const FloatVal& c);
00764 GECODE_MINIMODEL_EXPORT
00765 LinFloatExpr(FloatVal a, const LinFloatExpr& e);
00767 GECODE_MINIMODEL_EXPORT
00768 explicit LinFloatExpr(NonLinFloatExpr* e);
00770 GECODE_MINIMODEL_EXPORT
00771 const LinFloatExpr& operator =(const LinFloatExpr& e);
00773 GECODE_MINIMODEL_EXPORT
00774 void post(Home home, FloatRelType frt) const;
00776 GECODE_MINIMODEL_EXPORT
00777 void post(Home home, FloatRelType frt, const BoolVar& b) const;
00779 GECODE_MINIMODEL_EXPORT
00780 FloatVar post(Home home) const;
00782 GECODE_MINIMODEL_EXPORT
00783 NonLinFloatExpr* nlfe(void) const;
00785 GECODE_MINIMODEL_EXPORT
00786 ~LinFloatExpr(void);
00787 };
00788
00789 class BoolExpr;
00790
00792 class LinFloatRel {
00793 friend class BoolExpr;
00794 private:
00796 LinFloatExpr e;
00798 FloatRelType frt;
00800 static FloatRelType neg(FloatRelType frt);
00802 LinFloatRel(void);
00803 public:
00805 LinFloatRel(const LinFloatExpr& l, FloatRelType frt, const LinFloatExpr& r);
00807 LinFloatRel(const LinFloatExpr& l, FloatRelType frt, FloatVal r);
00809 LinFloatRel(FloatVal l, FloatRelType frt, const LinFloatExpr& r);
00811 void post(Home home, bool t) const;
00813 void post(Home home, const BoolVar& b, bool t) const;
00814 };
00815
00829
00830 GECODE_MINIMODEL_EXPORT LinFloatExpr
00831 operator +(const FloatVal&, const FloatVar&);
00833 GECODE_MINIMODEL_EXPORT LinFloatExpr
00834 operator +(const FloatVal&, const LinFloatExpr&);
00836 GECODE_MINIMODEL_EXPORT LinFloatExpr
00837 operator +(const FloatVar&, const FloatVal&);
00839 GECODE_MINIMODEL_EXPORT LinFloatExpr
00840 operator +(const LinFloatExpr&, const FloatVal&);
00842 GECODE_MINIMODEL_EXPORT LinFloatExpr
00843 operator +(const FloatVar&, const FloatVar&);
00845 GECODE_MINIMODEL_EXPORT LinFloatExpr
00846 operator +(const FloatVar&, const LinFloatExpr&);
00848 GECODE_MINIMODEL_EXPORT LinFloatExpr
00849 operator +(const LinFloatExpr&, const FloatVar&);
00851 GECODE_MINIMODEL_EXPORT LinFloatExpr
00852 operator +(const LinFloatExpr&, const LinFloatExpr&);
00853
00855 GECODE_MINIMODEL_EXPORT LinFloatExpr
00856 operator -(const FloatVal&, const FloatVar&);
00858 GECODE_MINIMODEL_EXPORT LinFloatExpr
00859 operator -(const FloatVal&, const LinFloatExpr&);
00861 GECODE_MINIMODEL_EXPORT LinFloatExpr
00862 operator -(const FloatVar&, const FloatVal&);
00864 GECODE_MINIMODEL_EXPORT LinFloatExpr
00865 operator -(const LinFloatExpr&, const FloatVal&);
00867 GECODE_MINIMODEL_EXPORT LinFloatExpr
00868 operator -(const FloatVar&, const FloatVar&);
00870 GECODE_MINIMODEL_EXPORT LinFloatExpr
00871 operator -(const FloatVar&, const LinFloatExpr&);
00873 GECODE_MINIMODEL_EXPORT LinFloatExpr
00874 operator -(const LinFloatExpr&, const FloatVar&);
00876 GECODE_MINIMODEL_EXPORT LinFloatExpr
00877 operator -(const LinFloatExpr&, const LinFloatExpr&);
00878
00880 GECODE_MINIMODEL_EXPORT LinFloatExpr
00881 operator -(const FloatVar&);
00883 GECODE_MINIMODEL_EXPORT LinFloatExpr
00884 operator -(const LinFloatExpr&);
00885
00887 GECODE_MINIMODEL_EXPORT LinFloatExpr
00888 operator *(const FloatVal&, const FloatVar&);
00890 GECODE_MINIMODEL_EXPORT LinFloatExpr
00891 operator *(const FloatVar&, const FloatVal&);
00893 GECODE_MINIMODEL_EXPORT LinFloatExpr
00894 operator *(const LinFloatExpr&, const FloatVal&);
00896 GECODE_MINIMODEL_EXPORT LinFloatExpr
00897 operator *(const FloatVal&, const LinFloatExpr&);
00898
00900 GECODE_MINIMODEL_EXPORT LinFloatExpr
00901 sum(const FloatVarArgs& x);
00903 GECODE_MINIMODEL_EXPORT LinFloatExpr
00904 sum(const FloatValArgs& a, const FloatVarArgs& x);
00905
00907 GECODE_MINIMODEL_EXPORT LinFloatRel
00908 operator ==(const FloatVal& l, const FloatVar& r);
00910 GECODE_MINIMODEL_EXPORT LinFloatRel
00911 operator ==(const FloatVal& l, const LinFloatExpr& r);
00913 GECODE_MINIMODEL_EXPORT LinFloatRel
00914 operator ==(const FloatVar& l, const FloatVal& r);
00916 GECODE_MINIMODEL_EXPORT LinFloatRel
00917 operator ==(const LinFloatExpr& l, const FloatVal& r);
00919 GECODE_MINIMODEL_EXPORT LinFloatRel
00920 operator ==(const FloatVar& l, const FloatVar& r);
00922 GECODE_MINIMODEL_EXPORT LinFloatRel
00923 operator ==(const FloatVar& l, const LinFloatExpr& r);
00925 GECODE_MINIMODEL_EXPORT LinFloatRel
00926 operator ==(const LinFloatExpr& l, const FloatVar& r);
00928 GECODE_MINIMODEL_EXPORT LinFloatRel
00929 operator ==(const LinFloatExpr& l, const LinFloatExpr& r);
00930
00932 GECODE_MINIMODEL_EXPORT LinFloatRel
00933 operator !=(const FloatVal& l, const FloatVar& r);
00935 GECODE_MINIMODEL_EXPORT LinFloatRel
00936 operator !=(const FloatVal& l, const LinFloatExpr& r);
00938 GECODE_MINIMODEL_EXPORT LinFloatRel
00939 operator !=(const FloatVar& l, const FloatVal& r);
00941 GECODE_MINIMODEL_EXPORT LinFloatRel
00942 operator !=(const LinFloatExpr& l, const FloatVal& r);
00944 GECODE_MINIMODEL_EXPORT LinFloatRel
00945 operator !=(const FloatVar& l, const FloatVar& r);
00947 GECODE_MINIMODEL_EXPORT LinFloatRel
00948 operator !=(const FloatVar& l, const LinFloatExpr& r);
00950 GECODE_MINIMODEL_EXPORT LinFloatRel
00951 operator !=(const LinFloatExpr& l, const FloatVar& r);
00953 GECODE_MINIMODEL_EXPORT LinFloatRel
00954 operator !=(const LinFloatExpr& l, const LinFloatExpr& r);
00955
00957 GECODE_MINIMODEL_EXPORT LinFloatRel
00958 operator <(const FloatVal& l, const FloatVar& r);
00960 GECODE_MINIMODEL_EXPORT LinFloatRel
00961 operator <(const FloatVal& l, const LinFloatExpr& r);
00963 GECODE_MINIMODEL_EXPORT LinFloatRel
00964 operator <(const FloatVar& l, const FloatVal& r);
00966 GECODE_MINIMODEL_EXPORT LinFloatRel
00967 operator <(const LinFloatExpr& l, const FloatVal& r);
00969 GECODE_MINIMODEL_EXPORT LinFloatRel
00970 operator <(const FloatVar& l, const FloatVar& r);
00972 GECODE_MINIMODEL_EXPORT LinFloatRel
00973 operator <(const FloatVar& l, const LinFloatExpr& r);
00975 GECODE_MINIMODEL_EXPORT LinFloatRel
00976 operator <(const LinFloatExpr& l, const FloatVar& r);
00978 GECODE_MINIMODEL_EXPORT LinFloatRel
00979 operator <(const LinFloatExpr& l, const LinFloatExpr& r);
00980
00982 GECODE_MINIMODEL_EXPORT LinFloatRel
00983 operator <=(const FloatVal& l, const FloatVar& r);
00985 GECODE_MINIMODEL_EXPORT LinFloatRel
00986 operator <=(const FloatVal& l, const LinFloatExpr& r);
00988 GECODE_MINIMODEL_EXPORT LinFloatRel
00989 operator <=(const FloatVar& l, const FloatVal& r);
00991 GECODE_MINIMODEL_EXPORT LinFloatRel
00992 operator <=(const LinFloatExpr& l, const FloatVal& r);
00994 GECODE_MINIMODEL_EXPORT LinFloatRel
00995 operator <=(const FloatVar& l, const FloatVar& r);
00997 GECODE_MINIMODEL_EXPORT LinFloatRel
00998 operator <=(const FloatVar& l, const LinFloatExpr& r);
01000 GECODE_MINIMODEL_EXPORT LinFloatRel
01001 operator <=(const LinFloatExpr& l, const FloatVar& r);
01003 GECODE_MINIMODEL_EXPORT LinFloatRel
01004 operator <=(const LinFloatExpr& l, const LinFloatExpr& r);
01005
01007 GECODE_MINIMODEL_EXPORT LinFloatRel
01008 operator >(const FloatVal& l, const FloatVar& r);
01010 GECODE_MINIMODEL_EXPORT LinFloatRel
01011 operator >(const FloatVal& l, const LinFloatExpr& r);
01013 GECODE_MINIMODEL_EXPORT LinFloatRel
01014 operator >(const FloatVar& l, const FloatVal& r);
01016 GECODE_MINIMODEL_EXPORT LinFloatRel
01017 operator >(const LinFloatExpr& l, const FloatVal& r);
01019 GECODE_MINIMODEL_EXPORT LinFloatRel
01020 operator >(const FloatVar& l, const FloatVar& r);
01022 GECODE_MINIMODEL_EXPORT LinFloatRel
01023 operator >(const FloatVar& l, const LinFloatExpr& r);
01025 GECODE_MINIMODEL_EXPORT LinFloatRel
01026 operator >(const LinFloatExpr& l, const FloatVar& r);
01028 GECODE_MINIMODEL_EXPORT LinFloatRel
01029 operator >(const LinFloatExpr& l, const LinFloatExpr& r);
01030
01032 GECODE_MINIMODEL_EXPORT LinFloatRel
01033 operator >=(const FloatVal& l, const FloatVar& r);
01035 GECODE_MINIMODEL_EXPORT LinFloatRel
01036 operator >=(const FloatVal& l, const LinFloatExpr& r);
01038 GECODE_MINIMODEL_EXPORT LinFloatRel
01039 operator >=(const FloatVar& l, const FloatVal& r);
01041 GECODE_MINIMODEL_EXPORT LinFloatRel
01042 operator >=(const LinFloatExpr& l, const FloatVal& r);
01044 GECODE_MINIMODEL_EXPORT LinFloatRel
01045 operator >=(const FloatVar& l, const FloatVar& r);
01047 GECODE_MINIMODEL_EXPORT LinFloatRel
01048 operator >=(const FloatVar& l, const LinFloatExpr& r);
01050 GECODE_MINIMODEL_EXPORT LinFloatRel
01051 operator >=(const LinFloatExpr& l, const FloatVar& r);
01053 GECODE_MINIMODEL_EXPORT LinFloatRel
01054 operator >=(const LinFloatExpr& l, const LinFloatExpr& r);
01056 #endif
01057
01058 #ifdef GECODE_HAS_SET_VARS
01059
01060 class SetExpr {
01061 public:
01063 enum NodeType {
01064 NT_VAR,
01065 NT_CONST,
01066 NT_LEXP,
01067 NT_CMPL,
01068 NT_INTER,
01069 NT_UNION,
01070 NT_DUNION
01071 };
01073 class Node;
01074 private:
01076 Node* n;
01077 public:
01079 SetExpr(void);
01081 GECODE_MINIMODEL_EXPORT
01082 SetExpr(const SetExpr& e);
01084 GECODE_MINIMODEL_EXPORT
01085 SetExpr(const SetExpr& l, NodeType t, const SetExpr& r);
01087 GECODE_MINIMODEL_EXPORT
01088 SetExpr(const SetVar& x);
01090 GECODE_MINIMODEL_EXPORT
01091 explicit SetExpr(const LinIntExpr& x);
01093 GECODE_MINIMODEL_EXPORT
01094 SetExpr(const IntSet& s);
01096 GECODE_MINIMODEL_EXPORT
01097 SetExpr(const SetExpr& e, NodeType t);
01099 GECODE_MINIMODEL_EXPORT
01100 SetVar post(Home home) const;
01102 GECODE_MINIMODEL_EXPORT
01103 void post(Home home, SetRelType srt, const SetExpr& e) const;
01105 GECODE_MINIMODEL_EXPORT
01106 void post(Home home, BoolVar b, bool t,
01107 SetRelType srt, const SetExpr& e) const;
01109 GECODE_MINIMODEL_EXPORT
01110 const SetExpr& operator =(const SetExpr& e);
01112 GECODE_MINIMODEL_EXPORT
01113 ~SetExpr(void);
01114 };
01115
01117 class SetCmpRel {
01118 public:
01120 SetExpr l;
01122 SetExpr r;
01124 SetRelType srt;
01126 SetCmpRel(const SetExpr& l, SetRelType srt, const SetExpr& r);
01127 };
01128
01130 class SetRel {
01131 private:
01133 SetExpr _e0;
01135 SetRelType _srt;
01137 SetExpr _e1;
01138 public:
01140 SetRel(void);
01142 SetRel(const SetExpr& e0, SetRelType srt, const SetExpr& e1);
01144 SetRel(const SetCmpRel& r);
01146 void post(Home home, bool t) const;
01148 void post(Home home, BoolVar b, bool t) const;
01149 };
01150
01161
01162 GECODE_MINIMODEL_EXPORT SetExpr
01163 singleton(const LinIntExpr&);
01165 GECODE_MINIMODEL_EXPORT SetExpr
01166 operator -(const SetExpr&);
01168 GECODE_MINIMODEL_EXPORT SetExpr
01169 operator &(const SetExpr&, const SetExpr&);
01171 GECODE_MINIMODEL_EXPORT SetExpr
01172 operator |(const SetExpr&, const SetExpr&);
01174 GECODE_MINIMODEL_EXPORT SetExpr
01175 operator +(const SetExpr&, const SetExpr&);
01177 GECODE_MINIMODEL_EXPORT SetExpr
01178 operator -(const SetExpr&, const SetExpr&);
01179
01181 GECODE_MINIMODEL_EXPORT SetExpr
01182 inter(const SetVarArgs&);
01184 GECODE_MINIMODEL_EXPORT SetExpr
01185 setunion(const SetVarArgs&);
01187 GECODE_MINIMODEL_EXPORT SetExpr
01188 setdunion(const SetVarArgs&);
01189
01191 GECODE_MINIMODEL_EXPORT LinIntExpr
01192 cardinality(const SetExpr&);
01194 GECODE_MINIMODEL_EXPORT LinIntExpr
01195 min(const SetExpr&);
01197 GECODE_MINIMODEL_EXPORT LinIntExpr
01198 max(const SetExpr&);
01199
01201 GECODE_MINIMODEL_EXPORT SetRel
01202 operator ==(const SetExpr&, const SetExpr&);
01204 GECODE_MINIMODEL_EXPORT SetRel
01205 operator !=(const SetExpr&, const SetExpr&);
01207 GECODE_MINIMODEL_EXPORT SetCmpRel
01208 operator <=(const SetExpr&, const SetExpr&);
01210 GECODE_MINIMODEL_EXPORT BoolExpr
01211 operator <=(const SetCmpRel&, const SetExpr&);
01213 GECODE_MINIMODEL_EXPORT SetCmpRel
01214 operator >=(const SetExpr&, const SetExpr&);
01216 GECODE_MINIMODEL_EXPORT BoolExpr
01217 operator >=(const SetCmpRel&, const SetExpr&);
01219 GECODE_MINIMODEL_EXPORT SetRel
01220 operator ||(const SetExpr&, const SetExpr&);
01222 #endif
01223
01225 class BoolExpr {
01226 public:
01228 enum NodeType {
01229 NT_VAR,
01230 NT_NOT,
01231 NT_AND,
01232 NT_OR,
01233 NT_EQV,
01234 NT_RLIN,
01235 NT_RLINFLOAT,
01236 NT_RSET,
01237 NT_MISC
01238 };
01240 class GECODE_VTABLE_EXPORT Misc : public HeapAllocated {
01241 public:
01243 Misc(void);
01248 virtual void post(Home home, BoolVar b, bool neg,
01249 IntPropLevel ipl) = 0;
01251 virtual GECODE_MINIMODEL_EXPORT ~Misc(void);
01252 };
01254 class Node;
01255 private:
01257 Node* n;
01258 public:
01260 GECODE_MINIMODEL_EXPORT
01261 BoolExpr(void);
01263 GECODE_MINIMODEL_EXPORT
01264 BoolExpr(const BoolExpr& e);
01266 GECODE_MINIMODEL_EXPORT
01267 BoolExpr(const BoolExpr& l, NodeType t, const BoolExpr& r);
01269 GECODE_MINIMODEL_EXPORT
01270 BoolExpr(const BoolVar& x);
01272 GECODE_MINIMODEL_EXPORT
01273 BoolExpr(const BoolExpr& e, NodeType t);
01275 GECODE_MINIMODEL_EXPORT
01276 BoolExpr(const LinIntRel& rl);
01277 #ifdef GECODE_HAS_FLOAT_VARS
01278
01279 GECODE_MINIMODEL_EXPORT
01280 BoolExpr(const LinFloatRel& rfl);
01281 #endif
01282 #ifdef GECODE_HAS_SET_VARS
01283
01284 GECODE_MINIMODEL_EXPORT
01285 BoolExpr(const SetRel& rs);
01287 GECODE_MINIMODEL_EXPORT
01288 BoolExpr(const SetCmpRel& rs);
01289 #endif
01290
01291 GECODE_MINIMODEL_EXPORT
01292 explicit BoolExpr(Misc* m);
01294 GECODE_MINIMODEL_EXPORT
01295 BoolVar expr(Home home, IntPropLevel ipl) const;
01297 GECODE_MINIMODEL_EXPORT
01298 void rel(Home home, IntPropLevel ipl) const;
01300 GECODE_MINIMODEL_EXPORT
01301 const BoolExpr& operator =(const BoolExpr& e);
01303 GECODE_MINIMODEL_EXPORT
01304 ~BoolExpr(void);
01305 };
01306
01317
01318 GECODE_MINIMODEL_EXPORT BoolExpr
01319 operator !(const BoolExpr&);
01321 GECODE_MINIMODEL_EXPORT BoolExpr
01322 operator &&(const BoolExpr&, const BoolExpr&);
01324 GECODE_MINIMODEL_EXPORT BoolExpr
01325 operator ||(const BoolExpr&, const BoolExpr&);
01327 GECODE_MINIMODEL_EXPORT BoolExpr
01328 operator ^(const BoolExpr&, const BoolExpr&);
01329
01331 GECODE_MINIMODEL_EXPORT BoolExpr
01332 operator !=(const BoolExpr&, const BoolExpr&);
01334 GECODE_MINIMODEL_EXPORT BoolExpr
01335 operator ==(const BoolExpr&, const BoolExpr&);
01337 GECODE_MINIMODEL_EXPORT BoolExpr
01338 operator >>(const BoolExpr&, const BoolExpr&);
01340 GECODE_MINIMODEL_EXPORT BoolExpr
01341 operator <<(const BoolExpr&, const BoolExpr&);
01342
01344
01352
01353 GECODE_MINIMODEL_EXPORT BoolExpr
01354 dom(const IntVar& x, int n);
01356 GECODE_MINIMODEL_EXPORT BoolExpr
01357 dom(const IntVar& x, int l, int m);
01359 GECODE_MINIMODEL_EXPORT BoolExpr
01360 dom(const IntVar& x, const IntSet& s);
01361
01362 #ifdef GECODE_HAS_SET_VARS
01363
01364 GECODE_MINIMODEL_EXPORT BoolExpr
01365 dom(const SetVar& x, SetRelType rt, int i);
01367 GECODE_MINIMODEL_EXPORT BoolExpr
01368 dom(const SetVar& x, SetRelType rt, int i, int j);
01370 GECODE_MINIMODEL_EXPORT BoolExpr
01371 dom(const SetVar& x, SetRelType rt, const IntSet& s);
01372 #endif
01373
01374 #ifdef GECODE_HAS_FLOAT_VARS
01375
01376 GECODE_MINIMODEL_EXPORT BoolExpr
01377 dom(const FloatVar& x, const FloatVal& n);
01379 GECODE_MINIMODEL_EXPORT BoolExpr
01380 dom(const FloatVar& x, FloatNum l, FloatNum u);
01381 #endif
01382
01383
01391 #ifdef GECODE_HAS_SET_VARS
01392
01393 GECODE_MINIMODEL_EXPORT BoolExpr
01394 operator ==(const SetExpr& s, const LinIntExpr& x);
01396 GECODE_MINIMODEL_EXPORT BoolExpr
01397 operator ==(const LinIntExpr& x, const SetExpr& s);
01399 BoolExpr
01400 operator ==(const LinIntExpr&, IntSet) = delete;
01402 BoolExpr
01403 operator ==(IntSet, const LinIntExpr&) = delete;
01404
01406 GECODE_MINIMODEL_EXPORT BoolExpr
01407 operator !=(const SetExpr& s, const LinIntExpr& x);
01409 GECODE_MINIMODEL_EXPORT BoolExpr
01410 operator !=(const LinIntExpr& x, const SetExpr& s);
01412 BoolExpr
01413 operator !=(const LinIntExpr&, IntSet) = delete;
01415 BoolExpr
01416 operator !=(IntSet, const LinIntExpr&) = delete;
01417
01419 GECODE_MINIMODEL_EXPORT BoolExpr
01420 operator <=(const SetExpr& s, const LinIntExpr& x);
01422 GECODE_MINIMODEL_EXPORT BoolExpr
01423 operator <=(const LinIntExpr& x, const SetExpr& s);
01425 BoolExpr
01426 operator <=(const LinIntExpr&, IntSet) = delete;
01428 BoolExpr
01429 operator <=(IntSet, const LinIntExpr&) = delete;
01430
01432 GECODE_MINIMODEL_EXPORT BoolExpr
01433 operator <(const SetExpr& s, const LinIntExpr& x);
01435 GECODE_MINIMODEL_EXPORT BoolExpr
01436 operator <(const LinIntExpr& x, const SetExpr& s);
01438 BoolExpr
01439 operator <(const LinIntExpr&, IntSet) = delete;
01441 BoolExpr
01442 operator <(IntSet, const LinIntExpr&) = delete;
01443
01445 GECODE_MINIMODEL_EXPORT BoolExpr
01446 operator >=(const SetExpr& s, const LinIntExpr& x);
01448 GECODE_MINIMODEL_EXPORT BoolExpr
01449 operator >=(const LinIntExpr& x, const SetExpr& s);
01451 BoolExpr
01452 operator >=(const LinIntExpr&, IntSet) = delete;
01454 BoolExpr
01455 operator >=(IntSet, const LinIntExpr&) = delete;
01456
01458 GECODE_MINIMODEL_EXPORT BoolExpr
01459 operator >(const SetExpr& s, const LinIntExpr& x);
01461 GECODE_MINIMODEL_EXPORT BoolExpr
01462 operator >(const LinIntExpr& x, const SetExpr& s);
01464 BoolExpr
01465 operator >(const LinIntExpr&, IntSet) = delete;
01467 BoolExpr
01468 operator >(IntSet, const LinIntExpr&) = delete;
01469 #endif
01470
01471
01478
01479 GECODE_MINIMODEL_EXPORT IntVar
01480 expr(Home home, const LinIntExpr& e, IntPropLevel ipl=IPL_DEF);
01481 #ifdef GECODE_HAS_FLOAT_VARS
01482
01483 GECODE_MINIMODEL_EXPORT FloatVar
01484 expr(Home home, const LinFloatExpr& e);
01485 #endif
01486 #ifdef GECODE_HAS_SET_VARS
01487
01488 GECODE_MINIMODEL_EXPORT SetVar
01489 expr(Home home, const SetExpr& e);
01490 #endif
01491
01492 GECODE_MINIMODEL_EXPORT BoolVar
01493 expr(Home home, const BoolExpr& e, IntPropLevel ipl=IPL_DEF);
01495 GECODE_MINIMODEL_EXPORT void
01496 rel(Home home, const BoolExpr& e, IntPropLevel ipl=IPL_DEF);
01498
01499 }
01500
01501 #include <gecode/minimodel/int-rel.hpp>
01502 #include <gecode/minimodel/float-rel.hpp>
01503 #include <gecode/minimodel/bool-expr.hpp>
01504 #include <gecode/minimodel/set-expr.hpp>
01505 #include <gecode/minimodel/set-rel.hpp>
01506
01507 namespace Gecode {
01508
01509 namespace MiniModel {
01510 class ExpInfo;
01511 }
01512
01518 class GECODE_MINIMODEL_EXPORT REG {
01519 friend class MiniModel::ExpInfo;
01520 private:
01522 class Exp;
01524 Exp* e;
01526 REG(Exp* e);
01528 std::string toString(void) const;
01529 public:
01531 REG(void);
01533 REG(int s);
01540 REG(const IntArgs& x);
01541
01543 REG(const REG& r);
01545 const REG& operator =(const REG& r);
01546
01548 REG operator +(const REG& r);
01550 REG& operator +=(const REG& r);
01552 REG operator |(const REG& r);
01554 REG& operator |=(const REG& r);
01556 REG operator *(void);
01558 REG operator +(void);
01560 REG operator ()(unsigned int n, unsigned int m);
01562 REG operator ()(unsigned int n);
01564 template<class Char, class Traits>
01565 std::basic_ostream<Char,Traits>&
01566 print(std::basic_ostream<Char,Traits>& os) const;
01568 operator DFA(void);
01570 ~REG(void);
01571 };
01572
01576 template<class Char, class Traits>
01577 std::basic_ostream<Char,Traits>&
01578 operator <<(std::basic_ostream<Char,Traits>& os, const REG& r);
01579
01580 }
01581
01582 #include <gecode/minimodel/reg.hpp>
01583
01584 namespace Gecode {
01585
01592
01593 GECODE_MINIMODEL_EXPORT LinIntExpr
01594 abs(const LinIntExpr& e);
01596 GECODE_MINIMODEL_EXPORT LinIntExpr
01597 min(const LinIntExpr& x, const LinIntExpr& y);
01599 GECODE_MINIMODEL_EXPORT LinIntExpr
01600 min(const IntVarArgs& x);
01602 GECODE_MINIMODEL_EXPORT LinIntExpr
01603 max(const LinIntExpr& x, const LinIntExpr& y);
01605 GECODE_MINIMODEL_EXPORT LinIntExpr
01606 max(const IntVarArgs& x);
01607 #ifdef GECODE_HAS_FLOAT_VARS
01608
01609 GECODE_MINIMODEL_EXPORT LinFloatExpr
01610 operator *(const FloatVar&, const FloatVar&);
01612 GECODE_MINIMODEL_EXPORT LinFloatExpr
01613 operator *(const FloatVar&, const LinFloatExpr&);
01615 GECODE_MINIMODEL_EXPORT LinFloatExpr
01616 operator *(const LinFloatExpr&, const FloatVar&);
01617 #endif
01618
01619 GECODE_MINIMODEL_EXPORT LinIntExpr
01620 operator *(const LinIntExpr& x, const LinIntExpr& y);
01622 GECODE_MINIMODEL_EXPORT LinIntExpr
01623 operator /(const LinIntExpr& x, const LinIntExpr& y);
01625 GECODE_MINIMODEL_EXPORT LinIntExpr
01626 operator %(const LinIntExpr& x, const LinIntExpr& y);
01628 GECODE_MINIMODEL_EXPORT LinIntExpr
01629 sqr(const LinIntExpr& x);
01631 GECODE_MINIMODEL_EXPORT LinIntExpr
01632 sqrt(const LinIntExpr& x);
01634 GECODE_MINIMODEL_EXPORT LinIntExpr
01635 pow(const LinIntExpr& x, int n);
01637 GECODE_MINIMODEL_EXPORT LinIntExpr
01638 nroot(const LinIntExpr& x, int n);
01640 GECODE_MINIMODEL_EXPORT LinIntExpr
01641 element(const IntVarArgs& x, const LinIntExpr& y);
01643 GECODE_MINIMODEL_EXPORT BoolExpr
01644 element(const BoolVarArgs& x, const LinIntExpr& y);
01646 GECODE_MINIMODEL_EXPORT LinIntExpr
01647 element(const IntArgs& x, const LinIntExpr& y);
01649 GECODE_MINIMODEL_EXPORT LinIntExpr
01650 ite(const BoolExpr& b, const LinIntExpr& x, const LinIntExpr& y);
01652
01653 #ifdef GECODE_HAS_FLOAT_VARS
01654
01655 GECODE_MINIMODEL_EXPORT LinFloatExpr
01656 abs(const LinFloatExpr& e);
01658 GECODE_MINIMODEL_EXPORT LinFloatExpr
01659 min(const LinFloatExpr& x, const LinFloatExpr& y);
01661 GECODE_MINIMODEL_EXPORT LinFloatExpr
01662 min(const FloatVarArgs& x);
01664 GECODE_MINIMODEL_EXPORT LinFloatExpr
01665 max(const LinFloatExpr& x, const LinFloatExpr& y);
01667 GECODE_MINIMODEL_EXPORT LinFloatExpr
01668 max(const FloatVarArgs& x);
01670 GECODE_MINIMODEL_EXPORT LinFloatExpr
01671 operator *(const LinFloatExpr& x, const LinFloatExpr& y);
01673 GECODE_MINIMODEL_EXPORT LinFloatExpr
01674 operator /(const LinFloatExpr& x, const LinFloatExpr& y);
01676 GECODE_MINIMODEL_EXPORT LinFloatExpr
01677 sqr(const LinFloatExpr& x);
01679 GECODE_MINIMODEL_EXPORT LinFloatExpr
01680 sqrt(const LinFloatExpr& x);
01682 GECODE_MINIMODEL_EXPORT LinFloatExpr
01683 pow(const LinFloatExpr& x, int n);
01685 GECODE_MINIMODEL_EXPORT LinFloatExpr
01686 nroot(const LinFloatExpr& x, int n);
01688
01689 #ifdef GECODE_HAS_MPFR
01690
01696
01697 GECODE_MINIMODEL_EXPORT LinFloatExpr
01698 exp(const LinFloatExpr& x);
01700 GECODE_MINIMODEL_EXPORT LinFloatExpr
01701 log(const LinFloatExpr& x);
01703
01710
01711 GECODE_MINIMODEL_EXPORT LinFloatExpr
01712 asin(const LinFloatExpr& x);
01714 GECODE_MINIMODEL_EXPORT LinFloatExpr
01715 sin(const LinFloatExpr& x);
01717 GECODE_MINIMODEL_EXPORT LinFloatExpr
01718 acos(const LinFloatExpr& x);
01720 GECODE_MINIMODEL_EXPORT LinFloatExpr
01721 cos(const LinFloatExpr& x);
01723 GECODE_MINIMODEL_EXPORT LinFloatExpr
01724 atan(const LinFloatExpr& x);
01726 GECODE_MINIMODEL_EXPORT LinFloatExpr
01727 tan(const LinFloatExpr& x);
01729 #endif
01730 #endif
01731
01738
01739 inline BoolVar
01740 channel(Home home, IntVar x,
01741 IntPropLevel ipl=IPL_DEF) {
01742 (void) ipl;
01743 BoolVar b(home,0,1); channel(home,b,x);
01744 return b;
01745 }
01747 inline IntVar
01748 channel(Home home, BoolVar b,
01749 IntPropLevel ipl=IPL_DEF) {
01750 (void) ipl;
01751 IntVar x(home,0,1); channel(home,b,x);
01752 return x;
01753 }
01754 #ifdef GECODE_HAS_FLOAT_VARS
01755
01756 inline IntVar
01757 channel(Home home, FloatVar f) {
01758 int min = static_cast<int>(std::max(static_cast<double>(Int::Limits::min),
01759 std::ceil(f.min())));
01760 int max = static_cast<int>(std::min(static_cast<double>(Int::Limits::max),
01761 std::floor(f.max())));
01762 IntVar x(home,min,max);
01763 channel(home,f,x);
01764 return x;
01765 }
01766 #endif
01767 #ifdef GECODE_HAS_SET_VARS
01768
01769 inline SetVar
01770 channel(Home home, const IntVarArgs& x, IntPropLevel ipl=IPL_DEF) {
01771 (void) ipl;
01772 SetVar s(home,IntSet::empty,Set::Limits::min,Set::Limits::max);
01773 rel(home,SOT_UNION,x,s);
01774 nvalues(home,x,IRT_EQ,expr(home,cardinality(s)));
01775 return s;
01776 }
01777 #endif
01778
01779
01780 }
01781
01782 namespace Gecode {
01783
01798 inline void
01799 atmost(Home home, const IntVarArgs& x, int n, int m,
01800 IntPropLevel ipl=IPL_DEF) {
01801 count(home,x,n,IRT_LQ,m,ipl);
01802 }
01807 inline void
01808 atmost(Home home, const IntVarArgs& x, IntVar y, int m,
01809 IntPropLevel ipl=IPL_DEF) {
01810 count(home,x,y,IRT_LQ,m,ipl);
01811 }
01819 inline void
01820 atmost(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01821 IntPropLevel ipl=IPL_DEF) {
01822 count(home,x,y,IRT_LQ,m,ipl);
01823 }
01828 inline void
01829 atmost(Home home, const IntVarArgs& x, int n, IntVar z,
01830 IntPropLevel ipl=IPL_DEF) {
01831 count(home,x,n,IRT_LQ,z,ipl);
01832 }
01837 inline void
01838 atmost(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01839 IntPropLevel ipl=IPL_DEF) {
01840 count(home,x,y,IRT_LQ,z,ipl);
01841 }
01849 inline void
01850 atmost(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01851 IntPropLevel ipl=IPL_DEF) {
01852 count(home,x,y,IRT_LQ,z,ipl);
01853 }
01854
01859 inline void
01860 atleast(Home home, const IntVarArgs& x, int n, int m,
01861 IntPropLevel ipl=IPL_DEF) {
01862 count(home,x,n,IRT_GQ,m,ipl);
01863 }
01868 inline void
01869 atleast(Home home, const IntVarArgs& x, IntVar y, int m,
01870 IntPropLevel ipl=IPL_DEF) {
01871 count(home,x,y,IRT_GQ,m,ipl);
01872 }
01880 inline void
01881 atleast(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01882 IntPropLevel ipl=IPL_DEF) {
01883 count(home,x,y,IRT_GQ,m,ipl);
01884 }
01889 inline void
01890 atleast(Home home, const IntVarArgs& x, int n, IntVar z,
01891 IntPropLevel ipl=IPL_DEF) {
01892 count(home,x,n,IRT_GQ,z,ipl);
01893 }
01898 inline void
01899 atleast(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01900 IntPropLevel ipl=IPL_DEF) {
01901 count(home,x,y,IRT_GQ,z,ipl);
01902 }
01910 inline void
01911 atleast(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01912 IntPropLevel ipl=IPL_DEF) {
01913 count(home,x,y,IRT_GQ,z,ipl);
01914 }
01915
01920 inline void
01921 exactly(Home home, const IntVarArgs& x, int n, int m,
01922 IntPropLevel ipl=IPL_DEF) {
01923 count(home,x,n,IRT_EQ,m,ipl);
01924 }
01929 inline void
01930 exactly(Home home, const IntVarArgs& x, IntVar y, int m,
01931 IntPropLevel ipl=IPL_DEF) {
01932 count(home,x,y,IRT_EQ,m,ipl);
01933 }
01941 inline void
01942 exactly(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01943 IntPropLevel ipl=IPL_DEF) {
01944 count(home,x,y,IRT_EQ,m,ipl);
01945 }
01950 inline void
01951 exactly(Home home, const IntVarArgs& x, int n, IntVar z,
01952 IntPropLevel ipl=IPL_DEF) {
01953 count(home,x,n,IRT_EQ,z,ipl);
01954 }
01959 inline void
01960 exactly(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01961 IntPropLevel ipl=IPL_DEF) {
01962 count(home,x,y,IRT_EQ,z,ipl);
01963 }
01971 inline void
01972 exactly(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01973 IntPropLevel ipl=IPL_DEF) {
01974 count(home,x,y,IRT_EQ,z,ipl);
01975 }
01978 inline void
01979 lex(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
01980 IntPropLevel ipl=IPL_DEF) {
01981 rel(home,x,r,y,ipl);
01982 }
01985 inline void
01986 lex(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
01987 IntPropLevel ipl=IPL_DEF) {
01988 rel(home,x,r,y,ipl);
01989 }
01992 inline void
01993 values(Home home, const IntVarArgs& x, IntSet y,
01994 IntPropLevel ipl=IPL_DEF) {
01995 dom(home,x,y,ipl);
01996 nvalues(home,x,IRT_EQ,static_cast<int>(y.size()),ipl);
01997 }
01998
02000
02001 #ifdef GECODE_HAS_SET_VARS
02002
02017 inline void
02018 channel(Home home, const IntVarArgs& x, SetVar y) {
02019 rel(home,SOT_UNION,x,y);
02020 nvalues(home,x,IRT_EQ,expr(home,cardinality(y)));
02021 }
02022
02025 inline void
02026 range(Home home, const IntVarArgs& x, SetVar y, SetVar z) {
02027 element(home,SOT_UNION,x,y,z);
02028 }
02029
02035 inline void
02036 roots(Home home, const IntVarArgs& x, SetVar y, SetVar z) {
02037 SetVarArgs xiv(home,z.lubMax()+1,IntSet::empty,0,x.size()-1);
02038 channel(home,x,xiv);
02039 element(home,SOT_UNION,xiv,z,y);
02040 }
02041
02043 #endif
02044 }
02045
02046 namespace Gecode {
02047
02048 template<class> class Matrix;
02049
02057 template<class A>
02058 class Slice {
02059 public:
02061 typedef typename ArrayTraits<A>::ArgsType ArgsType;
02062 private:
02063 ArgsType _r;
02064 int _fc,
02065 _tc,
02066 _fr,
02067 _tr;
02068 public:
02070 Slice(const Matrix<A>& a, int fc, int tc, int fr, int tr);
02074 Slice& reverse(void);
02076 operator ArgsType(void);
02078 operator Matrix<ArgsType>(void);
02079
02081 operator const ArgsType(void) const;
02083 operator const Matrix<ArgsType>(void) const;
02084 };
02085
02087 template<class A>
02088 typename Slice<A>::ArgsType
02089 operator+(const Slice<A>& x, const Slice<A>& y);
02090
02092 template<class A>
02093 typename Slice<A>::ArgsType
02094 operator+(const Slice<A>& x, const typename ArrayTraits<A>::ArgsType& y);
02095
02097 template<class A>
02098 typename Slice<A>::ArgsType
02099 operator+(const typename ArrayTraits<A>::ArgsType& x, const Slice<A>& y);
02100
02102 template<class A>
02103 typename Slice<A>::ArgsType
02104 operator+(const Slice<A>& x, const typename ArrayTraits<A>::ValueType& y);
02105
02107 template<class A>
02108 typename Slice<A>::ArgsType
02109 operator+(const typename ArrayTraits<A>::ValueType& x, const Slice<A>& y);
02110
02121 template<class A>
02122 class Matrix {
02123 public:
02125 typedef typename ArrayTraits<A>::ValueType ValueType;
02127 typedef typename ArrayTraits<A>::ArgsType ArgsType;
02128
02129 private:
02131 typedef typename ArrayTraits<A>::StorageType StorageType;
02132 StorageType _a;
02133 int _w;
02134 int _h;
02135
02136 public:
02149 Matrix(A a, int w, int h);
02150
02163 Matrix(A a, int n);
02164
02166 int width(void) const;
02168 int height(void) const;
02170 ArgsType const get_array(void) const;
02171
02177 ValueType& operator ()(int c, int r);
02178
02184 const ValueType& operator ()(int c, int r) const;
02185
02195 Slice<A> slice(int fc, int tc, int fr, int tr) const;
02196
02198 Slice<A> row(int r) const;
02199
02201 Slice<A> col(int c) const;
02202 };
02203
02207 template<class Char, class Traits, class A>
02208 std::basic_ostream<Char,Traits>&
02209 operator <<(std::basic_ostream<Char,Traits>& os, const Matrix<A>& m);
02210
02214 template<class Char, class Traits, class A>
02215 std::basic_ostream<Char,Traits>&
02216 operator <<(std::basic_ostream<Char,Traits>& os, const Slice<A>& s);
02217
02224 void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,
02225 IntVar z, IntPropLevel ipl=IPL_DEF);
02232 void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,
02233 BoolVar z, IntPropLevel ipl=IPL_DEF);
02240 void element(Home home, const Matrix<IntVarArgs>& m, IntVar x, IntVar y,
02241 IntVar z, IntPropLevel ipl=IPL_DEF);
02248 void element(Home home, const Matrix<BoolVarArgs>& m, IntVar x, IntVar y,
02249 BoolVar z, IntPropLevel ipl=IPL_DEF);
02250 #ifdef GECODE_HAS_SET_VARS
02251
02257 void element(Home home, const Matrix<IntSetArgs>& m, IntVar x, IntVar y,
02258 SetVar z);
02265 void element(Home home, const Matrix<SetVarArgs>& m, IntVar x, IntVar y,
02266 SetVar z);
02267 #endif
02268
02272 template<class A>
02273 SymmetryHandle rows_interchange(const Matrix<A>& m);
02277 template<class A>
02278 SymmetryHandle columns_interchange(const Matrix<A>& m);
02282 template<class A>
02283 SymmetryHandle rows_reflect(const Matrix<A>& m);
02287 template<class A>
02288 SymmetryHandle columns_reflect(const Matrix<A>& m);
02294 template<class A>
02295 SymmetryHandle diagonal_reflect(const Matrix<A>& m);
02296 }
02297
02298 #include <gecode/minimodel/matrix.hpp>
02299 #include <gecode/minimodel/ldsb.hpp>
02300
02305 namespace Gecode {
02306
02308 GECODE_MINIMODEL_EXPORT LinIntExpr
02309 sum(const Slice<IntArgs>& slice);
02311 GECODE_MINIMODEL_EXPORT LinIntExpr
02312 sum(const Matrix<IntArgs>& matrix);
02313
02314 }
02317 namespace Gecode {
02318
02332 class GECODE_VTABLE_EXPORT IntMinimizeSpace : public Space {
02333 public:
02335 IntMinimizeSpace(void);
02337 IntMinimizeSpace(IntMinimizeSpace& s);
02339 GECODE_MINIMODEL_EXPORT
02340 virtual void constrain(const Space& best);
02342 virtual IntVar cost(void) const = 0;
02343 };
02344
02349 class GECODE_VTABLE_EXPORT IntMaximizeSpace : public Space {
02350 public:
02352 IntMaximizeSpace(void);
02354 IntMaximizeSpace(IntMaximizeSpace& s);
02356 GECODE_MINIMODEL_EXPORT
02357 virtual void constrain(const Space& best);
02359 virtual IntVar cost(void) const = 0;
02360 };
02361
02366 class GECODE_VTABLE_EXPORT IntLexMinimizeSpace : public Space {
02367 public:
02369 IntLexMinimizeSpace(void);
02371 IntLexMinimizeSpace(IntLexMinimizeSpace& s);
02373 GECODE_MINIMODEL_EXPORT
02374 virtual void constrain(const Space& best);
02376 virtual IntVarArgs cost(void) const = 0;
02377 };
02378
02383 class GECODE_VTABLE_EXPORT IntLexMaximizeSpace : public Space {
02384 public:
02386 IntLexMaximizeSpace(void);
02388 IntLexMaximizeSpace(IntLexMaximizeSpace& s);
02390 GECODE_MINIMODEL_EXPORT
02391 virtual void constrain(const Space& best);
02393 virtual IntVarArgs cost(void) const = 0;
02394 };
02395
02396 #ifdef GECODE_HAS_FLOAT_VARS
02397
02407 class GECODE_VTABLE_EXPORT FloatMinimizeSpace : public Space {
02408 protected:
02410 FloatNum step;
02411 public:
02413 FloatMinimizeSpace(FloatNum s=0.0);
02415 FloatMinimizeSpace(FloatMinimizeSpace& s);
02417 GECODE_MINIMODEL_EXPORT
02418 virtual void constrain(const Space& best);
02420 virtual FloatVar cost(void) const = 0;
02421 };
02422
02432 class GECODE_VTABLE_EXPORT FloatMaximizeSpace : public Space {
02433 protected:
02435 FloatNum step;
02436 public:
02438 FloatMaximizeSpace(FloatNum s=0.0);
02440 FloatMaximizeSpace(FloatMaximizeSpace& s);
02442 GECODE_MINIMODEL_EXPORT
02443 virtual void constrain(const Space& best);
02445 virtual FloatVar cost(void) const = 0;
02446 };
02447
02448 #endif
02449
02450 }
02451
02452 #include <gecode/minimodel/optimize.hpp>
02453
02454 #endif
02455
02456
02457
02458