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
00043
00044 #ifndef __GECODE_MINIMODEL_HH__
00045 #define __GECODE_MINIMODEL_HH__
00046
00047 #include <gecode/kernel.hh>
00048 #include <gecode/int.hh>
00049 #ifdef GECODE_HAS_SET_VARS
00050 #include <gecode/set.hh>
00051 #endif
00052 #ifdef GECODE_HAS_FLOAT_VARS
00053 #include <gecode/float.hh>
00054 #endif
00055
00056 #include <iostream>
00057
00058
00059
00060
00061
00062
00063 #if !defined(GECODE_STATIC_LIBS) && \
00064 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00065
00066 #ifdef GECODE_BUILD_MINIMODEL
00067 #define GECODE_MINIMODEL_EXPORT __declspec( dllexport )
00068 #else
00069 #define GECODE_MINIMODEL_EXPORT __declspec( dllimport )
00070 #endif
00071
00072 #else
00073
00074 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00075
00076 #define GECODE_MINIMODEL_EXPORT __attribute__ ((visibility("default")))
00077
00078 #else
00079
00080 #define GECODE_MINIMODEL_EXPORT
00081
00082 #endif
00083 #endif
00084
00085
00086 #ifndef GECODE_BUILD_MINIMODEL
00087 #define GECODE_LIBRARY_NAME "MiniModel"
00088 #include <gecode/support/auto-link.hpp>
00089 #endif
00090
00091 namespace Gecode {
00092
00094 namespace MiniModel {}
00095
00096 }
00097
00098 #include <gecode/minimodel/exception.hpp>
00099
00100 namespace Gecode {
00101
00102 class LinIntRel;
00103 #ifdef GECODE_HAS_SET_VARS
00104 class SetExpr;
00105 #endif
00106 #ifdef GECODE_HAS_FLOAT_VARS
00107 class LinFloatExpr;
00108 #endif
00109
00111 class NonLinIntExpr {
00112 public:
00114 virtual IntVar post(Home home, IntVar* ret, IntPropLevel ipl) const = 0;
00116 virtual void post(Home home, IntRelType irt, int c,
00117 IntPropLevel ipl) const = 0;
00119 virtual void post(Home home, IntRelType irt, int c,
00120 BoolVar b, IntPropLevel ipl) const = 0;
00122 virtual ~NonLinIntExpr(void) {}
00124 static IntVar result(Home home, IntVar* x) {
00125 if (x==NULL)
00126 return IntVar(home,Int::Limits::min,Int::Limits::max);
00127 return *x;
00128 }
00130 static IntVar result(Home home, IntVar* x, IntVar y) {
00131 if (x!=NULL)
00132 rel(home,*x,IRT_EQ,y);
00133 return y;
00134 }
00136 void* operator new(size_t size) { return heap.ralloc(size); }
00138 void operator delete(void* p, size_t) { heap.rfree(p); }
00139 };
00140
00142 class LinIntExpr {
00143 friend class LinIntRel;
00144 #ifdef GECODE_HAS_SET_VARS
00145 friend class SetExpr;
00146 #endif
00147 #ifdef GECODE_HAS_FLOAT_VARS
00148 friend class LinFloatExpr;
00149 #endif
00150 public:
00152 enum NodeType {
00153 NT_CONST,
00154 NT_VAR_INT,
00155 NT_VAR_BOOL,
00156 NT_NONLIN,
00157 NT_SUM_INT,
00158 NT_SUM_BOOL,
00159 NT_ADD,
00160 NT_SUB,
00161 NT_MUL
00162 };
00163 private:
00165 class Node;
00167 Node* n;
00168 public:
00170 GECODE_MINIMODEL_EXPORT
00171 LinIntExpr(void);
00173 GECODE_MINIMODEL_EXPORT
00174 LinIntExpr(int c);
00176 GECODE_MINIMODEL_EXPORT
00177 LinIntExpr(const IntVar& x, int a=1);
00179 GECODE_MINIMODEL_EXPORT
00180 LinIntExpr(const BoolVar& x, int a=1);
00182 GECODE_MINIMODEL_EXPORT
00183 explicit LinIntExpr(const IntVarArgs& x);
00185 GECODE_MINIMODEL_EXPORT
00186 LinIntExpr(const IntArgs& a, const IntVarArgs& x);
00188 GECODE_MINIMODEL_EXPORT
00189 explicit LinIntExpr(const BoolVarArgs& x);
00191 GECODE_MINIMODEL_EXPORT
00192 LinIntExpr(const IntArgs& a, const BoolVarArgs& x);
00194 GECODE_MINIMODEL_EXPORT
00195 LinIntExpr(const LinIntExpr& e);
00197 GECODE_MINIMODEL_EXPORT
00198 LinIntExpr(const LinIntExpr& e0, NodeType t, const LinIntExpr& e1);
00200 GECODE_MINIMODEL_EXPORT
00201 LinIntExpr(const LinIntExpr& e0, NodeType t, int c);
00203 GECODE_MINIMODEL_EXPORT
00204 LinIntExpr(int a, const LinIntExpr& e);
00206 GECODE_MINIMODEL_EXPORT
00207 explicit LinIntExpr(NonLinIntExpr* e);
00209 GECODE_MINIMODEL_EXPORT
00210 const LinIntExpr& operator =(const LinIntExpr& e);
00212 GECODE_MINIMODEL_EXPORT
00213 void post(Home home, IntRelType irt, IntPropLevel ipl) const;
00215 GECODE_MINIMODEL_EXPORT
00216 void post(Home home, IntRelType irt, const BoolVar& b,
00217 IntPropLevel ipl) const;
00219 GECODE_MINIMODEL_EXPORT
00220 IntVar post(Home home, IntPropLevel ipl) const;
00222 GECODE_MINIMODEL_EXPORT
00223 NonLinIntExpr* nle(void) const;
00225 GECODE_MINIMODEL_EXPORT
00226 ~LinIntExpr(void);
00227 };
00228
00229 class BoolExpr;
00230
00232 class LinIntRel {
00233 friend class BoolExpr;
00234 private:
00236 LinIntExpr e;
00238 IntRelType irt;
00240 static IntRelType neg(IntRelType irt);
00242 LinIntRel(void);
00243 public:
00245 LinIntRel(const LinIntExpr& l, IntRelType irt, const LinIntExpr& r);
00247 LinIntRel(const LinIntExpr& l, IntRelType irt, int r);
00249 LinIntRel(int l, IntRelType irt, const LinIntExpr& r);
00251 void post(Home home, bool t, IntPropLevel ipl) const;
00253 void post(Home home, const BoolVar& b, bool t, IntPropLevel ipl) const;
00254 };
00255
00274
00275 GECODE_MINIMODEL_EXPORT LinIntExpr
00276 operator +(int, const IntVar&);
00278 GECODE_MINIMODEL_EXPORT LinIntExpr
00279 operator +(int, const BoolVar&);
00281 GECODE_MINIMODEL_EXPORT LinIntExpr
00282 operator +(int, const LinIntExpr&);
00284 GECODE_MINIMODEL_EXPORT LinIntExpr
00285 operator +(const IntVar&, int);
00287 GECODE_MINIMODEL_EXPORT LinIntExpr
00288 operator +(const BoolVar&, int);
00290 GECODE_MINIMODEL_EXPORT LinIntExpr
00291 operator +(const LinIntExpr&, int);
00293 GECODE_MINIMODEL_EXPORT LinIntExpr
00294 operator +(const IntVar&, const IntVar&);
00296 GECODE_MINIMODEL_EXPORT LinIntExpr
00297 operator +(const IntVar&, const BoolVar&);
00299 GECODE_MINIMODEL_EXPORT LinIntExpr
00300 operator +(const BoolVar&, const IntVar&);
00302 GECODE_MINIMODEL_EXPORT LinIntExpr
00303 operator +(const BoolVar&, const BoolVar&);
00305 GECODE_MINIMODEL_EXPORT LinIntExpr
00306 operator +(const IntVar&, const LinIntExpr&);
00308 GECODE_MINIMODEL_EXPORT LinIntExpr
00309 operator +(const BoolVar&, const LinIntExpr&);
00311 GECODE_MINIMODEL_EXPORT LinIntExpr
00312 operator +(const LinIntExpr&, const IntVar&);
00314 GECODE_MINIMODEL_EXPORT LinIntExpr
00315 operator +(const LinIntExpr&, const BoolVar&);
00317 GECODE_MINIMODEL_EXPORT LinIntExpr
00318 operator +(const LinIntExpr&, const LinIntExpr&);
00319
00321 GECODE_MINIMODEL_EXPORT LinIntExpr
00322 operator -(int, const IntVar&);
00324 GECODE_MINIMODEL_EXPORT LinIntExpr
00325 operator -(int, const BoolVar&);
00327 GECODE_MINIMODEL_EXPORT LinIntExpr
00328 operator -(int, const LinIntExpr&);
00330 GECODE_MINIMODEL_EXPORT LinIntExpr
00331 operator -(const IntVar&, int);
00333 GECODE_MINIMODEL_EXPORT LinIntExpr
00334 operator -(const BoolVar&, int);
00336 GECODE_MINIMODEL_EXPORT LinIntExpr
00337 operator -(const LinIntExpr&, int);
00339 GECODE_MINIMODEL_EXPORT LinIntExpr
00340 operator -(const IntVar&, const IntVar&);
00342 GECODE_MINIMODEL_EXPORT LinIntExpr
00343 operator -(const IntVar&, const BoolVar&);
00345 GECODE_MINIMODEL_EXPORT LinIntExpr
00346 operator -(const BoolVar&, const IntVar&);
00348 GECODE_MINIMODEL_EXPORT LinIntExpr
00349 operator -(const BoolVar&, const BoolVar&);
00351 GECODE_MINIMODEL_EXPORT LinIntExpr
00352 operator -(const IntVar&, const LinIntExpr&);
00354 GECODE_MINIMODEL_EXPORT LinIntExpr
00355 operator -(const BoolVar&, const LinIntExpr&);
00357 GECODE_MINIMODEL_EXPORT LinIntExpr
00358 operator -(const LinIntExpr&, const IntVar&);
00360 GECODE_MINIMODEL_EXPORT LinIntExpr
00361 operator -(const LinIntExpr&, const BoolVar&);
00363 GECODE_MINIMODEL_EXPORT LinIntExpr
00364 operator -(const LinIntExpr&, const LinIntExpr&);
00365
00367 GECODE_MINIMODEL_EXPORT LinIntExpr
00368 operator -(const IntVar&);
00370 GECODE_MINIMODEL_EXPORT LinIntExpr
00371 operator -(const BoolVar&);
00373 GECODE_MINIMODEL_EXPORT LinIntExpr
00374 operator -(const LinIntExpr&);
00375
00377 GECODE_MINIMODEL_EXPORT LinIntExpr
00378 operator *(int, const IntVar&);
00380 GECODE_MINIMODEL_EXPORT LinIntExpr
00381 operator *(int, const BoolVar&);
00383 GECODE_MINIMODEL_EXPORT LinIntExpr
00384 operator *(const IntVar&, int);
00386 GECODE_MINIMODEL_EXPORT LinIntExpr
00387 operator *(const BoolVar&, int);
00389 GECODE_MINIMODEL_EXPORT LinIntExpr
00390 operator *(const LinIntExpr&, int);
00392 GECODE_MINIMODEL_EXPORT LinIntExpr
00393 operator *(int, const LinIntExpr&);
00394
00396 GECODE_MINIMODEL_EXPORT LinIntExpr
00397 sum(const IntVarArgs& x);
00399 GECODE_MINIMODEL_EXPORT LinIntExpr
00400 sum(const IntArgs& a, const IntVarArgs& x);
00402 GECODE_MINIMODEL_EXPORT LinIntExpr
00403 sum(const BoolVarArgs& x);
00405 GECODE_MINIMODEL_EXPORT LinIntExpr
00406 sum(const IntArgs& a, const BoolVarArgs& x);
00408 GECODE_MINIMODEL_EXPORT LinIntExpr
00409 sum(const IntArgs& args);
00410
00412 GECODE_MINIMODEL_EXPORT LinIntRel
00413 operator ==(int l, const IntVar& r);
00415 GECODE_MINIMODEL_EXPORT LinIntRel
00416 operator ==(int l, const BoolVar& r);
00418 GECODE_MINIMODEL_EXPORT LinIntRel
00419 operator ==(int l, const LinIntExpr& r);
00421 GECODE_MINIMODEL_EXPORT LinIntRel
00422 operator ==(const IntVar& l, int r);
00424 GECODE_MINIMODEL_EXPORT LinIntRel
00425 operator ==(const BoolVar& l, int r);
00427 GECODE_MINIMODEL_EXPORT LinIntRel
00428 operator ==(const LinIntExpr& l, int r);
00430 GECODE_MINIMODEL_EXPORT LinIntRel
00431 operator ==(const IntVar& l, const IntVar& r);
00433 GECODE_MINIMODEL_EXPORT LinIntRel
00434 operator ==(const IntVar& l, const BoolVar& r);
00436 GECODE_MINIMODEL_EXPORT LinIntRel
00437 operator ==(const BoolVar& l, const IntVar& r);
00439 GECODE_MINIMODEL_EXPORT LinIntRel
00440 operator ==(const BoolVar& l, const BoolVar& r);
00442 GECODE_MINIMODEL_EXPORT LinIntRel
00443 operator ==(const IntVar& l, const LinIntExpr& r);
00445 GECODE_MINIMODEL_EXPORT LinIntRel
00446 operator ==(const BoolVar& l, const LinIntExpr& r);
00448 GECODE_MINIMODEL_EXPORT LinIntRel
00449 operator ==(const LinIntExpr& l, const IntVar& r);
00451 GECODE_MINIMODEL_EXPORT LinIntRel
00452 operator ==(const LinIntExpr& l, const BoolVar& r);
00454 GECODE_MINIMODEL_EXPORT LinIntRel
00455 operator ==(const LinIntExpr& l, const LinIntExpr& r);
00456
00458 GECODE_MINIMODEL_EXPORT LinIntRel
00459 operator !=(int l, const IntVar& r);
00461 GECODE_MINIMODEL_EXPORT LinIntRel
00462 operator !=(int l, const BoolVar& r);
00464 GECODE_MINIMODEL_EXPORT LinIntRel
00465 operator !=(int l, const LinIntExpr& r);
00467 GECODE_MINIMODEL_EXPORT LinIntRel
00468 operator !=(const IntVar& l, int r);
00470 GECODE_MINIMODEL_EXPORT LinIntRel
00471 operator !=(const BoolVar& l, int r);
00473 GECODE_MINIMODEL_EXPORT LinIntRel
00474 operator !=(const LinIntExpr& l, int r);
00476 GECODE_MINIMODEL_EXPORT LinIntRel
00477 operator !=(const IntVar& l, const IntVar& r);
00479 GECODE_MINIMODEL_EXPORT LinIntRel
00480 operator !=(const IntVar& l, const BoolVar& r);
00482 GECODE_MINIMODEL_EXPORT LinIntRel
00483 operator !=(const BoolVar& l, const IntVar& r);
00485 GECODE_MINIMODEL_EXPORT LinIntRel
00486 operator !=(const BoolVar& l, const BoolVar& r);
00488 GECODE_MINIMODEL_EXPORT LinIntRel
00489 operator !=(const IntVar& l, const LinIntExpr& r);
00491 GECODE_MINIMODEL_EXPORT LinIntRel
00492 operator !=(const BoolVar& l, const LinIntExpr& r);
00494 GECODE_MINIMODEL_EXPORT LinIntRel
00495 operator !=(const LinIntExpr& l, const IntVar& r);
00497 GECODE_MINIMODEL_EXPORT LinIntRel
00498 operator !=(const LinIntExpr& l, const BoolVar& r);
00500 GECODE_MINIMODEL_EXPORT LinIntRel
00501 operator !=(const LinIntExpr& l, const LinIntExpr& r);
00502
00504 GECODE_MINIMODEL_EXPORT LinIntRel
00505 operator <(int l, const IntVar& r);
00507 GECODE_MINIMODEL_EXPORT LinIntRel
00508 operator <(int l, const BoolVar& r);
00510 GECODE_MINIMODEL_EXPORT LinIntRel
00511 operator <(int l, const LinIntExpr& r);
00513 GECODE_MINIMODEL_EXPORT LinIntRel
00514 operator <(const IntVar& l, int r);
00516 GECODE_MINIMODEL_EXPORT LinIntRel
00517 operator <(const BoolVar& l, int r);
00519 GECODE_MINIMODEL_EXPORT LinIntRel
00520 operator <(const LinIntExpr& l, int r);
00522 GECODE_MINIMODEL_EXPORT LinIntRel
00523 operator <(const IntVar& l, const IntVar& r);
00525 GECODE_MINIMODEL_EXPORT LinIntRel
00526 operator <(const IntVar& l, const BoolVar& r);
00528 GECODE_MINIMODEL_EXPORT LinIntRel
00529 operator <(const BoolVar& l, const IntVar& r);
00531 GECODE_MINIMODEL_EXPORT LinIntRel
00532 operator <(const BoolVar& l, const BoolVar& r);
00534 GECODE_MINIMODEL_EXPORT LinIntRel
00535 operator <(const IntVar& l, const LinIntExpr& r);
00537 GECODE_MINIMODEL_EXPORT LinIntRel
00538 operator <(const BoolVar& l, const LinIntExpr& r);
00540 GECODE_MINIMODEL_EXPORT LinIntRel
00541 operator <(const LinIntExpr& l, const IntVar& r);
00543 GECODE_MINIMODEL_EXPORT LinIntRel
00544 operator <(const LinIntExpr& l, const BoolVar& r);
00546 GECODE_MINIMODEL_EXPORT LinIntRel
00547 operator <(const LinIntExpr& l, const LinIntExpr& r);
00548
00550 GECODE_MINIMODEL_EXPORT LinIntRel
00551 operator <=(int l, const IntVar& r);
00553 GECODE_MINIMODEL_EXPORT LinIntRel
00554 operator <=(int l, const BoolVar& r);
00556 GECODE_MINIMODEL_EXPORT LinIntRel
00557 operator <=(int l, const LinIntExpr& r);
00559 GECODE_MINIMODEL_EXPORT LinIntRel
00560 operator <=(const IntVar& l, int r);
00562 GECODE_MINIMODEL_EXPORT LinIntRel
00563 operator <=(const BoolVar& l, int r);
00565 GECODE_MINIMODEL_EXPORT LinIntRel
00566 operator <=(const LinIntExpr& l, int r);
00568 GECODE_MINIMODEL_EXPORT LinIntRel
00569 operator <=(const IntVar& l, const IntVar& r);
00571 GECODE_MINIMODEL_EXPORT LinIntRel
00572 operator <=(const IntVar& l, const BoolVar& r);
00574 GECODE_MINIMODEL_EXPORT LinIntRel
00575 operator <=(const BoolVar& l, const IntVar& r);
00577 GECODE_MINIMODEL_EXPORT LinIntRel
00578 operator <=(const BoolVar& l, const BoolVar& r);
00580 GECODE_MINIMODEL_EXPORT LinIntRel
00581 operator <=(const IntVar& l, const LinIntExpr& r);
00583 GECODE_MINIMODEL_EXPORT LinIntRel
00584 operator <=(const BoolVar& l, const LinIntExpr& r);
00586 GECODE_MINIMODEL_EXPORT LinIntRel
00587 operator <=(const LinIntExpr& l, const IntVar& r);
00589 GECODE_MINIMODEL_EXPORT LinIntRel
00590 operator <=(const LinIntExpr& l, const BoolVar& r);
00592 GECODE_MINIMODEL_EXPORT LinIntRel
00593 operator <=(const LinIntExpr& l, const LinIntExpr& r);
00594
00596 GECODE_MINIMODEL_EXPORT LinIntRel
00597 operator >(int l, const IntVar& r);
00599 GECODE_MINIMODEL_EXPORT LinIntRel
00600 operator >(int l, const BoolVar& r);
00602 GECODE_MINIMODEL_EXPORT LinIntRel
00603 operator >(int l, const LinIntExpr& r);
00605 GECODE_MINIMODEL_EXPORT LinIntRel
00606 operator >(const IntVar& l, int r);
00608 GECODE_MINIMODEL_EXPORT LinIntRel
00609 operator >(const BoolVar& l, int r);
00611 GECODE_MINIMODEL_EXPORT LinIntRel
00612 operator >(const LinIntExpr& l, int r);
00614 GECODE_MINIMODEL_EXPORT LinIntRel
00615 operator >(const IntVar& l, const IntVar& r);
00617 GECODE_MINIMODEL_EXPORT LinIntRel
00618 operator >(const IntVar& l, const BoolVar& r);
00620 GECODE_MINIMODEL_EXPORT LinIntRel
00621 operator >(const BoolVar& l, const IntVar& r);
00623 GECODE_MINIMODEL_EXPORT LinIntRel
00624 operator >(const BoolVar& l, const BoolVar& r);
00626 GECODE_MINIMODEL_EXPORT LinIntRel
00627 operator >(const IntVar& l, const LinIntExpr& r);
00629 GECODE_MINIMODEL_EXPORT LinIntRel
00630 operator >(const BoolVar& l, const LinIntExpr& r);
00632 GECODE_MINIMODEL_EXPORT LinIntRel
00633 operator >(const LinIntExpr& l, const IntVar& r);
00635 GECODE_MINIMODEL_EXPORT LinIntRel
00636 operator >(const LinIntExpr& l, const BoolVar& r);
00638 GECODE_MINIMODEL_EXPORT LinIntRel
00639 operator >(const LinIntExpr& l, const LinIntExpr& r);
00640
00642 GECODE_MINIMODEL_EXPORT LinIntRel
00643 operator >=(int l, const IntVar& r);
00645 GECODE_MINIMODEL_EXPORT LinIntRel
00646 operator >=(int l, const BoolVar& r);
00648 GECODE_MINIMODEL_EXPORT LinIntRel
00649 operator >=(int l, const LinIntExpr& r);
00651 GECODE_MINIMODEL_EXPORT LinIntRel
00652 operator >=(const IntVar& l, int r);
00654 GECODE_MINIMODEL_EXPORT LinIntRel
00655 operator >=(const BoolVar& l, int r);
00657 GECODE_MINIMODEL_EXPORT LinIntRel
00658 operator >=(const LinIntExpr& l, int r);
00660 GECODE_MINIMODEL_EXPORT LinIntRel
00661 operator >=(const IntVar& l, const IntVar& r);
00663 GECODE_MINIMODEL_EXPORT LinIntRel
00664 operator >=(const IntVar& l, const BoolVar& r);
00666 GECODE_MINIMODEL_EXPORT LinIntRel
00667 operator >=(const BoolVar& l, const IntVar& r);
00669 GECODE_MINIMODEL_EXPORT LinIntRel
00670 operator >=(const BoolVar& l, const BoolVar& r);
00672 GECODE_MINIMODEL_EXPORT LinIntRel
00673 operator >=(const IntVar& l, const LinIntExpr& r);
00675 GECODE_MINIMODEL_EXPORT LinIntRel
00676 operator >=(const BoolVar& l, const LinIntExpr& r);
00678 GECODE_MINIMODEL_EXPORT LinIntRel
00679 operator >=(const LinIntExpr& l, const IntVar& r);
00681 GECODE_MINIMODEL_EXPORT LinIntRel
00682 operator >=(const LinIntExpr& l, const BoolVar& r);
00684 GECODE_MINIMODEL_EXPORT LinIntRel
00685 operator >=(const LinIntExpr& l, const LinIntExpr& r);
00687
00688 #ifdef GECODE_HAS_FLOAT_VARS
00689
00690 class NonLinFloatExpr {
00691 public:
00693 virtual FloatVar post(Home home, FloatVar* ret) const = 0;
00695 virtual void post(Home home, FloatRelType frt, FloatVal c) const = 0;
00697 virtual void post(Home home, FloatRelType frt, FloatVal c,
00698 BoolVar b) const = 0;
00700 virtual ~NonLinFloatExpr(void) {}
00702 static FloatVar result(Home home, FloatVar* x) {
00703 if (x == NULL)
00704 return FloatVar(home,Float::Limits::min,Float::Limits::max);
00705 return *x;
00706 }
00708 static FloatVar result(Home home, FloatVar* x, FloatVar y) {
00709 if (x!=NULL)
00710 rel(home,*x,FRT_EQ,y);
00711 return y;
00712 }
00714 void* operator new(size_t size) { return heap.ralloc(size); }
00716 void operator delete(void* p, size_t) { heap.rfree(p); }
00717 };
00718
00720 class LinFloatExpr {
00721 friend class LinFloatRel;
00722 public:
00724 enum NodeType {
00725 NT_CONST,
00726 NT_VAR,
00727 NT_NONLIN,
00728 NT_SUM,
00729 NT_ADD,
00730 NT_SUB,
00731 NT_MUL
00732 };
00733 private:
00735 class Node;
00736 Node* n;
00737 public:
00739 GECODE_MINIMODEL_EXPORT
00740 LinFloatExpr(void);
00742 GECODE_MINIMODEL_EXPORT
00743 LinFloatExpr(const FloatVal& c);
00745 GECODE_MINIMODEL_EXPORT
00746 LinFloatExpr(const FloatVar& x);
00748 GECODE_MINIMODEL_EXPORT
00749 LinFloatExpr(const FloatVar& x, FloatVal a);
00751 GECODE_MINIMODEL_EXPORT
00752 explicit LinFloatExpr(const FloatVarArgs& x);
00754 GECODE_MINIMODEL_EXPORT
00755 LinFloatExpr(const FloatValArgs& a, const FloatVarArgs& x);
00757 GECODE_MINIMODEL_EXPORT
00758 LinFloatExpr(const LinFloatExpr& e);
00760 GECODE_MINIMODEL_EXPORT
00761 LinFloatExpr(const LinFloatExpr& e0, NodeType t, const LinFloatExpr& e1);
00763 GECODE_MINIMODEL_EXPORT
00764 LinFloatExpr(const LinFloatExpr& e0, NodeType t, const FloatVal& c);
00766 GECODE_MINIMODEL_EXPORT
00767 LinFloatExpr(FloatVal a, const LinFloatExpr& e);
00769 GECODE_MINIMODEL_EXPORT
00770 explicit LinFloatExpr(NonLinFloatExpr* e);
00772 GECODE_MINIMODEL_EXPORT
00773 const LinFloatExpr& operator =(const LinFloatExpr& e);
00775 GECODE_MINIMODEL_EXPORT
00776 void post(Home home, FloatRelType frt) const;
00778 GECODE_MINIMODEL_EXPORT
00779 void post(Home home, FloatRelType frt, const BoolVar& b) const;
00781 GECODE_MINIMODEL_EXPORT
00782 FloatVar post(Home home) const;
00784 GECODE_MINIMODEL_EXPORT
00785 NonLinFloatExpr* nlfe(void) const;
00787 GECODE_MINIMODEL_EXPORT
00788 ~LinFloatExpr(void);
00789 };
00790
00791 class BoolExpr;
00792
00794 class LinFloatRel {
00795 friend class BoolExpr;
00796 private:
00798 LinFloatExpr e;
00800 FloatRelType frt;
00802 static FloatRelType neg(FloatRelType frt);
00804 LinFloatRel(void);
00805 public:
00807 LinFloatRel(const LinFloatExpr& l, FloatRelType frt, const LinFloatExpr& r);
00809 LinFloatRel(const LinFloatExpr& l, FloatRelType frt, FloatVal r);
00811 LinFloatRel(FloatVal l, FloatRelType frt, const LinFloatExpr& r);
00813 void post(Home home, bool t) const;
00815 void post(Home home, const BoolVar& b, bool t) const;
00816 };
00817
00831
00832 GECODE_MINIMODEL_EXPORT LinFloatExpr
00833 operator +(const FloatVal&, const FloatVar&);
00835 GECODE_MINIMODEL_EXPORT LinFloatExpr
00836 operator +(const FloatVal&, const LinFloatExpr&);
00838 GECODE_MINIMODEL_EXPORT LinFloatExpr
00839 operator +(const FloatVar&, const FloatVal&);
00841 GECODE_MINIMODEL_EXPORT LinFloatExpr
00842 operator +(const LinFloatExpr&, const FloatVal&);
00844 GECODE_MINIMODEL_EXPORT LinFloatExpr
00845 operator +(const FloatVar&, const FloatVar&);
00847 GECODE_MINIMODEL_EXPORT LinFloatExpr
00848 operator +(const FloatVar&, const LinFloatExpr&);
00850 GECODE_MINIMODEL_EXPORT LinFloatExpr
00851 operator +(const LinFloatExpr&, const FloatVar&);
00853 GECODE_MINIMODEL_EXPORT LinFloatExpr
00854 operator +(const LinFloatExpr&, const LinFloatExpr&);
00855
00857 GECODE_MINIMODEL_EXPORT LinFloatExpr
00858 operator -(const FloatVal&, const FloatVar&);
00860 GECODE_MINIMODEL_EXPORT LinFloatExpr
00861 operator -(const FloatVal&, const LinFloatExpr&);
00863 GECODE_MINIMODEL_EXPORT LinFloatExpr
00864 operator -(const FloatVar&, const FloatVal&);
00866 GECODE_MINIMODEL_EXPORT LinFloatExpr
00867 operator -(const LinFloatExpr&, const FloatVal&);
00869 GECODE_MINIMODEL_EXPORT LinFloatExpr
00870 operator -(const FloatVar&, const FloatVar&);
00872 GECODE_MINIMODEL_EXPORT LinFloatExpr
00873 operator -(const FloatVar&, const LinFloatExpr&);
00875 GECODE_MINIMODEL_EXPORT LinFloatExpr
00876 operator -(const LinFloatExpr&, const FloatVar&);
00878 GECODE_MINIMODEL_EXPORT LinFloatExpr
00879 operator -(const LinFloatExpr&, const LinFloatExpr&);
00880
00882 GECODE_MINIMODEL_EXPORT LinFloatExpr
00883 operator -(const FloatVar&);
00885 GECODE_MINIMODEL_EXPORT LinFloatExpr
00886 operator -(const LinFloatExpr&);
00887
00889 GECODE_MINIMODEL_EXPORT LinFloatExpr
00890 operator *(const FloatVal&, const FloatVar&);
00892 GECODE_MINIMODEL_EXPORT LinFloatExpr
00893 operator *(const FloatVar&, const FloatVal&);
00895 GECODE_MINIMODEL_EXPORT LinFloatExpr
00896 operator *(const LinFloatExpr&, const FloatVal&);
00898 GECODE_MINIMODEL_EXPORT LinFloatExpr
00899 operator *(const FloatVal&, const LinFloatExpr&);
00900
00902 GECODE_MINIMODEL_EXPORT LinFloatExpr
00903 sum(const FloatVarArgs& x);
00905 GECODE_MINIMODEL_EXPORT LinFloatExpr
00906 sum(const FloatValArgs& a, const FloatVarArgs& x);
00907
00909 GECODE_MINIMODEL_EXPORT LinFloatRel
00910 operator ==(const FloatVal& l, const FloatVar& r);
00912 GECODE_MINIMODEL_EXPORT LinFloatRel
00913 operator ==(const FloatVal& l, const LinFloatExpr& r);
00915 GECODE_MINIMODEL_EXPORT LinFloatRel
00916 operator ==(const FloatVar& l, const FloatVal& r);
00918 GECODE_MINIMODEL_EXPORT LinFloatRel
00919 operator ==(const LinFloatExpr& l, const FloatVal& r);
00921 GECODE_MINIMODEL_EXPORT LinFloatRel
00922 operator ==(const FloatVar& l, const FloatVar& r);
00924 GECODE_MINIMODEL_EXPORT LinFloatRel
00925 operator ==(const FloatVar& l, const LinFloatExpr& r);
00927 GECODE_MINIMODEL_EXPORT LinFloatRel
00928 operator ==(const LinFloatExpr& l, const FloatVar& r);
00930 GECODE_MINIMODEL_EXPORT LinFloatRel
00931 operator ==(const LinFloatExpr& l, const LinFloatExpr& r);
00932
00934 GECODE_MINIMODEL_EXPORT LinFloatRel
00935 operator !=(const FloatVal& l, const FloatVar& r);
00937 GECODE_MINIMODEL_EXPORT LinFloatRel
00938 operator !=(const FloatVal& l, const LinFloatExpr& r);
00940 GECODE_MINIMODEL_EXPORT LinFloatRel
00941 operator !=(const FloatVar& l, const FloatVal& r);
00943 GECODE_MINIMODEL_EXPORT LinFloatRel
00944 operator !=(const LinFloatExpr& l, const FloatVal& r);
00946 GECODE_MINIMODEL_EXPORT LinFloatRel
00947 operator !=(const FloatVar& l, const FloatVar& r);
00949 GECODE_MINIMODEL_EXPORT LinFloatRel
00950 operator !=(const FloatVar& l, const LinFloatExpr& r);
00952 GECODE_MINIMODEL_EXPORT LinFloatRel
00953 operator !=(const LinFloatExpr& l, const FloatVar& r);
00955 GECODE_MINIMODEL_EXPORT LinFloatRel
00956 operator !=(const LinFloatExpr& l, const LinFloatExpr& r);
00957
00959 GECODE_MINIMODEL_EXPORT LinFloatRel
00960 operator <(const FloatVal& l, const FloatVar& r);
00962 GECODE_MINIMODEL_EXPORT LinFloatRel
00963 operator <(const FloatVal& l, const LinFloatExpr& r);
00965 GECODE_MINIMODEL_EXPORT LinFloatRel
00966 operator <(const FloatVar& l, const FloatVal& r);
00968 GECODE_MINIMODEL_EXPORT LinFloatRel
00969 operator <(const LinFloatExpr& l, const FloatVal& r);
00971 GECODE_MINIMODEL_EXPORT LinFloatRel
00972 operator <(const FloatVar& l, const FloatVar& r);
00974 GECODE_MINIMODEL_EXPORT LinFloatRel
00975 operator <(const FloatVar& l, const LinFloatExpr& r);
00977 GECODE_MINIMODEL_EXPORT LinFloatRel
00978 operator <(const LinFloatExpr& l, const FloatVar& r);
00980 GECODE_MINIMODEL_EXPORT LinFloatRel
00981 operator <(const LinFloatExpr& l, const LinFloatExpr& r);
00982
00984 GECODE_MINIMODEL_EXPORT LinFloatRel
00985 operator <=(const FloatVal& l, const FloatVar& r);
00987 GECODE_MINIMODEL_EXPORT LinFloatRel
00988 operator <=(const FloatVal& l, const LinFloatExpr& r);
00990 GECODE_MINIMODEL_EXPORT LinFloatRel
00991 operator <=(const FloatVar& l, const FloatVal& r);
00993 GECODE_MINIMODEL_EXPORT LinFloatRel
00994 operator <=(const LinFloatExpr& l, const FloatVal& r);
00996 GECODE_MINIMODEL_EXPORT LinFloatRel
00997 operator <=(const FloatVar& l, const FloatVar& r);
00999 GECODE_MINIMODEL_EXPORT LinFloatRel
01000 operator <=(const FloatVar& l, const LinFloatExpr& r);
01002 GECODE_MINIMODEL_EXPORT LinFloatRel
01003 operator <=(const LinFloatExpr& l, const FloatVar& r);
01005 GECODE_MINIMODEL_EXPORT LinFloatRel
01006 operator <=(const LinFloatExpr& l, const LinFloatExpr& r);
01007
01009 GECODE_MINIMODEL_EXPORT LinFloatRel
01010 operator >(const FloatVal& l, const FloatVar& r);
01012 GECODE_MINIMODEL_EXPORT LinFloatRel
01013 operator >(const FloatVal& l, const LinFloatExpr& r);
01015 GECODE_MINIMODEL_EXPORT LinFloatRel
01016 operator >(const FloatVar& l, const FloatVal& r);
01018 GECODE_MINIMODEL_EXPORT LinFloatRel
01019 operator >(const LinFloatExpr& l, const FloatVal& r);
01021 GECODE_MINIMODEL_EXPORT LinFloatRel
01022 operator >(const FloatVar& l, const FloatVar& r);
01024 GECODE_MINIMODEL_EXPORT LinFloatRel
01025 operator >(const FloatVar& l, const LinFloatExpr& r);
01027 GECODE_MINIMODEL_EXPORT LinFloatRel
01028 operator >(const LinFloatExpr& l, const FloatVar& r);
01030 GECODE_MINIMODEL_EXPORT LinFloatRel
01031 operator >(const LinFloatExpr& l, const LinFloatExpr& r);
01032
01034 GECODE_MINIMODEL_EXPORT LinFloatRel
01035 operator >=(const FloatVal& l, const FloatVar& r);
01037 GECODE_MINIMODEL_EXPORT LinFloatRel
01038 operator >=(const FloatVal& l, const LinFloatExpr& r);
01040 GECODE_MINIMODEL_EXPORT LinFloatRel
01041 operator >=(const FloatVar& l, const FloatVal& r);
01043 GECODE_MINIMODEL_EXPORT LinFloatRel
01044 operator >=(const LinFloatExpr& l, const FloatVal& r);
01046 GECODE_MINIMODEL_EXPORT LinFloatRel
01047 operator >=(const FloatVar& l, const FloatVar& r);
01049 GECODE_MINIMODEL_EXPORT LinFloatRel
01050 operator >=(const FloatVar& l, const LinFloatExpr& r);
01052 GECODE_MINIMODEL_EXPORT LinFloatRel
01053 operator >=(const LinFloatExpr& l, const FloatVar& r);
01055 GECODE_MINIMODEL_EXPORT LinFloatRel
01056 operator >=(const LinFloatExpr& l, const LinFloatExpr& r);
01058 #endif
01059
01060 #ifdef GECODE_HAS_SET_VARS
01061
01062 class SetExpr {
01063 public:
01065 enum NodeType {
01066 NT_VAR,
01067 NT_CONST,
01068 NT_LEXP,
01069 NT_CMPL,
01070 NT_INTER,
01071 NT_UNION,
01072 NT_DUNION
01073 };
01075 class Node;
01076 private:
01078 Node* n;
01079 public:
01081 SetExpr(void);
01083 GECODE_MINIMODEL_EXPORT
01084 SetExpr(const SetExpr& e);
01086 GECODE_MINIMODEL_EXPORT
01087 SetExpr(const SetExpr& l, NodeType t, const SetExpr& r);
01089 GECODE_MINIMODEL_EXPORT
01090 SetExpr(const SetVar& x);
01092 GECODE_MINIMODEL_EXPORT
01093 explicit SetExpr(const LinIntExpr& x);
01095 GECODE_MINIMODEL_EXPORT
01096 SetExpr(const IntSet& s);
01098 GECODE_MINIMODEL_EXPORT
01099 SetExpr(const SetExpr& e, NodeType t);
01101 GECODE_MINIMODEL_EXPORT
01102 SetVar post(Home home) const;
01104 GECODE_MINIMODEL_EXPORT
01105 void post(Home home, SetRelType srt, const SetExpr& e) const;
01107 GECODE_MINIMODEL_EXPORT
01108 void post(Home home, BoolVar b, bool t,
01109 SetRelType srt, const SetExpr& e) const;
01111 GECODE_MINIMODEL_EXPORT
01112 const SetExpr& operator =(const SetExpr& e);
01114 GECODE_MINIMODEL_EXPORT
01115 ~SetExpr(void);
01116 };
01117
01119 class SetCmpRel {
01120 public:
01122 SetExpr l;
01124 SetExpr r;
01126 SetRelType srt;
01128 SetCmpRel(const SetExpr& l, SetRelType srt, const SetExpr& r);
01129 };
01130
01132 class SetRel {
01133 private:
01135 SetExpr _e0;
01137 SetRelType _srt;
01139 SetExpr _e1;
01140 public:
01142 SetRel(void);
01144 SetRel(const SetExpr& e0, SetRelType srt, const SetExpr& e1);
01146 SetRel(const SetCmpRel& r);
01148 void post(Home home, bool t) const;
01150 void post(Home home, BoolVar b, bool t) const;
01151 };
01152
01163
01164 GECODE_MINIMODEL_EXPORT SetExpr
01165 singleton(const LinIntExpr&);
01167 GECODE_MINIMODEL_EXPORT SetExpr
01168 operator -(const SetExpr&);
01170 GECODE_MINIMODEL_EXPORT SetExpr
01171 operator &(const SetExpr&, const SetExpr&);
01173 GECODE_MINIMODEL_EXPORT SetExpr
01174 operator |(const SetExpr&, const SetExpr&);
01176 GECODE_MINIMODEL_EXPORT SetExpr
01177 operator +(const SetExpr&, const SetExpr&);
01179 GECODE_MINIMODEL_EXPORT SetExpr
01180 operator -(const SetExpr&, const SetExpr&);
01181
01183 GECODE_MINIMODEL_EXPORT SetExpr
01184 inter(const SetVarArgs&);
01186 GECODE_MINIMODEL_EXPORT SetExpr
01187 setunion(const SetVarArgs&);
01189 GECODE_MINIMODEL_EXPORT SetExpr
01190 setdunion(const SetVarArgs&);
01191
01193 GECODE_MINIMODEL_EXPORT LinIntExpr
01194 cardinality(const SetExpr&);
01196 GECODE_MINIMODEL_EXPORT LinIntExpr
01197 min(const SetExpr&);
01199 GECODE_MINIMODEL_EXPORT LinIntExpr
01200 max(const SetExpr&);
01201
01203 GECODE_MINIMODEL_EXPORT SetRel
01204 operator ==(const SetExpr&, const SetExpr&);
01206 GECODE_MINIMODEL_EXPORT SetRel
01207 operator !=(const SetExpr&, const SetExpr&);
01209 GECODE_MINIMODEL_EXPORT SetCmpRel
01210 operator <=(const SetExpr&, const SetExpr&);
01212 GECODE_MINIMODEL_EXPORT BoolExpr
01213 operator <=(const SetCmpRel&, const SetExpr&);
01215 GECODE_MINIMODEL_EXPORT SetCmpRel
01216 operator >=(const SetExpr&, const SetExpr&);
01218 GECODE_MINIMODEL_EXPORT BoolExpr
01219 operator >=(const SetCmpRel&, const SetExpr&);
01221 GECODE_MINIMODEL_EXPORT SetRel
01222 operator ||(const SetExpr&, const SetExpr&);
01224 #endif
01225
01227 class BoolExpr {
01228 public:
01230 enum NodeType {
01231 NT_VAR,
01232 NT_NOT,
01233 NT_AND,
01234 NT_OR,
01235 NT_EQV,
01236 NT_RLIN,
01237 NT_RLINFLOAT,
01238 NT_RSET,
01239 NT_MISC
01240 };
01242 class GECODE_VTABLE_EXPORT Misc : public HeapAllocated {
01243 public:
01245 Misc(void);
01250 virtual void post(Home home, BoolVar b, bool neg,
01251 IntPropLevel ipl) = 0;
01253 virtual GECODE_MINIMODEL_EXPORT ~Misc(void);
01254 };
01256 class Node;
01257 private:
01259 Node* n;
01260 public:
01262 GECODE_MINIMODEL_EXPORT
01263 BoolExpr(void);
01265 GECODE_MINIMODEL_EXPORT
01266 BoolExpr(const BoolExpr& e);
01268 GECODE_MINIMODEL_EXPORT
01269 BoolExpr(const BoolExpr& l, NodeType t, const BoolExpr& r);
01271 GECODE_MINIMODEL_EXPORT
01272 BoolExpr(const BoolVar& x);
01274 GECODE_MINIMODEL_EXPORT
01275 BoolExpr(const BoolExpr& e, NodeType t);
01277 GECODE_MINIMODEL_EXPORT
01278 BoolExpr(const LinIntRel& rl);
01279 #ifdef GECODE_HAS_FLOAT_VARS
01280
01281 GECODE_MINIMODEL_EXPORT
01282 BoolExpr(const LinFloatRel& rfl);
01283 #endif
01284 #ifdef GECODE_HAS_SET_VARS
01285
01286 GECODE_MINIMODEL_EXPORT
01287 BoolExpr(const SetRel& rs);
01289 GECODE_MINIMODEL_EXPORT
01290 BoolExpr(const SetCmpRel& rs);
01291 #endif
01292
01293 GECODE_MINIMODEL_EXPORT
01294 explicit BoolExpr(Misc* m);
01296 GECODE_MINIMODEL_EXPORT
01297 BoolVar expr(Home home, IntPropLevel ipl) const;
01299 GECODE_MINIMODEL_EXPORT
01300 void rel(Home home, IntPropLevel ipl) const;
01302 GECODE_MINIMODEL_EXPORT
01303 const BoolExpr& operator =(const BoolExpr& e);
01305 GECODE_MINIMODEL_EXPORT
01306 ~BoolExpr(void);
01307 };
01308
01319
01320 GECODE_MINIMODEL_EXPORT BoolExpr
01321 operator !(const BoolExpr&);
01323 GECODE_MINIMODEL_EXPORT BoolExpr
01324 operator &&(const BoolExpr&, const BoolExpr&);
01326 GECODE_MINIMODEL_EXPORT BoolExpr
01327 operator ||(const BoolExpr&, const BoolExpr&);
01329 GECODE_MINIMODEL_EXPORT BoolExpr
01330 operator ^(const BoolExpr&, const BoolExpr&);
01331
01333 GECODE_MINIMODEL_EXPORT BoolExpr
01334 operator !=(const BoolExpr&, const BoolExpr&);
01336 GECODE_MINIMODEL_EXPORT BoolExpr
01337 operator ==(const BoolExpr&, const BoolExpr&);
01339 GECODE_MINIMODEL_EXPORT BoolExpr
01340 operator >>(const BoolExpr&, const BoolExpr&);
01342 GECODE_MINIMODEL_EXPORT BoolExpr
01343 operator <<(const BoolExpr&, const BoolExpr&);
01344
01346
01353
01354 GECODE_MINIMODEL_EXPORT IntVar
01355 expr(Home home, const LinIntExpr& e, IntPropLevel ipl=IPL_DEF);
01356 #ifdef GECODE_HAS_FLOAT_VARS
01357
01358 GECODE_MINIMODEL_EXPORT FloatVar
01359 expr(Home home, const LinFloatExpr& e);
01360 #endif
01361 #ifdef GECODE_HAS_SET_VARS
01362
01363 GECODE_MINIMODEL_EXPORT SetVar
01364 expr(Home home, const SetExpr& e);
01365 #endif
01366
01367 GECODE_MINIMODEL_EXPORT BoolVar
01368 expr(Home home, const BoolExpr& e, IntPropLevel ipl=IPL_DEF);
01370 GECODE_MINIMODEL_EXPORT void
01371 rel(Home home, const BoolExpr& e, IntPropLevel ipl=IPL_DEF);
01373
01374 }
01375
01376 #include <gecode/minimodel/int-rel.hpp>
01377 #include <gecode/minimodel/float-rel.hpp>
01378 #include <gecode/minimodel/bool-expr.hpp>
01379 #include <gecode/minimodel/set-expr.hpp>
01380 #include <gecode/minimodel/set-rel.hpp>
01381
01382 namespace Gecode {
01383
01384 namespace MiniModel {
01385 class ExpInfo;
01386 }
01387
01393 class GECODE_MINIMODEL_EXPORT REG {
01394 friend class MiniModel::ExpInfo;
01395 private:
01397 class Exp;
01399 Exp* e;
01401 REG(Exp* e);
01403 std::string toString(void) const;
01404 public:
01406 REG(void);
01408 REG(int s);
01415 REG(const IntArgs& x);
01416
01418 REG(const REG& r);
01420 const REG& operator =(const REG& r);
01421
01423 REG operator +(const REG& r);
01425 REG& operator +=(const REG& r);
01427 REG operator |(const REG& r);
01429 REG& operator |=(const REG& r);
01431 REG operator *(void);
01433 REG operator +(void);
01435 REG operator ()(unsigned int n, unsigned int m);
01437 REG operator ()(unsigned int n);
01439 template<class Char, class Traits>
01440 std::basic_ostream<Char,Traits>&
01441 print(std::basic_ostream<Char,Traits>& os) const;
01443 operator DFA(void);
01445 ~REG(void);
01446 };
01447
01451 template<class Char, class Traits>
01452 std::basic_ostream<Char,Traits>&
01453 operator <<(std::basic_ostream<Char,Traits>& os, const REG& r);
01454
01455 }
01456
01457 #include <gecode/minimodel/reg.hpp>
01458
01459 namespace Gecode {
01460
01467
01468 GECODE_MINIMODEL_EXPORT LinIntExpr
01469 abs(const LinIntExpr& e);
01471 GECODE_MINIMODEL_EXPORT LinIntExpr
01472 min(const LinIntExpr& x, const LinIntExpr& y);
01474 GECODE_MINIMODEL_EXPORT LinIntExpr
01475 min(const IntVarArgs& x);
01477 GECODE_MINIMODEL_EXPORT LinIntExpr
01478 max(const LinIntExpr& x, const LinIntExpr& y);
01480 GECODE_MINIMODEL_EXPORT LinIntExpr
01481 max(const IntVarArgs& x);
01482 #ifdef GECODE_HAS_FLOAT_VARS
01483
01484 GECODE_MINIMODEL_EXPORT LinFloatExpr
01485 operator *(const FloatVar&, const FloatVar&);
01487 GECODE_MINIMODEL_EXPORT LinFloatExpr
01488 operator *(const FloatVar&, const LinFloatExpr&);
01490 GECODE_MINIMODEL_EXPORT LinFloatExpr
01491 operator *(const LinFloatExpr&, const FloatVar&);
01492 #endif
01493
01494 GECODE_MINIMODEL_EXPORT LinIntExpr
01495 operator *(const LinIntExpr& x, const LinIntExpr& y);
01497 GECODE_MINIMODEL_EXPORT LinIntExpr
01498 operator /(const LinIntExpr& x, const LinIntExpr& y);
01500 GECODE_MINIMODEL_EXPORT LinIntExpr
01501 operator %(const LinIntExpr& x, const LinIntExpr& y);
01503 GECODE_MINIMODEL_EXPORT LinIntExpr
01504 sqr(const LinIntExpr& x);
01506 GECODE_MINIMODEL_EXPORT LinIntExpr
01507 sqrt(const LinIntExpr& x);
01509 GECODE_MINIMODEL_EXPORT LinIntExpr
01510 pow(const LinIntExpr& x, int n);
01512 GECODE_MINIMODEL_EXPORT LinIntExpr
01513 nroot(const LinIntExpr& x, int n);
01515 GECODE_MINIMODEL_EXPORT LinIntExpr
01516 element(const IntVarArgs& x, const LinIntExpr& y);
01518 GECODE_MINIMODEL_EXPORT BoolExpr
01519 element(const BoolVarArgs& x, const LinIntExpr& y);
01521 GECODE_MINIMODEL_EXPORT LinIntExpr
01522 element(const IntArgs& x, const LinIntExpr& y);
01524 GECODE_MINIMODEL_EXPORT LinIntExpr
01525 ite(const BoolExpr& b, const LinIntExpr& x, const LinIntExpr& y);
01527
01528 #ifdef GECODE_HAS_FLOAT_VARS
01529
01530 GECODE_MINIMODEL_EXPORT LinFloatExpr
01531 abs(const LinFloatExpr& e);
01533 GECODE_MINIMODEL_EXPORT LinFloatExpr
01534 min(const LinFloatExpr& x, const LinFloatExpr& y);
01536 GECODE_MINIMODEL_EXPORT LinFloatExpr
01537 min(const FloatVarArgs& x);
01539 GECODE_MINIMODEL_EXPORT LinFloatExpr
01540 max(const LinFloatExpr& x, const LinFloatExpr& y);
01542 GECODE_MINIMODEL_EXPORT LinFloatExpr
01543 max(const FloatVarArgs& x);
01545 GECODE_MINIMODEL_EXPORT LinFloatExpr
01546 operator *(const LinFloatExpr& x, const LinFloatExpr& y);
01548 GECODE_MINIMODEL_EXPORT LinFloatExpr
01549 operator /(const LinFloatExpr& x, const LinFloatExpr& y);
01551 GECODE_MINIMODEL_EXPORT LinFloatExpr
01552 sqr(const LinFloatExpr& x);
01554 GECODE_MINIMODEL_EXPORT LinFloatExpr
01555 sqrt(const LinFloatExpr& x);
01557 GECODE_MINIMODEL_EXPORT LinFloatExpr
01558 pow(const LinFloatExpr& x, int n);
01560 GECODE_MINIMODEL_EXPORT LinFloatExpr
01561 nroot(const LinFloatExpr& x, int n);
01563
01564 #ifdef GECODE_HAS_MPFR
01565
01571
01572 GECODE_MINIMODEL_EXPORT LinFloatExpr
01573 exp(const LinFloatExpr& x);
01575 GECODE_MINIMODEL_EXPORT LinFloatExpr
01576 log(const LinFloatExpr& x);
01578
01585
01586 GECODE_MINIMODEL_EXPORT LinFloatExpr
01587 asin(const LinFloatExpr& x);
01589 GECODE_MINIMODEL_EXPORT LinFloatExpr
01590 sin(const LinFloatExpr& x);
01592 GECODE_MINIMODEL_EXPORT LinFloatExpr
01593 acos(const LinFloatExpr& x);
01595 GECODE_MINIMODEL_EXPORT LinFloatExpr
01596 cos(const LinFloatExpr& x);
01598 GECODE_MINIMODEL_EXPORT LinFloatExpr
01599 atan(const LinFloatExpr& x);
01601 GECODE_MINIMODEL_EXPORT LinFloatExpr
01602 tan(const LinFloatExpr& x);
01604 #endif
01605 #endif
01606
01613
01614 inline BoolVar
01615 channel(Home home, IntVar x,
01616 IntPropLevel ipl=IPL_DEF) {
01617 (void) ipl;
01618 BoolVar b(home,0,1); channel(home,b,x);
01619 return b;
01620 }
01622 inline IntVar
01623 channel(Home home, BoolVar b,
01624 IntPropLevel ipl=IPL_DEF) {
01625 (void) ipl;
01626 IntVar x(home,0,1); channel(home,b,x);
01627 return x;
01628 }
01629 #ifdef GECODE_HAS_FLOAT_VARS
01630
01631 inline IntVar
01632 channel(Home home, FloatVar f) {
01633 int min = static_cast<int>(std::max(static_cast<double>(Int::Limits::min),
01634 std::ceil(f.min())));
01635 int max = static_cast<int>(std::min(static_cast<double>(Int::Limits::max),
01636 std::floor(f.max())));
01637 IntVar x(home,min,max);
01638 channel(home,f,x);
01639 return x;
01640 }
01641 #endif
01642 #ifdef GECODE_HAS_SET_VARS
01643
01644 inline SetVar
01645 channel(Home home, const IntVarArgs& x, IntPropLevel ipl=IPL_DEF) {
01646 (void) ipl;
01647 SetVar s(home,IntSet::empty,Set::Limits::min,Set::Limits::max);
01648 rel(home,SOT_UNION,x,s);
01649 nvalues(home,x,IRT_EQ,expr(home,cardinality(s)));
01650 return s;
01651 }
01652 #endif
01653
01654
01655 }
01656
01657 namespace Gecode {
01658
01673 inline void
01674 atmost(Home home, const IntVarArgs& x, int n, int m,
01675 IntPropLevel ipl=IPL_DEF) {
01676 count(home,x,n,IRT_LQ,m,ipl);
01677 }
01682 inline void
01683 atmost(Home home, const IntVarArgs& x, IntVar y, int m,
01684 IntPropLevel ipl=IPL_DEF) {
01685 count(home,x,y,IRT_LQ,m,ipl);
01686 }
01694 inline void
01695 atmost(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01696 IntPropLevel ipl=IPL_DEF) {
01697 count(home,x,y,IRT_LQ,m,ipl);
01698 }
01703 inline void
01704 atmost(Home home, const IntVarArgs& x, int n, IntVar z,
01705 IntPropLevel ipl=IPL_DEF) {
01706 count(home,x,n,IRT_LQ,z,ipl);
01707 }
01712 inline void
01713 atmost(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01714 IntPropLevel ipl=IPL_DEF) {
01715 count(home,x,y,IRT_LQ,z,ipl);
01716 }
01724 inline void
01725 atmost(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01726 IntPropLevel ipl=IPL_DEF) {
01727 count(home,x,y,IRT_LQ,z,ipl);
01728 }
01729
01734 inline void
01735 atleast(Home home, const IntVarArgs& x, int n, int m,
01736 IntPropLevel ipl=IPL_DEF) {
01737 count(home,x,n,IRT_GQ,m,ipl);
01738 }
01743 inline void
01744 atleast(Home home, const IntVarArgs& x, IntVar y, int m,
01745 IntPropLevel ipl=IPL_DEF) {
01746 count(home,x,y,IRT_GQ,m,ipl);
01747 }
01755 inline void
01756 atleast(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01757 IntPropLevel ipl=IPL_DEF) {
01758 count(home,x,y,IRT_GQ,m,ipl);
01759 }
01764 inline void
01765 atleast(Home home, const IntVarArgs& x, int n, IntVar z,
01766 IntPropLevel ipl=IPL_DEF) {
01767 count(home,x,n,IRT_GQ,z,ipl);
01768 }
01773 inline void
01774 atleast(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01775 IntPropLevel ipl=IPL_DEF) {
01776 count(home,x,y,IRT_GQ,z,ipl);
01777 }
01785 inline void
01786 atleast(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01787 IntPropLevel ipl=IPL_DEF) {
01788 count(home,x,y,IRT_GQ,z,ipl);
01789 }
01790
01795 inline void
01796 exactly(Home home, const IntVarArgs& x, int n, int m,
01797 IntPropLevel ipl=IPL_DEF) {
01798 count(home,x,n,IRT_EQ,m,ipl);
01799 }
01804 inline void
01805 exactly(Home home, const IntVarArgs& x, IntVar y, int m,
01806 IntPropLevel ipl=IPL_DEF) {
01807 count(home,x,y,IRT_EQ,m,ipl);
01808 }
01816 inline void
01817 exactly(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01818 IntPropLevel ipl=IPL_DEF) {
01819 count(home,x,y,IRT_EQ,m,ipl);
01820 }
01825 inline void
01826 exactly(Home home, const IntVarArgs& x, int n, IntVar z,
01827 IntPropLevel ipl=IPL_DEF) {
01828 count(home,x,n,IRT_EQ,z,ipl);
01829 }
01834 inline void
01835 exactly(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01836 IntPropLevel ipl=IPL_DEF) {
01837 count(home,x,y,IRT_EQ,z,ipl);
01838 }
01846 inline void
01847 exactly(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01848 IntPropLevel ipl=IPL_DEF) {
01849 count(home,x,y,IRT_EQ,z,ipl);
01850 }
01853 inline void
01854 lex(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
01855 IntPropLevel ipl=IPL_DEF) {
01856 rel(home,x,r,y,ipl);
01857 }
01860 inline void
01861 lex(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
01862 IntPropLevel ipl=IPL_DEF) {
01863 rel(home,x,r,y,ipl);
01864 }
01867 inline void
01868 values(Home home, const IntVarArgs& x, IntSet y,
01869 IntPropLevel ipl=IPL_DEF) {
01870 dom(home,x,y,ipl);
01871 nvalues(home,x,IRT_EQ,static_cast<int>(y.size()),ipl);
01872 }
01873
01875
01876 #ifdef GECODE_HAS_SET_VARS
01877
01892 inline void
01893 channel(Home home, const IntVarArgs& x, SetVar y) {
01894 rel(home,SOT_UNION,x,y);
01895 nvalues(home,x,IRT_EQ,expr(home,cardinality(y)));
01896 }
01897
01900 inline void
01901 range(Home home, const IntVarArgs& x, SetVar y, SetVar z) {
01902 element(home,SOT_UNION,x,y,z);
01903 }
01904
01910 inline void
01911 roots(Home home, const IntVarArgs& x, SetVar y, SetVar z) {
01912 SetVarArgs xiv(home,z.lubMax()+1,IntSet::empty,0,x.size()-1);
01913 channel(home,x,xiv);
01914 element(home,SOT_UNION,xiv,z,y);
01915 }
01916
01918 #endif
01919 }
01920
01921 namespace Gecode {
01922
01923 template<class> class Matrix;
01924
01932 template<class A>
01933 class Slice {
01934 public:
01936 typedef typename ArrayTraits<A>::ArgsType ArgsType;
01937 private:
01938 ArgsType _r;
01939 int _fc,
01940 _tc,
01941 _fr,
01942 _tr;
01943 public:
01945 Slice(const Matrix<A>& a, int fc, int tc, int fr, int tr);
01949 Slice& reverse(void);
01951 operator ArgsType(void);
01953 operator Matrix<ArgsType>(void);
01954
01956 operator const ArgsType(void) const;
01958 operator const Matrix<ArgsType>(void) const;
01959 };
01960
01962 template<class A>
01963 typename Slice<A>::ArgsType
01964 operator+(const Slice<A>& x, const Slice<A>& y);
01965
01967 template<class A>
01968 typename Slice<A>::ArgsType
01969 operator+(const Slice<A>& x, const typename ArrayTraits<A>::ArgsType& y);
01970
01972 template<class A>
01973 typename Slice<A>::ArgsType
01974 operator+(const typename ArrayTraits<A>::ArgsType& x, const Slice<A>& y);
01975
01977 template<class A>
01978 typename Slice<A>::ArgsType
01979 operator+(const Slice<A>& x, const typename ArrayTraits<A>::ValueType& y);
01980
01982 template<class A>
01983 typename Slice<A>::ArgsType
01984 operator+(const typename ArrayTraits<A>::ValueType& x, const Slice<A>& y);
01985
01996 template<class A>
01997 class Matrix {
01998 public:
02000 typedef typename ArrayTraits<A>::ValueType ValueType;
02002 typedef typename ArrayTraits<A>::ArgsType ArgsType;
02003
02004 private:
02006 typedef typename ArrayTraits<A>::StorageType StorageType;
02007 StorageType _a;
02008 int _w;
02009 int _h;
02010
02011 public:
02024 Matrix(A a, int w, int h);
02025
02038 Matrix(A a, int n);
02039
02041 int width(void) const;
02043 int height(void) const;
02045 ArgsType const get_array(void) const;
02046
02052 ValueType& operator ()(int c, int r);
02053
02059 const ValueType& operator ()(int c, int r) const;
02060
02070 Slice<A> slice(int fc, int tc, int fr, int tr) const;
02071
02073 Slice<A> row(int r) const;
02074
02076 Slice<A> col(int c) const;
02077 };
02078
02082 template<class Char, class Traits, class A>
02083 std::basic_ostream<Char,Traits>&
02084 operator <<(std::basic_ostream<Char,Traits>& os, const Matrix<A>& m);
02085
02089 template<class Char, class Traits, class A>
02090 std::basic_ostream<Char,Traits>&
02091 operator <<(std::basic_ostream<Char,Traits>& os, const Slice<A>& s);
02092
02099 void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,
02100 IntVar z, IntPropLevel ipl=IPL_DEF);
02107 void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,
02108 BoolVar z, IntPropLevel ipl=IPL_DEF);
02115 void element(Home home, const Matrix<IntVarArgs>& m, IntVar x, IntVar y,
02116 IntVar z, IntPropLevel ipl=IPL_DEF);
02123 void element(Home home, const Matrix<BoolVarArgs>& m, IntVar x, IntVar y,
02124 BoolVar z, IntPropLevel ipl=IPL_DEF);
02125 #ifdef GECODE_HAS_SET_VARS
02126
02132 void element(Home home, const Matrix<IntSetArgs>& m, IntVar x, IntVar y,
02133 SetVar z);
02140 void element(Home home, const Matrix<SetVarArgs>& m, IntVar x, IntVar y,
02141 SetVar z);
02142 #endif
02143
02147 template<class A>
02148 SymmetryHandle rows_interchange(const Matrix<A>& m);
02152 template<class A>
02153 SymmetryHandle columns_interchange(const Matrix<A>& m);
02157 template<class A>
02158 SymmetryHandle rows_reflect(const Matrix<A>& m);
02162 template<class A>
02163 SymmetryHandle columns_reflect(const Matrix<A>& m);
02169 template<class A>
02170 SymmetryHandle diagonal_reflect(const Matrix<A>& m);
02171 }
02172
02173 #include <gecode/minimodel/matrix.hpp>
02174 #include <gecode/minimodel/ldsb.hpp>
02175
02180 namespace Gecode {
02181
02183 GECODE_MINIMODEL_EXPORT LinIntExpr
02184 sum(const Slice<IntArgs>& slice);
02186 GECODE_MINIMODEL_EXPORT LinIntExpr
02187 sum(const Matrix<IntArgs>& matrix);
02188
02189 }
02192 namespace Gecode {
02193
02207 class GECODE_VTABLE_EXPORT IntMinimizeSpace : public Space {
02208 public:
02210 IntMinimizeSpace(void);
02212 IntMinimizeSpace(bool share, IntMinimizeSpace& s);
02214 GECODE_MINIMODEL_EXPORT
02215 virtual void constrain(const Space& best);
02217 virtual IntVar cost(void) const = 0;
02218 };
02219
02224 class GECODE_VTABLE_EXPORT IntMaximizeSpace : public Space {
02225 public:
02227 IntMaximizeSpace(void);
02229 IntMaximizeSpace(bool share, IntMaximizeSpace& s);
02231 GECODE_MINIMODEL_EXPORT
02232 virtual void constrain(const Space& best);
02234 virtual IntVar cost(void) const = 0;
02235 };
02236
02241 typedef IntMinimizeSpace MinimizeSpace;
02246 typedef IntMaximizeSpace MaximizeSpace;
02247
02248
02249 #ifdef GECODE_HAS_FLOAT_VARS
02250
02260 class GECODE_VTABLE_EXPORT FloatMinimizeSpace : public Space {
02261 protected:
02263 FloatNum step;
02264 public:
02266 FloatMinimizeSpace(FloatNum s=0.0);
02268 FloatMinimizeSpace(bool share, FloatMinimizeSpace& s);
02270 GECODE_MINIMODEL_EXPORT
02271 virtual void constrain(const Space& best);
02273 virtual FloatVar cost(void) const = 0;
02274 };
02275
02285 class GECODE_VTABLE_EXPORT FloatMaximizeSpace : public Space {
02286 protected:
02288 FloatNum step;
02289 public:
02291 FloatMaximizeSpace(FloatNum s=0.0);
02293 FloatMaximizeSpace(bool share, FloatMaximizeSpace& s);
02295 GECODE_MINIMODEL_EXPORT
02296 virtual void constrain(const Space& best);
02298 virtual FloatVar cost(void) const = 0;
02299 };
02300
02301 #endif
02302
02303 }
02304
02305 #include <gecode/minimodel/optimize.hpp>
02306
02307 #endif
02308
02309
02310
02311