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 #include <gecode/int/linear.hh>
00051
00052 #include <gecode/minimodel/exception.hpp>
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 class LinRel;
00095
00097 class LinExpr {
00098 friend class LinRel;
00099 public:
00101 enum NodeType {
00102 NT_VAR_INT,
00103 NT_VAR_BOOL,
00104 NT_SUM_INT,
00105 NT_SUM_BOOL,
00106 NT_ADD,
00107 NT_SUB,
00108 NT_MUL
00109 };
00110 private:
00112 class Node {
00113 public:
00115 unsigned int use;
00117 unsigned int n_int;
00119 unsigned int n_bool;
00121 NodeType t;
00123 Node *l, *r;
00125 union {
00127 Int::Linear::Term<Int::IntView>* ti;
00129 Int::Linear::Term<Int::BoolView>* tb;
00130 } sum;
00132 int a, c;
00134 IntVar x_int;
00136 BoolVar x_bool;
00138 Node(void);
00140 GECODE_MINIMODEL_EXPORT
00141 void fill(Int::Linear::Term<Int::IntView>*& ti,
00142 Int::Linear::Term<Int::BoolView>*& tb,
00143 double m, double& d) const;
00145 int fill(Int::Linear::Term<Int::IntView>* ti,
00146 Int::Linear::Term<Int::BoolView>* tb) const;
00148 bool decrement(void);
00150 ~Node(void);
00152 static void* operator new(size_t size);
00154 static void operator delete(void* p,size_t size);
00155 };
00156 Node* n;
00158 LinExpr(void);
00159 public:
00161 LinExpr(const IntVar& x, int a=1);
00163 LinExpr(const BoolVar& x, int a=1);
00165 LinExpr(const IntVarArgs& x);
00167 LinExpr(const IntArgs& a, const IntVarArgs& x);
00169 LinExpr(const BoolVarArgs& x);
00171 LinExpr(const IntArgs& a, const BoolVarArgs& x);
00173 LinExpr(const LinExpr& e);
00175 LinExpr(const LinExpr& e0, NodeType t, const LinExpr& e1);
00177 LinExpr(const LinExpr& e0, NodeType t, int c);
00179 LinExpr(int a, const LinExpr& e);
00181 GECODE_MINIMODEL_EXPORT
00182 const LinExpr& operator =(const LinExpr& e);
00184 void post(Home home, IntRelType irt, IntConLevel icl) const;
00186 void post(Home home, IntRelType irt, const BoolVar& b,
00187 IntConLevel icl) const;
00189 IntVar post(Home home, IntConLevel icl) const;
00191 GECODE_MINIMODEL_EXPORT
00192 ~LinExpr(void);
00193 };
00194
00195 class BoolExpr;
00196
00198 class LinRel {
00199 friend class BoolExpr;
00200 private:
00202 LinExpr e;
00204 IntRelType irt;
00206 static IntRelType neg(IntRelType irt);
00208 LinRel(void);
00209 public:
00211 LinRel(const LinExpr& l, IntRelType irt, const LinExpr& r);
00213 LinRel(const LinExpr& l, IntRelType irt, int r);
00215 LinRel(int l, IntRelType irt, const LinExpr& r);
00217 void post(Home home, bool t, IntConLevel icl) const;
00219 void post(Home home, const BoolVar& b, bool t, IntConLevel icl) const;
00220 };
00221
00240
00241 GECODE_MINIMODEL_EXPORT LinExpr
00242 operator +(int, const IntVar&);
00244 GECODE_MINIMODEL_EXPORT LinExpr
00245 operator +(int, const BoolVar&);
00247 GECODE_MINIMODEL_EXPORT LinExpr
00248 operator +(int, const LinExpr&);
00250 GECODE_MINIMODEL_EXPORT LinExpr
00251 operator +(const IntVar&, int);
00253 GECODE_MINIMODEL_EXPORT LinExpr
00254 operator +(const BoolVar&, int);
00256 GECODE_MINIMODEL_EXPORT LinExpr
00257 operator +(const LinExpr&, int);
00259 GECODE_MINIMODEL_EXPORT LinExpr
00260 operator +(const IntVar&, const IntVar&);
00262 GECODE_MINIMODEL_EXPORT LinExpr
00263 operator +(const IntVar&, const BoolVar&);
00265 GECODE_MINIMODEL_EXPORT LinExpr
00266 operator +(const BoolVar&, const IntVar&);
00268 GECODE_MINIMODEL_EXPORT LinExpr
00269 operator +(const BoolVar&, const BoolVar&);
00271 GECODE_MINIMODEL_EXPORT LinExpr
00272 operator +(const IntVar&, const LinExpr&);
00274 GECODE_MINIMODEL_EXPORT LinExpr
00275 operator +(const BoolVar&, const LinExpr&);
00277 GECODE_MINIMODEL_EXPORT LinExpr
00278 operator +(const LinExpr&, const IntVar&);
00280 GECODE_MINIMODEL_EXPORT LinExpr
00281 operator +(const LinExpr&, const BoolVar&);
00283 GECODE_MINIMODEL_EXPORT LinExpr
00284 operator +(const LinExpr&, const LinExpr&);
00285
00287 GECODE_MINIMODEL_EXPORT LinExpr
00288 operator -(int, const IntVar&);
00290 GECODE_MINIMODEL_EXPORT LinExpr
00291 operator -(int, const BoolVar&);
00293 GECODE_MINIMODEL_EXPORT LinExpr
00294 operator -(int, const LinExpr&);
00296 GECODE_MINIMODEL_EXPORT LinExpr
00297 operator -(const IntVar&, int);
00299 GECODE_MINIMODEL_EXPORT LinExpr
00300 operator -(const BoolVar&, int);
00302 GECODE_MINIMODEL_EXPORT LinExpr
00303 operator -(const LinExpr&, int);
00305 GECODE_MINIMODEL_EXPORT LinExpr
00306 operator -(const IntVar&, const IntVar&);
00308 GECODE_MINIMODEL_EXPORT LinExpr
00309 operator -(const IntVar&, const BoolVar&);
00311 GECODE_MINIMODEL_EXPORT LinExpr
00312 operator -(const BoolVar&, const IntVar&);
00314 GECODE_MINIMODEL_EXPORT LinExpr
00315 operator -(const BoolVar&, const BoolVar&);
00317 GECODE_MINIMODEL_EXPORT LinExpr
00318 operator -(const IntVar&, const LinExpr&);
00320 GECODE_MINIMODEL_EXPORT LinExpr
00321 operator -(const BoolVar&, const LinExpr&);
00323 GECODE_MINIMODEL_EXPORT LinExpr
00324 operator -(const LinExpr&, const IntVar&);
00326 GECODE_MINIMODEL_EXPORT LinExpr
00327 operator -(const LinExpr&, const BoolVar&);
00329 GECODE_MINIMODEL_EXPORT LinExpr
00330 operator -(const LinExpr&, const LinExpr&);
00331
00333 GECODE_MINIMODEL_EXPORT LinExpr
00334 operator -(const IntVar&);
00336 GECODE_MINIMODEL_EXPORT LinExpr
00337 operator -(const BoolVar&);
00339 GECODE_MINIMODEL_EXPORT LinExpr
00340 operator -(const LinExpr&);
00341
00343 GECODE_MINIMODEL_EXPORT LinExpr
00344 operator *(int, const IntVar&);
00346 GECODE_MINIMODEL_EXPORT LinExpr
00347 operator *(int, const BoolVar&);
00349 GECODE_MINIMODEL_EXPORT LinExpr
00350 operator *(const IntVar&, int);
00352 GECODE_MINIMODEL_EXPORT LinExpr
00353 operator *(const BoolVar&, int);
00355 GECODE_MINIMODEL_EXPORT LinExpr
00356 operator *(const LinExpr&, int);
00358 GECODE_MINIMODEL_EXPORT LinExpr
00359 operator *(int, const LinExpr&);
00360
00362 GECODE_MINIMODEL_EXPORT LinExpr
00363 sum(const IntVarArgs& x);
00365 GECODE_MINIMODEL_EXPORT LinExpr
00366 sum(const IntArgs& a, const IntVarArgs& x);
00368 GECODE_MINIMODEL_EXPORT LinExpr
00369 sum(const BoolVarArgs& x);
00371 GECODE_MINIMODEL_EXPORT LinExpr
00372 sum(const IntArgs& a, const BoolVarArgs& x);
00373
00375 GECODE_MINIMODEL_EXPORT LinRel
00376 operator ==(int l, const IntVar& r);
00378 GECODE_MINIMODEL_EXPORT LinRel
00379 operator ==(int l, const BoolVar& r);
00381 GECODE_MINIMODEL_EXPORT LinRel
00382 operator ==(int l, const LinExpr& r);
00384 GECODE_MINIMODEL_EXPORT LinRel
00385 operator ==(const IntVar& l, int r);
00387 GECODE_MINIMODEL_EXPORT LinRel
00388 operator ==(const BoolVar& l, int r);
00390 GECODE_MINIMODEL_EXPORT LinRel
00391 operator ==(const LinExpr& l, int r);
00393 GECODE_MINIMODEL_EXPORT LinRel
00394 operator ==(const IntVar& l, const IntVar& r);
00396 GECODE_MINIMODEL_EXPORT LinRel
00397 operator ==(const IntVar& l, const BoolVar& r);
00399 GECODE_MINIMODEL_EXPORT LinRel
00400 operator ==(const BoolVar& l, const IntVar& r);
00402 GECODE_MINIMODEL_EXPORT LinRel
00403 operator ==(const BoolVar& l, const BoolVar& r);
00405 GECODE_MINIMODEL_EXPORT LinRel
00406 operator ==(const IntVar& l, const LinExpr& r);
00408 GECODE_MINIMODEL_EXPORT LinRel
00409 operator ==(const BoolVar& l, const LinExpr& r);
00411 GECODE_MINIMODEL_EXPORT LinRel
00412 operator ==(const LinExpr& l, const IntVar& r);
00414 GECODE_MINIMODEL_EXPORT LinRel
00415 operator ==(const LinExpr& l, const BoolVar& r);
00417 GECODE_MINIMODEL_EXPORT LinRel
00418 operator ==(const LinExpr& l, const LinExpr& r);
00419
00421 GECODE_MINIMODEL_EXPORT LinRel
00422 operator !=(int l, const IntVar& r);
00424 GECODE_MINIMODEL_EXPORT LinRel
00425 operator !=(int l, const BoolVar& r);
00427 GECODE_MINIMODEL_EXPORT LinRel
00428 operator !=(int l, const LinExpr& r);
00430 GECODE_MINIMODEL_EXPORT LinRel
00431 operator !=(const IntVar& l, int r);
00433 GECODE_MINIMODEL_EXPORT LinRel
00434 operator !=(const BoolVar& l, int r);
00436 GECODE_MINIMODEL_EXPORT LinRel
00437 operator !=(const LinExpr& l, int r);
00439 GECODE_MINIMODEL_EXPORT LinRel
00440 operator !=(const IntVar& l, const IntVar& r);
00442 GECODE_MINIMODEL_EXPORT LinRel
00443 operator !=(const IntVar& l, const BoolVar& r);
00445 GECODE_MINIMODEL_EXPORT LinRel
00446 operator !=(const BoolVar& l, const IntVar& r);
00448 GECODE_MINIMODEL_EXPORT LinRel
00449 operator !=(const BoolVar& l, const BoolVar& r);
00451 GECODE_MINIMODEL_EXPORT LinRel
00452 operator !=(const IntVar& l, const LinExpr& r);
00454 GECODE_MINIMODEL_EXPORT LinRel
00455 operator !=(const BoolVar& l, const LinExpr& r);
00457 GECODE_MINIMODEL_EXPORT LinRel
00458 operator !=(const LinExpr& l, const IntVar& r);
00460 GECODE_MINIMODEL_EXPORT LinRel
00461 operator !=(const LinExpr& l, const BoolVar& r);
00463 GECODE_MINIMODEL_EXPORT LinRel
00464 operator !=(const LinExpr& l, const LinExpr& r);
00465
00467 GECODE_MINIMODEL_EXPORT LinRel
00468 operator <(int l, const IntVar& r);
00470 GECODE_MINIMODEL_EXPORT LinRel
00471 operator <(int l, const BoolVar& r);
00473 GECODE_MINIMODEL_EXPORT LinRel
00474 operator <(int l, const LinExpr& r);
00476 GECODE_MINIMODEL_EXPORT LinRel
00477 operator <(const IntVar& l, int r);
00479 GECODE_MINIMODEL_EXPORT LinRel
00480 operator <(const BoolVar& l, int r);
00482 GECODE_MINIMODEL_EXPORT LinRel
00483 operator <(const LinExpr& l, int r);
00485 GECODE_MINIMODEL_EXPORT LinRel
00486 operator <(const IntVar& l, const IntVar& r);
00488 GECODE_MINIMODEL_EXPORT LinRel
00489 operator <(const IntVar& l, const BoolVar& r);
00491 GECODE_MINIMODEL_EXPORT LinRel
00492 operator <(const BoolVar& l, const IntVar& r);
00494 GECODE_MINIMODEL_EXPORT LinRel
00495 operator <(const BoolVar& l, const BoolVar& r);
00497 GECODE_MINIMODEL_EXPORT LinRel
00498 operator <(const IntVar& l, const LinExpr& r);
00500 GECODE_MINIMODEL_EXPORT LinRel
00501 operator <(const BoolVar& l, const LinExpr& r);
00503 GECODE_MINIMODEL_EXPORT LinRel
00504 operator <(const LinExpr& l, const IntVar& r);
00506 GECODE_MINIMODEL_EXPORT LinRel
00507 operator <(const LinExpr& l, const BoolVar& r);
00509 GECODE_MINIMODEL_EXPORT LinRel
00510 operator <(const LinExpr& l, const LinExpr& r);
00511
00513 GECODE_MINIMODEL_EXPORT LinRel
00514 operator <=(int l, const IntVar& r);
00516 GECODE_MINIMODEL_EXPORT LinRel
00517 operator <=(int l, const BoolVar& r);
00519 GECODE_MINIMODEL_EXPORT LinRel
00520 operator <=(int l, const LinExpr& r);
00522 GECODE_MINIMODEL_EXPORT LinRel
00523 operator <=(const IntVar& l, int r);
00525 GECODE_MINIMODEL_EXPORT LinRel
00526 operator <=(const BoolVar& l, int r);
00528 GECODE_MINIMODEL_EXPORT LinRel
00529 operator <=(const LinExpr& l, int r);
00531 GECODE_MINIMODEL_EXPORT LinRel
00532 operator <=(const IntVar& l, const IntVar& r);
00534 GECODE_MINIMODEL_EXPORT LinRel
00535 operator <=(const IntVar& l, const BoolVar& r);
00537 GECODE_MINIMODEL_EXPORT LinRel
00538 operator <=(const BoolVar& l, const IntVar& r);
00540 GECODE_MINIMODEL_EXPORT LinRel
00541 operator <=(const BoolVar& l, const BoolVar& r);
00543 GECODE_MINIMODEL_EXPORT LinRel
00544 operator <=(const IntVar& l, const LinExpr& r);
00546 GECODE_MINIMODEL_EXPORT LinRel
00547 operator <=(const BoolVar& l, const LinExpr& r);
00549 GECODE_MINIMODEL_EXPORT LinRel
00550 operator <=(const LinExpr& l, const IntVar& r);
00552 GECODE_MINIMODEL_EXPORT LinRel
00553 operator <=(const LinExpr& l, const BoolVar& r);
00555 GECODE_MINIMODEL_EXPORT LinRel
00556 operator <=(const LinExpr& l, const LinExpr& r);
00557
00559 GECODE_MINIMODEL_EXPORT LinRel
00560 operator >(int l, const IntVar& r);
00562 GECODE_MINIMODEL_EXPORT LinRel
00563 operator >(int l, const BoolVar& r);
00565 GECODE_MINIMODEL_EXPORT LinRel
00566 operator >(int l, const LinExpr& r);
00568 GECODE_MINIMODEL_EXPORT LinRel
00569 operator >(const IntVar& l, int r);
00571 GECODE_MINIMODEL_EXPORT LinRel
00572 operator >(const BoolVar& l, int r);
00574 GECODE_MINIMODEL_EXPORT LinRel
00575 operator >(const LinExpr& l, int r);
00577 GECODE_MINIMODEL_EXPORT LinRel
00578 operator >(const IntVar& l, const IntVar& r);
00580 GECODE_MINIMODEL_EXPORT LinRel
00581 operator >(const IntVar& l, const BoolVar& r);
00583 GECODE_MINIMODEL_EXPORT LinRel
00584 operator >(const BoolVar& l, const IntVar& r);
00586 GECODE_MINIMODEL_EXPORT LinRel
00587 operator >(const BoolVar& l, const BoolVar& r);
00589 GECODE_MINIMODEL_EXPORT LinRel
00590 operator >(const IntVar& l, const LinExpr& r);
00592 GECODE_MINIMODEL_EXPORT LinRel
00593 operator >(const BoolVar& l, const LinExpr& r);
00595 GECODE_MINIMODEL_EXPORT LinRel
00596 operator >(const LinExpr& l, const IntVar& r);
00598 GECODE_MINIMODEL_EXPORT LinRel
00599 operator >(const LinExpr& l, const BoolVar& r);
00601 GECODE_MINIMODEL_EXPORT LinRel
00602 operator >(const LinExpr& l, const LinExpr& r);
00603
00605 GECODE_MINIMODEL_EXPORT LinRel
00606 operator >=(int l, const IntVar& r);
00608 GECODE_MINIMODEL_EXPORT LinRel
00609 operator >=(int l, const BoolVar& r);
00611 GECODE_MINIMODEL_EXPORT LinRel
00612 operator >=(int l, const LinExpr& r);
00614 GECODE_MINIMODEL_EXPORT LinRel
00615 operator >=(const IntVar& l, int r);
00617 GECODE_MINIMODEL_EXPORT LinRel
00618 operator >=(const BoolVar& l, int r);
00620 GECODE_MINIMODEL_EXPORT LinRel
00621 operator >=(const LinExpr& l, int r);
00623 GECODE_MINIMODEL_EXPORT LinRel
00624 operator >=(const IntVar& l, const IntVar& r);
00626 GECODE_MINIMODEL_EXPORT LinRel
00627 operator >=(const IntVar& l, const BoolVar& r);
00629 GECODE_MINIMODEL_EXPORT LinRel
00630 operator >=(const BoolVar& l, const IntVar& r);
00632 GECODE_MINIMODEL_EXPORT LinRel
00633 operator >=(const BoolVar& l, const BoolVar& r);
00635 GECODE_MINIMODEL_EXPORT LinRel
00636 operator >=(const IntVar& l, const LinExpr& r);
00638 GECODE_MINIMODEL_EXPORT LinRel
00639 operator >=(const BoolVar& l, const LinExpr& r);
00641 GECODE_MINIMODEL_EXPORT LinRel
00642 operator >=(const LinExpr& l, const IntVar& r);
00644 GECODE_MINIMODEL_EXPORT LinRel
00645 operator >=(const LinExpr& l, const BoolVar& r);
00647 GECODE_MINIMODEL_EXPORT LinRel
00648 operator >=(const LinExpr& l, const LinExpr& r);
00650
00651
00653 class BoolExpr {
00654 public:
00656 enum NodeType {
00657 NT_VAR,
00658 NT_NOT,
00659 NT_AND,
00660 NT_OR,
00661 NT_EQV,
00662 NT_RLIN
00663 };
00665 class Node {
00666 public:
00668 unsigned int use;
00670 unsigned int same;
00672 NodeType t;
00674 Node *l, *r;
00676 BoolVar x;
00678 LinRel rl;
00679
00681 Node(void);
00683 GECODE_MINIMODEL_EXPORT
00684 bool decrement(void);
00686 static void* operator new(size_t size);
00688 static void operator delete(void* p, size_t size);
00689 };
00691 class NNF {
00692 public:
00694 NodeType t;
00696 unsigned int p;
00698 unsigned int n;
00700 union {
00702 struct {
00704 NNF* l;
00706 NNF* r;
00707 } b;
00709 struct {
00711 bool neg;
00713 Node* x;
00714 } a;
00715 } u;
00717 GECODE_MINIMODEL_EXPORT
00718 static NNF* nnf(Region& r, Node* n, bool neg);
00720 GECODE_MINIMODEL_EXPORT
00721 void post(Home home, NodeType t,
00722 BoolVarArgs& bp, BoolVarArgs& bn,
00723 int& ip, int& in,
00724 IntConLevel icl) const;
00726 GECODE_MINIMODEL_EXPORT
00727 BoolVar post(Home home, IntConLevel icl) const;
00729 GECODE_MINIMODEL_EXPORT
00730 void post(Home home, bool t, IntConLevel icl) const;
00732 static void* operator new(size_t s, Region& r);
00734 static void operator delete(void*);
00736 static void operator delete(void*, Region&);
00737 };
00738 private:
00740 Node* n;
00741 public:
00743 BoolExpr(const BoolExpr& e);
00745 BoolExpr(const BoolExpr& l, NodeType t, const BoolExpr& r);
00747 BoolExpr(const BoolVar& x);
00749 BoolExpr(const BoolExpr& e, NodeType t);
00751 BoolExpr(const LinRel& rl);
00753 BoolVar post(Home home, IntConLevel icl) const;
00755 void post(Home home, bool t, IntConLevel icl) const;
00757 GECODE_MINIMODEL_EXPORT
00758 const BoolExpr& operator =(const BoolExpr& e);
00760 GECODE_MINIMODEL_EXPORT
00761 ~BoolExpr(void);
00762 };
00763
00765 class BoolRel {
00766 private:
00768 BoolExpr e;
00770 bool t;
00771 public:
00773 BoolRel(const BoolExpr& e, bool t);
00775 void post(Home home, IntConLevel icl) const;
00776 };
00777
00792
00793 GECODE_MINIMODEL_EXPORT BoolExpr
00794 operator !(const BoolExpr&);
00796 GECODE_MINIMODEL_EXPORT BoolExpr
00797 operator &&(const BoolExpr&, const BoolExpr&);
00799 GECODE_MINIMODEL_EXPORT BoolExpr
00800 operator ||(const BoolExpr&, const BoolExpr&);
00802 GECODE_MINIMODEL_EXPORT BoolExpr
00803 operator ^(const BoolExpr&, const BoolExpr&);
00805 GECODE_MINIMODEL_EXPORT BoolExpr
00806 operator ~(const LinRel&);
00807
00809 GECODE_MINIMODEL_EXPORT BoolExpr
00810 eqv(const BoolExpr&, const BoolExpr&);
00812 GECODE_MINIMODEL_EXPORT BoolExpr
00813 imp(const BoolExpr&, const BoolExpr&);
00814
00816 GECODE_MINIMODEL_EXPORT BoolRel
00817 tt(const BoolExpr&);
00818
00820 GECODE_MINIMODEL_EXPORT BoolRel
00821 ff(const BoolExpr&);
00823
00830
00831 GECODE_MINIMODEL_EXPORT IntVar
00832 post(Home home, const LinExpr& e, IntConLevel icl=ICL_DEF);
00834 GECODE_MINIMODEL_EXPORT void
00835 post(Home home, const LinRel& r, IntConLevel icl=ICL_DEF);
00837 GECODE_MINIMODEL_EXPORT BoolVar
00838 post(Home home, const BoolExpr& e, IntConLevel icl=ICL_DEF);
00840 GECODE_MINIMODEL_EXPORT void
00841 post(Home home, const BoolRel& r, IntConLevel icl=ICL_DEF);
00843
00844 }
00845
00846 #include <gecode/minimodel/lin-expr.hpp>
00847 #include <gecode/minimodel/lin-rel.hpp>
00848 #include <gecode/minimodel/bool-expr.hpp>
00849 #include <gecode/minimodel/bool-rel.hpp>
00850
00851 namespace Gecode {
00852
00853 namespace MiniModel {
00854 class ExpInfo;
00855 }
00856
00862 class GECODE_MINIMODEL_EXPORT REG {
00863 friend class MiniModel::ExpInfo;
00864 private:
00866 class Exp;
00868 Exp* e;
00870 REG(Exp* e);
00871 public:
00873 REG(void);
00875 REG(int s);
00882 REG(const IntArgs& x);
00883
00885 REG(const REG& r);
00887 const REG& operator =(const REG& r);
00888
00890 REG operator +(const REG& r);
00892 REG& operator +=(const REG& r);
00894 REG operator |(const REG& r);
00896 REG& operator |=(const REG& r);
00898 REG operator *(void);
00900 REG operator +(void);
00902 REG operator ()(unsigned int n, unsigned int m);
00904 REG operator ()(unsigned int n);
00906 template<class Char, class Traits>
00907 std::basic_ostream<Char,Traits>&
00908 print(std::basic_ostream<Char,Traits>& os) const;
00910 operator DFA(void);
00912 ~REG(void);
00913 };
00914
00918 template<class Char, class Traits>
00919 std::basic_ostream<Char,Traits>&
00920 operator <<(std::basic_ostream<Char,Traits>& os, const REG& r);
00921
00922
00934 IntVar
00935 abs(Home home, IntVar x,
00936 IntConLevel icl=ICL_DEF);
00942 IntVar
00943 min(Home home, IntVar x, IntVar y,
00944 IntConLevel icl=ICL_DEF);
00950 IntVar
00951 min(Home home, const IntVarArgs& x,
00952 IntConLevel icl=ICL_DEF);
00958 IntVar
00959 max(Home home, IntVar x, IntVar y,
00960 IntConLevel icl=ICL_DEF);
00966 IntVar
00967 max(Home home, const IntVarArgs& x,
00968 IntConLevel icl=ICL_DEF);
00974 IntVar
00975 mult(Home home, IntVar x, IntVar y,
00976 IntConLevel icl=ICL_DEF);
00981 IntVar
00982 div(Home home, IntVar x, IntVar y,
00983 IntConLevel icl=ICL_DEF);
00988 IntVar
00989 mod(Home home, IntVar x, IntVar y,
00990 IntConLevel icl=ICL_DEF);
00996 IntVar
00997 sqr(Home home, IntVar x,
00998 IntConLevel icl=ICL_DEF);
01004 IntVar
01005 sqrt(Home home, IntVar x,
01006 IntConLevel icl=ICL_DEF);
01012 IntVar
01013 plus(Home home, IntVar x, IntVar y,
01014 IntConLevel icl=ICL_DEF);
01020 IntVar
01021 minus(Home home, IntVar x, IntVar y,
01022 IntConLevel icl=ICL_DEF);
01024 }
01025
01026 #include <gecode/minimodel/arithmetic.hpp>
01027
01028 namespace Gecode {
01029
01036
01037 inline BoolVar
01038 channel(Home home, IntVar x,
01039 IntConLevel icl=ICL_DEF) {
01040 (void) icl;
01041 BoolVar b(home,0,1); channel(home,b,x);
01042 return b;
01043 }
01045 inline IntVar
01046 channel(Home home, BoolVar b,
01047 IntConLevel icl=ICL_DEF) {
01048 (void) icl;
01049 IntVar x(home,0,1); channel(home,b,x);
01050 return x;
01051 }
01053
01054 }
01055
01056 namespace Gecode {
01057
01072 inline void
01073 atmost(Home home, const IntVarArgs& x, int n, int m,
01074 IntConLevel icl=ICL_DEF) {
01075 count(home,x,n,IRT_LQ,m,icl);
01076 }
01081 inline void
01082 atmost(Home home, const IntVarArgs& x, IntVar y, int m,
01083 IntConLevel icl=ICL_DEF) {
01084 count(home,x,y,IRT_LQ,m,icl);
01085 }
01093 inline void
01094 atmost(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01095 IntConLevel icl=ICL_DEF) {
01096 count(home,x,y,IRT_LQ,m,icl);
01097 }
01102 inline void
01103 atmost(Home home, const IntVarArgs& x, int n, IntVar z,
01104 IntConLevel icl=ICL_DEF) {
01105 count(home,x,n,IRT_LQ,z,icl);
01106 }
01111 inline void
01112 atmost(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01113 IntConLevel icl=ICL_DEF) {
01114 count(home,x,y,IRT_LQ,z,icl);
01115 }
01123 inline void
01124 atmost(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01125 IntConLevel icl=ICL_DEF) {
01126 count(home,x,y,IRT_LQ,z,icl);
01127 }
01128
01133 inline void
01134 atleast(Home home, const IntVarArgs& x, int n, int m,
01135 IntConLevel icl=ICL_DEF) {
01136 count(home,x,n,IRT_GQ,m,icl);
01137 }
01142 inline void
01143 atleast(Home home, const IntVarArgs& x, IntVar y, int m,
01144 IntConLevel icl=ICL_DEF) {
01145 count(home,x,y,IRT_GQ,m,icl);
01146 }
01154 inline void
01155 atleast(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01156 IntConLevel icl=ICL_DEF) {
01157 count(home,x,y,IRT_GQ,m,icl);
01158 }
01163 inline void
01164 atleast(Home home, const IntVarArgs& x, int n, IntVar z,
01165 IntConLevel icl=ICL_DEF) {
01166 count(home,x,n,IRT_GQ,z,icl);
01167 }
01172 inline void
01173 atleast(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01174 IntConLevel icl=ICL_DEF) {
01175 count(home,x,y,IRT_GQ,z,icl);
01176 }
01184 inline void
01185 atleast(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01186 IntConLevel icl=ICL_DEF) {
01187 count(home,x,y,IRT_GQ,z,icl);
01188 }
01189
01194 inline void
01195 exactly(Home home, const IntVarArgs& x, int n, int m,
01196 IntConLevel icl=ICL_DEF) {
01197 count(home,x,n,IRT_EQ,m,icl);
01198 }
01203 inline void
01204 exactly(Home home, const IntVarArgs& x, IntVar y, int m,
01205 IntConLevel icl=ICL_DEF) {
01206 count(home,x,y,IRT_EQ,m,icl);
01207 }
01215 inline void
01216 exactly(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01217 IntConLevel icl=ICL_DEF) {
01218 count(home,x,y,IRT_EQ,m,icl);
01219 }
01224 inline void
01225 exactly(Home home, const IntVarArgs& x, int n, IntVar z,
01226 IntConLevel icl=ICL_DEF) {
01227 count(home,x,n,IRT_EQ,z,icl);
01228 }
01233 inline void
01234 exactly(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01235 IntConLevel icl=ICL_DEF) {
01236 count(home,x,y,IRT_EQ,z,icl);
01237 }
01245 inline void
01246 exactly(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01247 IntConLevel icl=ICL_DEF) {
01248 count(home,x,y,IRT_EQ,z,icl);
01249 }
01255 inline void
01256 lex(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
01257 IntConLevel icl=ICL_DEF) {
01258 rel(home,x,r,y,icl);
01259 }
01265 inline void
01266 lex(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
01267 IntConLevel icl=ICL_DEF) {
01268 rel(home,x,r,y,icl);
01269 }
01270
01272
01273 }
01274
01275 namespace Gecode {
01276
01287 template<class A>
01288 class Matrix {
01289 public:
01291 typedef typename ArrayTraits<A>::value_type value_type;
01293 typedef typename ArrayTraits<A>::args_type args_type;
01294
01302 class Slice {
01303 args_type _r;
01304 unsigned int _fc,
01305 _tc,
01306 _fr,
01307 _tr;
01308 public:
01310 Slice(Matrix<A>& a, int fc, int tc, int fr, int tr);
01314 Slice& reverse(void);
01316 operator typename Matrix<A>::args_type(void);
01318 operator Matrix<typename Matrix<A>::args_type>(void);
01319 };
01320
01321 private:
01323 typedef typename ArrayTraits<A>::storage_type storage_type;
01324 storage_type _a;
01325 int _w;
01326 int _h;
01327
01328 public:
01341 Matrix(A a, int w, int h);
01342
01355 Matrix(A a, int n);
01356
01358 int width(void) const;
01360 int height(void) const;
01362 args_type const get_array(void) const;
01363
01369 value_type& operator ()(int c, int r);
01370
01380 Slice slice(int fc, int tc, int fr, int tr);
01381
01383 Slice row(int r);
01384
01386 Slice col(int c);
01387 };
01388
01395 void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,
01396 IntVar z, IntConLevel icl=ICL_DEF);
01403 void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,
01404 BoolVar z, IntConLevel icl=ICL_DEF);
01411 void element(Home home, const Matrix<IntVarArgs>& m, IntVar x, IntVar y,
01412 IntVar z, IntConLevel icl=ICL_DEF);
01419 void element(Home home, const Matrix<BoolVarArgs>& m, IntVar x, IntVar y,
01420 BoolVar z, IntConLevel icl=ICL_DEF);
01421 #ifdef GECODE_HAS_SET_VARS
01422
01428 void element(Home home, const Matrix<IntSetArgs>& m, IntVar x, IntVar y,
01429 SetVar z);
01436 void element(Home home, const Matrix<SetVarArgs>& m, IntVar x, IntVar y,
01437 SetVar z);
01438 #endif
01439
01440 }
01441
01442 #include <gecode/minimodel/matrix.hpp>
01443
01444 namespace Gecode {
01445
01455 namespace MiniModel {
01456
01458 template<IntRelType irt>
01459 class OptimizeSpace : public Space {
01460 public:
01462 OptimizeSpace(void);
01464 OptimizeSpace(bool share, OptimizeSpace& s);
01466 virtual void constrain(const Space& best);
01468 virtual IntVar cost(void) const = 0;
01469 };
01470
01471 }
01472
01474 typedef MiniModel::OptimizeSpace<IRT_LE> MinimizeSpace;
01475
01477 typedef MiniModel::OptimizeSpace<IRT_GR> MaximizeSpace;
01479
01480 }
01481
01482 #include <gecode/minimodel/optimize.hpp>
01483
01484 #endif
01485
01486
01487
01488