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 #include <gecode/int/linear.hh>
00048
00049 #include <gecode/minimodel/exception.hpp>
00050
00051 #include <iostream>
00052
00053
00054
00055
00056
00057
00058 #if !defined(GECODE_STATIC_LIBS) && \
00059 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00060
00061 #ifdef GECODE_BUILD_MINIMODEL
00062 #define GECODE_MINIMODEL_EXPORT __declspec( dllexport )
00063 #else
00064 #define GECODE_MINIMODEL_EXPORT __declspec( dllimport )
00065 #endif
00066
00067 #else
00068
00069 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00070
00071 #define GECODE_MINIMODEL_EXPORT __attribute__ ((visibility("default")))
00072
00073 #else
00074
00075 #define GECODE_MINIMODEL_EXPORT
00076
00077 #endif
00078 #endif
00079
00080
00081 #ifndef GECODE_BUILD_MINIMODEL
00082 #define GECODE_LIBRARY_NAME "MiniModel"
00083 #include <gecode/support/auto-link.hpp>
00084 #endif
00085
00086 namespace Gecode {
00087
00089 namespace MiniModel {}
00090
00092 template <class Var>
00093 class LinExpr {
00094 public:
00096 enum NodeType {
00097 NT_VAR,
00098 NT_ADD,
00099 NT_SUB,
00100 NT_MUL
00101 };
00102 private:
00103 typedef typename VarViewTraits<Var>::View View;
00105 class Node {
00106 public:
00108 unsigned int use;
00110 unsigned int n;
00112 NodeType t;
00114 Node *l, *r;
00116 int a, c;
00118 Var x;
00120 Node(void);
00122 int fill(Int::Linear::Term<View> t[], int i, int m,
00123 int c_i, int& c_o) const;
00125 bool decrement(void);
00127 static void* operator new(size_t size);
00129 static void operator delete(void* p,size_t size);
00130 };
00131 Node* n;
00132 public:
00134 LinExpr(void);
00136 LinExpr(const Var& x, int a=1);
00138 LinExpr(const LinExpr& e);
00140 LinExpr(const LinExpr& e0, NodeType t, const LinExpr& e1);
00142 LinExpr(const LinExpr& e0, NodeType t, int c);
00144 LinExpr(int a, const LinExpr& e);
00146 const LinExpr& operator =(const LinExpr& e);
00148 void post(Space& home, IntRelType irt, IntConLevel icl) const;
00150 void post(Space& home, IntRelType irt, const BoolVar& b,
00151 IntConLevel icl) const;
00153 IntVar post(Space& home, IntConLevel icl) const;
00155 ~LinExpr(void);
00156 };
00157
00159 template<class Var>
00160 class LinRel {
00161 private:
00163 LinExpr<Var> e;
00165 IntRelType irt;
00167 static IntRelType neg(IntRelType irt);
00168 public:
00170 LinRel(void);
00172 LinRel(const LinExpr<Var>& l, IntRelType irt, const LinExpr<Var>& r);
00174 LinRel(const LinExpr<Var>& l, IntRelType irt, int r);
00176 LinRel(int l, IntRelType irt, const LinExpr<Var>& r);
00178 void post(Space& home, bool t, IntConLevel icl) const;
00180 void post(Space& home, const BoolVar& b, bool t, IntConLevel icl) const;
00181 };
00182
00201
00202 LinExpr<IntVar>
00203 operator +(int, const IntVar&);
00205 LinExpr<IntVar>
00206 operator +(int, const LinExpr<IntVar>&);
00208 LinExpr<IntVar>
00209 operator +(const IntVar&, int);
00211 LinExpr<IntVar>
00212 operator +(const LinExpr<IntVar>&, int);
00214 LinExpr<IntVar>
00215 operator +(const IntVar&, const IntVar&);
00217 LinExpr<IntVar>
00218 operator +(const IntVar&, const LinExpr<IntVar>&);
00220 LinExpr<IntVar>
00221 operator +(const LinExpr<IntVar>&, const IntVar&);
00223 LinExpr<IntVar>
00224 operator +(const LinExpr<IntVar>&, const LinExpr<IntVar>&);
00225
00227 LinExpr<IntVar>
00228 operator -(int, const IntVar&);
00230 LinExpr<IntVar>
00231 operator -(int, const LinExpr<IntVar>&);
00233 LinExpr<IntVar>
00234 operator -(const IntVar&, int);
00236 LinExpr<IntVar>
00237 operator -(const LinExpr<IntVar>&, int);
00239 LinExpr<IntVar>
00240 operator -(const IntVar&, const IntVar&);
00242 LinExpr<IntVar>
00243 operator -(const IntVar&, const LinExpr<IntVar>&);
00245 LinExpr<IntVar>
00246 operator -(const LinExpr<IntVar>&, const IntVar&);
00248 LinExpr<IntVar>
00249 operator -(const LinExpr<IntVar>&, const LinExpr<IntVar>&);
00251 LinExpr<IntVar>
00252 operator -(const IntVar&);
00254 LinExpr<IntVar>
00255 operator -(const LinExpr<IntVar>&);
00256
00258 LinExpr<IntVar>
00259 operator *(int, const IntVar&);
00261 LinExpr<IntVar>
00262 operator *(const IntVar&, int);
00264 LinExpr<IntVar>
00265 operator *(const LinExpr<IntVar>&, int);
00267 LinExpr<IntVar>
00268 operator *(int, const LinExpr<IntVar>&);
00269
00270
00272 LinExpr<BoolVar>
00273 operator +(int, const BoolVar&);
00275 LinExpr<BoolVar>
00276 operator +(int, const LinExpr<BoolVar>&);
00278 LinExpr<BoolVar>
00279 operator +(const BoolVar&, int);
00281 LinExpr<BoolVar>
00282 operator +(const LinExpr<BoolVar>&, int);
00284 LinExpr<BoolVar>
00285 operator +(const BoolVar&, const BoolVar&);
00287 LinExpr<BoolVar>
00288 operator +(const BoolVar&, const LinExpr<BoolVar>&);
00290 LinExpr<BoolVar>
00291 operator +(const LinExpr<BoolVar>&, const BoolVar&);
00293 LinExpr<BoolVar>
00294 operator +(const LinExpr<BoolVar>&, const LinExpr<BoolVar>&);
00295
00297 LinExpr<BoolVar>
00298 operator -(int, const BoolVar&);
00300 LinExpr<BoolVar>
00301 operator -(int, const LinExpr<BoolVar>&);
00303 LinExpr<BoolVar>
00304 operator -(const BoolVar&, int);
00306 LinExpr<BoolVar>
00307 operator -(const LinExpr<BoolVar>&, int);
00309 LinExpr<BoolVar>
00310 operator -(const BoolVar&, const BoolVar&);
00312 LinExpr<BoolVar>
00313 operator -(const BoolVar&, const LinExpr<BoolVar>&);
00315 LinExpr<BoolVar>
00316 operator -(const LinExpr<BoolVar>&, const BoolVar&);
00318 LinExpr<BoolVar>
00319 operator -(const LinExpr<BoolVar>&, const LinExpr<BoolVar>&);
00321 LinExpr<BoolVar>
00322 operator -(const BoolVar&);
00324 LinExpr<BoolVar>
00325 operator -(const LinExpr<BoolVar>&);
00326
00328 LinExpr<BoolVar>
00329 operator *(int, const BoolVar&);
00331 LinExpr<BoolVar>
00332 operator *(const BoolVar&, int);
00334 LinExpr<BoolVar>
00335 operator *(const LinExpr<BoolVar>&, int);
00337 LinExpr<BoolVar>
00338 operator *(int, const LinExpr<BoolVar>&);
00339
00340
00342 LinRel<IntVar>
00343 operator ==(int l, const IntVar& r);
00345 LinRel<IntVar>
00346 operator ==(int l, const LinExpr<IntVar>& r);
00348 LinRel<IntVar>
00349 operator ==(const IntVar& l, int r);
00351 LinRel<IntVar>
00352 operator ==(const LinExpr<IntVar>& l, int r);
00354 LinRel<IntVar>
00355 operator ==(const IntVar& l, const IntVar& r);
00357 LinRel<IntVar>
00358 operator ==(const IntVar& l, const LinExpr<IntVar>& r);
00360 LinRel<IntVar>
00361 operator ==(const LinExpr<IntVar>& l, const IntVar& r);
00363 LinRel<IntVar>
00364 operator ==(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00365
00367 LinRel<IntVar>
00368 operator !=(int l, const IntVar& r);
00370 LinRel<IntVar>
00371 operator !=(int l, const LinExpr<IntVar>& r);
00373 LinRel<IntVar>
00374 operator !=(const IntVar& l, int r);
00376 LinRel<IntVar>
00377 operator !=(const LinExpr<IntVar>& l, int r);
00379 LinRel<IntVar>
00380 operator !=(const IntVar& l, const IntVar& r);
00382 LinRel<IntVar>
00383 operator !=(const IntVar& l, const LinExpr<IntVar>& r);
00385 LinRel<IntVar>
00386 operator !=(const LinExpr<IntVar>& l, const IntVar& r);
00388 LinRel<IntVar>
00389 operator !=(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00390
00392 LinRel<IntVar>
00393 operator <(int l, const IntVar& r);
00395 LinRel<IntVar>
00396 operator <(int l, const LinExpr<IntVar>& r);
00398 LinRel<IntVar>
00399 operator <(const IntVar& l, int r);
00401 LinRel<IntVar>
00402 operator <(const LinExpr<IntVar>& l, int r);
00404 LinRel<IntVar>
00405 operator <(const IntVar& l, const IntVar& r);
00407 LinRel<IntVar>
00408 operator <(const IntVar& l, const LinExpr<IntVar>& r);
00410 LinRel<IntVar>
00411 operator <(const LinExpr<IntVar>& l, const IntVar& r);
00413 LinRel<IntVar>
00414 operator <(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00415
00417 LinRel<IntVar>
00418 operator <=(int l, const IntVar& r);
00420 LinRel<IntVar>
00421 operator <=(int l, const LinExpr<IntVar>& r);
00423 LinRel<IntVar>
00424 operator <=(const IntVar& l, int r);
00426 LinRel<IntVar>
00427 operator <=(const LinExpr<IntVar>& l, int r);
00429 LinRel<IntVar>
00430 operator <=(const IntVar& l, const IntVar& r);
00432 LinRel<IntVar>
00433 operator <=(const IntVar& l, const LinExpr<IntVar>& r);
00435 LinRel<IntVar>
00436 operator <=(const LinExpr<IntVar>& l, const IntVar& r);
00438 LinRel<IntVar>
00439 operator <=(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00440
00442 LinRel<IntVar>
00443 operator >(int l, const IntVar& r);
00445 LinRel<IntVar>
00446 operator >(int l, const LinExpr<IntVar>& r);
00448 LinRel<IntVar>
00449 operator >(const IntVar& l, int r);
00451 LinRel<IntVar>
00452 operator >(const LinExpr<IntVar>& l, int r);
00454 LinRel<IntVar>
00455 operator >(const IntVar& l, const IntVar& r);
00457 LinRel<IntVar>
00458 operator >(const IntVar& l, const LinExpr<IntVar>& r);
00460 LinRel<IntVar>
00461 operator >(const LinExpr<IntVar>& l, const IntVar& r);
00463 LinRel<IntVar>
00464 operator >(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00465
00467 LinRel<IntVar>
00468 operator >=(int l, const IntVar& r);
00470 LinRel<IntVar>
00471 operator >=(int l, const LinExpr<IntVar>& r);
00473 LinRel<IntVar>
00474 operator >=(const IntVar& l, int r);
00476 LinRel<IntVar>
00477 operator >=(const LinExpr<IntVar>& l, int r);
00479 LinRel<IntVar>
00480 operator >=(const IntVar& l, const IntVar& r);
00482 LinRel<IntVar>
00483 operator >=(const IntVar& l, const LinExpr<IntVar>& r);
00485 LinRel<IntVar>
00486 operator >=(const LinExpr<IntVar>& l, const IntVar& r);
00488 LinRel<IntVar>
00489 operator >=(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00490
00491
00493 LinRel<BoolVar>
00494 operator ==(int l, const BoolVar& r);
00496 LinRel<BoolVar>
00497 operator ==(int l, const LinExpr<BoolVar>& r);
00499 LinRel<BoolVar>
00500 operator ==(const BoolVar& l, int r);
00502 LinRel<BoolVar>
00503 operator ==(const LinExpr<BoolVar>& l, int r);
00505 LinRel<BoolVar>
00506 operator ==(const BoolVar& l, const BoolVar& r);
00508 LinRel<BoolVar>
00509 operator ==(const BoolVar& l, const LinExpr<BoolVar>& r);
00511 LinRel<BoolVar>
00512 operator ==(const LinExpr<BoolVar>& l, const BoolVar& r);
00514 LinRel<BoolVar>
00515 operator ==(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00516
00518 LinRel<BoolVar>
00519 operator !=(int l, const BoolVar& r);
00521 LinRel<BoolVar>
00522 operator !=(int l, const LinExpr<BoolVar>& r);
00524 LinRel<BoolVar>
00525 operator !=(const BoolVar& l, int r);
00527 LinRel<BoolVar>
00528 operator !=(const LinExpr<BoolVar>& l, int r);
00530 LinRel<BoolVar>
00531 operator !=(const BoolVar& l, const BoolVar& r);
00533 LinRel<BoolVar>
00534 operator !=(const BoolVar& l, const LinExpr<BoolVar>& r);
00536 LinRel<BoolVar>
00537 operator !=(const LinExpr<BoolVar>& l, const BoolVar& r);
00539 LinRel<BoolVar>
00540 operator !=(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00541
00543 LinRel<BoolVar>
00544 operator <(int l, const BoolVar& r);
00546 LinRel<BoolVar>
00547 operator <(int l, const LinExpr<BoolVar>& r);
00549 LinRel<BoolVar>
00550 operator <(const BoolVar& l, int r);
00552 LinRel<BoolVar>
00553 operator <(const LinExpr<BoolVar>& l, int r);
00555 LinRel<BoolVar>
00556 operator <(const BoolVar& l, const BoolVar& r);
00558 LinRel<BoolVar>
00559 operator <(const BoolVar& l, const LinExpr<BoolVar>& r);
00561 LinRel<BoolVar>
00562 operator <(const LinExpr<BoolVar>& l, const BoolVar& r);
00564 LinRel<BoolVar>
00565 operator <(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00566
00568 LinRel<BoolVar>
00569 operator <=(int l, const BoolVar& r);
00571 LinRel<BoolVar>
00572 operator <=(int l, const LinExpr<BoolVar>& r);
00574 LinRel<BoolVar>
00575 operator <=(const BoolVar& l, int r);
00577 LinRel<BoolVar>
00578 operator <=(const LinExpr<BoolVar>& l, int r);
00580 LinRel<BoolVar>
00581 operator <=(const BoolVar& l, const BoolVar& r);
00583 LinRel<BoolVar>
00584 operator <=(const BoolVar& l, const LinExpr<BoolVar>& r);
00586 LinRel<BoolVar>
00587 operator <=(const LinExpr<BoolVar>& l, const BoolVar& r);
00589 LinRel<BoolVar>
00590 operator <=(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00591
00593 LinRel<BoolVar>
00594 operator >(int l, const BoolVar& r);
00596 LinRel<BoolVar>
00597 operator >(int l, const LinExpr<BoolVar>& r);
00599 LinRel<BoolVar>
00600 operator >(const BoolVar& l, int r);
00602 LinRel<BoolVar>
00603 operator >(const LinExpr<BoolVar>& l, int r);
00605 LinRel<BoolVar>
00606 operator >(const BoolVar& l, const BoolVar& r);
00608 LinRel<BoolVar>
00609 operator >(const BoolVar& l, const LinExpr<BoolVar>& r);
00611 LinRel<BoolVar>
00612 operator >(const LinExpr<BoolVar>& l, const BoolVar& r);
00614 LinRel<BoolVar>
00615 operator >(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00616
00618 LinRel<BoolVar>
00619 operator >=(int l, const BoolVar& r);
00621 LinRel<BoolVar>
00622 operator >=(int l, const LinExpr<BoolVar>& r);
00624 LinRel<BoolVar>
00625 operator >=(const BoolVar& l, int r);
00627 LinRel<BoolVar>
00628 operator >=(const LinExpr<BoolVar>& l, int r);
00630 LinRel<BoolVar>
00631 operator >=(const BoolVar& l, const BoolVar& r);
00633 LinRel<BoolVar>
00634 operator >=(const BoolVar& l, const LinExpr<BoolVar>& r);
00636 LinRel<BoolVar>
00637 operator >=(const LinExpr<BoolVar>& l, const BoolVar& r);
00639 LinRel<BoolVar>
00640 operator >=(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00641
00643
00644
00646 class BoolExpr {
00647 public:
00649 enum NodeType {
00650 NT_VAR,
00651 NT_NOT,
00652 NT_AND,
00653 NT_OR,
00654 NT_EQV,
00655 NT_RLIN_INT,
00656 NT_RLIN_BOOL
00657 };
00659 class Node {
00660 public:
00662 unsigned int use;
00664 unsigned int same;
00666 NodeType t;
00668 Node *l, *r;
00670 BoolVar x;
00672 LinRel<IntVar> rl_int;
00674 LinRel<BoolVar> rl_bool;
00675
00677 Node(void);
00679 GECODE_MINIMODEL_EXPORT
00680 bool decrement(void);
00682 static void* operator new(size_t size);
00684 static void operator delete(void* p, size_t size);
00685 };
00687 class NNF {
00688 public:
00690 NodeType t;
00692 unsigned int p;
00694 unsigned int n;
00696 union {
00698 struct {
00700 NNF* l;
00702 NNF* r;
00703 } b;
00705 struct {
00707 bool neg;
00709 Node* x;
00710 } a;
00711 } u;
00713 GECODE_MINIMODEL_EXPORT
00714 static NNF* nnf(Region& r, Node* n, bool neg);
00716 GECODE_MINIMODEL_EXPORT
00717 void post(Space& home, NodeType t,
00718 BoolVarArgs& bp, BoolVarArgs& bn,
00719 int& ip, int& in,
00720 IntConLevel icl) const;
00722 GECODE_MINIMODEL_EXPORT
00723 BoolVar post(Space& home, IntConLevel icl) const;
00725 GECODE_MINIMODEL_EXPORT
00726 void post(Space& home, bool t, IntConLevel icl) const;
00728 static void* operator new(size_t s, Region& r);
00730 static void operator delete(void*);
00732 static void operator delete(void*, Region&);
00733 };
00734 private:
00736 Node* n;
00737 public:
00739 BoolExpr(const BoolExpr& e);
00741 GECODE_MINIMODEL_EXPORT
00742 BoolExpr(const BoolExpr& l, NodeType t, const BoolExpr& r);
00744 GECODE_MINIMODEL_EXPORT
00745 BoolExpr(const BoolVar& x);
00747 GECODE_MINIMODEL_EXPORT
00748 BoolExpr(const BoolExpr& e, NodeType t);
00750 GECODE_MINIMODEL_EXPORT
00751 BoolExpr(const LinRel<IntVar>& rl);
00753 GECODE_MINIMODEL_EXPORT
00754 BoolExpr(const LinRel<BoolVar>& rl);
00756 BoolVar post(Space& home, IntConLevel icl) const;
00758 void post(Space& home, bool t, IntConLevel icl) const;
00759
00761 GECODE_MINIMODEL_EXPORT
00762 const BoolExpr& operator =(const BoolExpr& e);
00764 GECODE_MINIMODEL_EXPORT
00765 ~BoolExpr(void);
00766 };
00767
00769 class BoolRel {
00770 private:
00772 BoolExpr e;
00774 bool t;
00775 public:
00777 BoolRel(const BoolExpr& e, bool t);
00779 void post(Space& home, IntConLevel icl) const;
00780 };
00781
00796
00797 BoolExpr
00798 operator !(const BoolExpr&);
00800 BoolExpr
00801 operator &&(const BoolExpr&, const BoolExpr&);
00803 BoolExpr
00804 operator ||(const BoolExpr&, const BoolExpr&);
00806 BoolExpr
00807 operator ^(const BoolExpr&, const BoolExpr&);
00809 template <class Var>
00810 BoolExpr
00811 operator ~(const LinRel<Var>&);
00812
00814 BoolExpr
00815 eqv(const BoolExpr&, const BoolExpr&);
00817 BoolExpr
00818 imp(const BoolExpr&, const BoolExpr&);
00819
00821 BoolRel
00822 tt(const BoolExpr&);
00823
00825 BoolRel
00826 ff(const BoolExpr&);
00828
00835
00836 template <class Var>
00837 IntVar post(Space& home, const LinExpr<Var>& e,
00838 IntConLevel icl=ICL_DEF);
00840 IntVar post(Space& home, const IntVar& x,
00841 IntConLevel icl=ICL_DEF);
00843 IntVar post(Space& home, int n,
00844 IntConLevel icl=ICL_DEF);
00845
00847 template <class Var>
00848 void post(Space& home, const LinRel<Var>& r,
00849 IntConLevel icl=ICL_DEF);
00851 void post(Space& home, bool r,
00852 IntConLevel icl=ICL_DEF);
00853
00855 BoolVar post(Space& home, const BoolExpr& e,
00856 IntConLevel icl=ICL_DEF);
00858 BoolVar post(Space& home, const BoolVar& b,
00859 IntConLevel icl=ICL_DEF);
00861 void post(Space& home, const BoolRel& r,
00862 IntConLevel icl=ICL_DEF);
00864
00865 }
00866
00867 #include <gecode/minimodel/lin-expr.hpp>
00868 #include <gecode/minimodel/lin-rel.hpp>
00869 #include <gecode/minimodel/bool-expr.hpp>
00870 #include <gecode/minimodel/bool-rel.hpp>
00871
00872 namespace Gecode {
00873
00879 class GECODE_MINIMODEL_EXPORT REG {
00880 private:
00882 class Exp;
00884 Exp* e;
00886 REG(Exp* e);
00887 public:
00889 REG(void);
00891 REG(int s);
00898 REG(const IntArgs& x);
00899
00901 REG(const REG& r);
00903 const REG& operator =(const REG& r);
00904
00906 REG operator +(const REG& r);
00908 REG& operator +=(const REG& r);
00910 REG operator |(const REG& r);
00912 REG& operator |=(const REG& r);
00914 REG operator *(void);
00916 REG operator +(void);
00918 REG operator ()(unsigned int n, unsigned int m);
00920 REG operator ()(unsigned int n);
00922 template<class Char, class Traits>
00923 std::basic_ostream<Char,Traits>&
00924 print(std::basic_ostream<Char,Traits>& os) const;
00926 operator DFA(void);
00928 ~REG(void);
00929 };
00930
00934 template<class Char, class Traits>
00935 std::basic_ostream<Char,Traits>&
00936 operator <<(std::basic_ostream<Char,Traits>& os, const REG& r);
00937
00938
00950 IntVar
00951 abs(Space& home, IntVar x,
00952 IntConLevel icl=ICL_DEF);
00958 IntVar
00959 min(Space& home, IntVar x, IntVar y,
00960 IntConLevel icl=ICL_DEF);
00966 IntVar
00967 min(Space& home, const IntVarArgs& x,
00968 IntConLevel icl=ICL_DEF);
00974 IntVar
00975 max(Space& home, IntVar x, IntVar y,
00976 IntConLevel icl=ICL_DEF);
00982 IntVar
00983 max(Space& home, const IntVarArgs& x,
00984 IntConLevel icl=ICL_DEF);
00990 IntVar
00991 mult(Space& home, IntVar x, IntVar y,
00992 IntConLevel icl=ICL_DEF);
00997 IntVar
00998 div(Space& home, IntVar x, IntVar y,
00999 IntConLevel icl=ICL_DEF);
01004 IntVar
01005 mod(Space& home, IntVar x, IntVar y,
01006 IntConLevel icl=ICL_DEF);
01012 IntVar
01013 sqr(Space& home, IntVar x,
01014 IntConLevel icl=ICL_DEF);
01020 IntVar
01021 sqrt(Space& home, IntVar x,
01022 IntConLevel icl=ICL_DEF);
01028 IntVar
01029 plus(Space& home, IntVar x, IntVar y,
01030 IntConLevel icl=ICL_DEF);
01036 IntVar
01037 minus(Space& home, IntVar x, IntVar y,
01038 IntConLevel icl=ICL_DEF);
01040 }
01041
01042 #include <gecode/minimodel/arithmetic.hpp>
01043
01044 namespace Gecode {
01045
01052
01053 inline BoolVar
01054 channel(Space& home, IntVar x,
01055 IntConLevel icl=ICL_DEF) {
01056 (void) icl;
01057 BoolVar b(home,0,1); channel(home,b,x);
01058 return b;
01059 }
01061 inline IntVar
01062 channel(Space& home, BoolVar b,
01063 IntConLevel icl=ICL_DEF) {
01064 (void) icl;
01065 IntVar x(home,0,1); channel(home,b,x);
01066 return x;
01067 }
01069
01070 }
01071
01072 namespace Gecode {
01073
01088 inline void
01089 atmost(Space& home, const IntVarArgs& x, int n, int m,
01090 IntConLevel icl=ICL_DEF) {
01091 count(home,x,n,IRT_LQ,m,icl);
01092 }
01097 inline void
01098 atmost(Space& home, const IntVarArgs& x, IntVar y, int m,
01099 IntConLevel icl=ICL_DEF) {
01100 count(home,x,y,IRT_LQ,m,icl);
01101 }
01109 inline void
01110 atmost(Space& home, const IntVarArgs& x, const IntArgs& y, int m,
01111 IntConLevel icl=ICL_DEF) {
01112 count(home,x,y,IRT_LQ,m,icl);
01113 }
01118 inline void
01119 atmost(Space& home, const IntVarArgs& x, int n, IntVar z,
01120 IntConLevel icl=ICL_DEF) {
01121 count(home,x,n,IRT_LQ,z,icl);
01122 }
01127 inline void
01128 atmost(Space& home, const IntVarArgs& x, IntVar y, IntVar z,
01129 IntConLevel icl=ICL_DEF) {
01130 count(home,x,y,IRT_LQ,z,icl);
01131 }
01139 inline void
01140 atmost(Space& home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01141 IntConLevel icl=ICL_DEF) {
01142 count(home,x,y,IRT_LQ,z,icl);
01143 }
01144
01149 inline void
01150 atleast(Space& home, const IntVarArgs& x, int n, int m,
01151 IntConLevel icl=ICL_DEF) {
01152 count(home,x,n,IRT_GQ,m,icl);
01153 }
01158 inline void
01159 atleast(Space& home, const IntVarArgs& x, IntVar y, int m,
01160 IntConLevel icl=ICL_DEF) {
01161 count(home,x,y,IRT_GQ,m,icl);
01162 }
01170 inline void
01171 atleast(Space& home, const IntVarArgs& x, const IntArgs& y, int m,
01172 IntConLevel icl=ICL_DEF) {
01173 count(home,x,y,IRT_GQ,m,icl);
01174 }
01179 inline void
01180 atleast(Space& home, const IntVarArgs& x, int n, IntVar z,
01181 IntConLevel icl=ICL_DEF) {
01182 count(home,x,n,IRT_GQ,z,icl);
01183 }
01188 inline void
01189 atleast(Space& home, const IntVarArgs& x, IntVar y, IntVar z,
01190 IntConLevel icl=ICL_DEF) {
01191 count(home,x,y,IRT_GQ,z,icl);
01192 }
01200 inline void
01201 atleast(Space& home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01202 IntConLevel icl=ICL_DEF) {
01203 count(home,x,y,IRT_GQ,z,icl);
01204 }
01205
01210 inline void
01211 exactly(Space& home, const IntVarArgs& x, int n, int m,
01212 IntConLevel icl=ICL_DEF) {
01213 count(home,x,n,IRT_EQ,m,icl);
01214 }
01219 inline void
01220 exactly(Space& home, const IntVarArgs& x, IntVar y, int m,
01221 IntConLevel icl=ICL_DEF) {
01222 count(home,x,y,IRT_EQ,m,icl);
01223 }
01231 inline void
01232 exactly(Space& home, const IntVarArgs& x, const IntArgs& y, int m,
01233 IntConLevel icl=ICL_DEF) {
01234 count(home,x,y,IRT_EQ,m,icl);
01235 }
01240 inline void
01241 exactly(Space& home, const IntVarArgs& x, int n, IntVar z,
01242 IntConLevel icl=ICL_DEF) {
01243 count(home,x,n,IRT_EQ,z,icl);
01244 }
01249 inline void
01250 exactly(Space& home, const IntVarArgs& x, IntVar y, IntVar z,
01251 IntConLevel icl=ICL_DEF) {
01252 count(home,x,y,IRT_EQ,z,icl);
01253 }
01261 inline void
01262 exactly(Space& home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01263 IntConLevel icl=ICL_DEF) {
01264 count(home,x,y,IRT_EQ,z,icl);
01265 }
01271 inline void
01272 lex(Space& home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
01273 IntConLevel icl=ICL_DEF) {
01274 rel(home,x,r,y,icl);
01275 }
01281 inline void
01282 lex(Space& home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
01283 IntConLevel icl=ICL_DEF) {
01284 rel(home,x,r,y,icl);
01285 }
01286
01288
01289 }
01290
01291 namespace Gecode {
01292
01303 template <class A>
01304 class Matrix {
01305 public:
01307 typedef typename ArrayTraits<A>::value_type value_type;
01309 typedef typename ArrayTraits<A>::args_type args_type;
01310
01318 class Slice {
01319 args_type _r;
01320 unsigned int _fc,
01321 _tc,
01322 _fr,
01323 _tr;
01324 public:
01325 Slice(Matrix<A>& a,
01326 unsigned int fc, unsigned int tc,
01327 unsigned int fr, unsigned int tr);
01328
01332 Slice& reverse(void);
01333
01334 operator args_type(void);
01335 operator Matrix<args_type>(void);
01336 };
01337
01338 private:
01340 typedef typename ArrayTraits<A>::storage_type storage_type;
01341 storage_type _a;
01342 unsigned int _w,
01343 _h;
01344
01345 public:
01358 Matrix(A a, unsigned int w, unsigned int h);
01359
01372 Matrix(A a, unsigned int n);
01373
01375 unsigned int width(void) const;
01377 unsigned int height(void) const;
01379 args_type const get_array(void);
01380
01386 value_type& operator ()(unsigned int c, unsigned int r);
01387
01397 Slice slice(unsigned int fc, unsigned int tc,
01398 unsigned int fr, unsigned int tr);
01399
01401 Slice row(int r);
01402
01404 Slice col(int c);
01405 };
01406 }
01407
01408 #include <gecode/minimodel/matrix.hpp>
01409
01410 namespace Gecode {
01411
01421 namespace MiniModel {
01422
01424 template <IntRelType irt>
01425 class OptimizeSpace : public Space {
01426 public:
01428 OptimizeSpace(void);
01430 OptimizeSpace(bool share, OptimizeSpace& s);
01432 virtual void constrain(const Space& best);
01434 virtual IntVar cost(void) const = 0;
01435 };
01436
01437 }
01438
01440 typedef MiniModel::OptimizeSpace<IRT_LE> MinimizeSpace;
01441
01443 typedef MiniModel::OptimizeSpace<IRT_GR> MaximizeSpace;
01445
01446 }
01447
01448 #include <gecode/minimodel/optimize.hpp>
01449
01450 #endif
01451
01452
01453
01454