Generated on Mon Nov 30 23:53:33 2009 for Gecode by doxygen 1.6.1

minimodel.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Guido Tack <tack@gecode.org>
00006  *     Mikael Lagerkvist <lagerkvist@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Christian Schulte, 2004
00010  *     Guido Tack, 2004
00011  *     Mikael Lagerkvist, 2005
00012  *
00013  *  Last modified:
00014  *     $Date: 2009-11-03 17:23:42 +0100 (Tue, 03 Nov 2009) $ by $Author: schulte $
00015  *     $Revision: 10032 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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  * Support for DLLs under Windows
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 // Configure auto-linking
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 
00095   template<class Var>
00096   class LinExpr {
00097   public:
00099     enum NodeType {
00100       NT_VAR, 
00101       NT_ADD, 
00102       NT_SUB, 
00103       NT_MUL  
00104     };
00105   private:
00106     typedef typename VarViewTraits<Var>::View View;
00108     class Node {
00109     public:
00111       unsigned int use;
00113       unsigned int n;
00115       NodeType t;
00117       Node *l, *r;
00119       int a, c;
00121       Var x;
00123       Node(void);
00125       int fill(Int::Linear::Term<View> t[], int i, int m,
00126                int c_i, int& c_o) const;
00128       bool decrement(void);
00130       static void* operator new(size_t size);
00132       static void  operator delete(void* p,size_t size);
00133     };
00134     Node* n;
00135   public:
00137     LinExpr(void);
00139     LinExpr(const Var& x, int a=1);
00141     LinExpr(const LinExpr& e);
00143     LinExpr(const LinExpr& e0, NodeType t, const LinExpr& e1);
00145     LinExpr(const LinExpr& e0, NodeType t, int c);
00147     LinExpr(int a, const LinExpr& e);
00149     const LinExpr& operator =(const LinExpr& e);
00151     void post(Home home, IntRelType irt, IntConLevel icl) const;
00153     void post(Home home, IntRelType irt, const BoolVar& b,
00154               IntConLevel icl) const;
00156     IntVar post(Home home, IntConLevel icl) const;
00158     ~LinExpr(void);
00159   };
00160 
00162   template<class Var>
00163   class LinRel {
00164   private:
00166     LinExpr<Var> e;
00168     IntRelType   irt;
00170     static IntRelType neg(IntRelType irt);
00171   public:
00173     LinRel(void);
00175     LinRel(const LinExpr<Var>& l, IntRelType irt, const LinExpr<Var>& r);
00177     LinRel(const LinExpr<Var>& l, IntRelType irt, int r);
00179     LinRel(int l, IntRelType irt, const LinExpr<Var>& r);
00181     void post(Home home, bool t,  IntConLevel icl) const;
00183     void post(Home home, const BoolVar& b, bool t, IntConLevel icl) const;
00184   };
00185 
00204 
00205   LinExpr<IntVar>
00206   operator +(int, const IntVar&);
00208   LinExpr<IntVar>
00209   operator +(int, const LinExpr<IntVar>&);
00211   LinExpr<IntVar>
00212   operator +(const IntVar&, int);
00214   LinExpr<IntVar>
00215   operator +(const LinExpr<IntVar>&, int);
00217   LinExpr<IntVar>
00218   operator +(const IntVar&, const IntVar&);
00220   LinExpr<IntVar>
00221   operator +(const IntVar&, const LinExpr<IntVar>&);
00223   LinExpr<IntVar>
00224   operator +(const LinExpr<IntVar>&, const IntVar&);
00226   LinExpr<IntVar>
00227   operator +(const LinExpr<IntVar>&, const LinExpr<IntVar>&);
00228 
00230   LinExpr<IntVar>
00231   operator -(int, const IntVar&);
00233   LinExpr<IntVar>
00234   operator -(int, const LinExpr<IntVar>&);
00236   LinExpr<IntVar>
00237   operator -(const IntVar&, int);
00239   LinExpr<IntVar>
00240   operator -(const LinExpr<IntVar>&, int);
00242   LinExpr<IntVar>
00243   operator -(const IntVar&, const IntVar&);
00245   LinExpr<IntVar>
00246   operator -(const IntVar&, const LinExpr<IntVar>&);
00248   LinExpr<IntVar>
00249   operator -(const LinExpr<IntVar>&, const IntVar&);
00251   LinExpr<IntVar>
00252   operator -(const LinExpr<IntVar>&, const LinExpr<IntVar>&);
00254   LinExpr<IntVar>
00255   operator -(const IntVar&);
00257   LinExpr<IntVar>
00258   operator -(const LinExpr<IntVar>&);
00259 
00261   LinExpr<IntVar>
00262   operator *(int, const IntVar&);
00264   LinExpr<IntVar>
00265   operator *(const IntVar&, int);
00267   LinExpr<IntVar>
00268   operator *(const LinExpr<IntVar>&, int);
00270   LinExpr<IntVar>
00271   operator *(int, const LinExpr<IntVar>&);
00272 
00273 
00275   LinExpr<BoolVar>
00276   operator +(int, const BoolVar&);
00278   LinExpr<BoolVar>
00279   operator +(int, const LinExpr<BoolVar>&);
00281   LinExpr<BoolVar>
00282   operator +(const BoolVar&, int);
00284   LinExpr<BoolVar>
00285   operator +(const LinExpr<BoolVar>&, int);
00287   LinExpr<BoolVar>
00288   operator +(const BoolVar&, const BoolVar&);
00290   LinExpr<BoolVar>
00291   operator +(const BoolVar&, const LinExpr<BoolVar>&);
00293   LinExpr<BoolVar>
00294   operator +(const LinExpr<BoolVar>&, const BoolVar&);
00296   LinExpr<BoolVar>
00297   operator +(const LinExpr<BoolVar>&, const LinExpr<BoolVar>&);
00298 
00300   LinExpr<BoolVar>
00301   operator -(int, const BoolVar&);
00303   LinExpr<BoolVar>
00304   operator -(int, const LinExpr<BoolVar>&);
00306   LinExpr<BoolVar>
00307   operator -(const BoolVar&, int);
00309   LinExpr<BoolVar>
00310   operator -(const LinExpr<BoolVar>&, int);
00312   LinExpr<BoolVar>
00313   operator -(const BoolVar&, const BoolVar&);
00315   LinExpr<BoolVar>
00316   operator -(const BoolVar&, const LinExpr<BoolVar>&);
00318   LinExpr<BoolVar>
00319   operator -(const LinExpr<BoolVar>&, const BoolVar&);
00321   LinExpr<BoolVar>
00322   operator -(const LinExpr<BoolVar>&, const LinExpr<BoolVar>&);
00324   LinExpr<BoolVar>
00325   operator -(const BoolVar&);
00327   LinExpr<BoolVar>
00328   operator -(const LinExpr<BoolVar>&);
00329 
00331   LinExpr<BoolVar>
00332   operator *(int, const BoolVar&);
00334   LinExpr<BoolVar>
00335   operator *(const BoolVar&, int);
00337   LinExpr<BoolVar>
00338   operator *(const LinExpr<BoolVar>&, int);
00340   LinExpr<BoolVar>
00341   operator *(int, const LinExpr<BoolVar>&);
00342 
00343 
00345   LinRel<IntVar>
00346   operator ==(int l, const IntVar& r);
00348   LinRel<IntVar>
00349   operator ==(int l, const LinExpr<IntVar>& r);
00351   LinRel<IntVar>
00352   operator ==(const IntVar& l, int r);
00354   LinRel<IntVar>
00355   operator ==(const LinExpr<IntVar>& l, int r);
00357   LinRel<IntVar>
00358   operator ==(const IntVar& l, const IntVar& r);
00360   LinRel<IntVar>
00361   operator ==(const IntVar& l, const LinExpr<IntVar>& r);
00363   LinRel<IntVar>
00364   operator ==(const LinExpr<IntVar>& l, const IntVar& r);
00366   LinRel<IntVar>
00367   operator ==(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00368 
00370   LinRel<IntVar>
00371   operator !=(int l, const IntVar& r);
00373   LinRel<IntVar>
00374   operator !=(int l, const LinExpr<IntVar>& r);
00376   LinRel<IntVar>
00377   operator !=(const IntVar& l, int r);
00379   LinRel<IntVar>
00380   operator !=(const LinExpr<IntVar>& l, int r);
00382   LinRel<IntVar>
00383   operator !=(const IntVar& l, const IntVar& r);
00385   LinRel<IntVar>
00386   operator !=(const IntVar& l, const LinExpr<IntVar>& r);
00388   LinRel<IntVar>
00389   operator !=(const LinExpr<IntVar>& l, const IntVar& r);
00391   LinRel<IntVar>
00392   operator !=(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00393 
00395   LinRel<IntVar>
00396   operator <(int l, const IntVar& r);
00398   LinRel<IntVar>
00399   operator <(int l, const LinExpr<IntVar>& r);
00401   LinRel<IntVar>
00402   operator <(const IntVar& l, int r);
00404   LinRel<IntVar>
00405   operator <(const LinExpr<IntVar>& l, int r);
00407   LinRel<IntVar>
00408   operator <(const IntVar& l, const IntVar& r);
00410   LinRel<IntVar>
00411   operator <(const IntVar& l, const LinExpr<IntVar>& r);
00413   LinRel<IntVar>
00414   operator <(const LinExpr<IntVar>& l, const IntVar& r);
00416   LinRel<IntVar>
00417   operator <(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00418 
00420   LinRel<IntVar>
00421   operator <=(int l, const IntVar& r);
00423   LinRel<IntVar>
00424   operator <=(int l, const LinExpr<IntVar>& r);
00426   LinRel<IntVar>
00427   operator <=(const IntVar& l, int r);
00429   LinRel<IntVar>
00430   operator <=(const LinExpr<IntVar>& l, int r);
00432   LinRel<IntVar>
00433   operator <=(const IntVar& l, const IntVar& r);
00435   LinRel<IntVar>
00436   operator <=(const IntVar& l, const LinExpr<IntVar>& r);
00438   LinRel<IntVar>
00439   operator <=(const LinExpr<IntVar>& l, const IntVar& r);
00441   LinRel<IntVar>
00442   operator <=(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00443 
00445   LinRel<IntVar>
00446   operator >(int l, const IntVar& r);
00448   LinRel<IntVar>
00449   operator >(int l, const LinExpr<IntVar>& r);
00451   LinRel<IntVar>
00452   operator >(const IntVar& l, int r);
00454   LinRel<IntVar>
00455   operator >(const LinExpr<IntVar>& l, int r);
00457   LinRel<IntVar>
00458   operator >(const IntVar& l, const IntVar& r);
00460   LinRel<IntVar>
00461   operator >(const IntVar& l, const LinExpr<IntVar>& r);
00463   LinRel<IntVar>
00464   operator >(const LinExpr<IntVar>& l, const IntVar& r);
00466   LinRel<IntVar>
00467   operator >(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00468 
00470   LinRel<IntVar>
00471   operator >=(int l, const IntVar& r);
00473   LinRel<IntVar>
00474   operator >=(int l, const LinExpr<IntVar>& r);
00476   LinRel<IntVar>
00477   operator >=(const IntVar& l, int r);
00479   LinRel<IntVar>
00480   operator >=(const LinExpr<IntVar>& l, int r);
00482   LinRel<IntVar>
00483   operator >=(const IntVar& l, const IntVar& r);
00485   LinRel<IntVar>
00486   operator >=(const IntVar& l, const LinExpr<IntVar>& r);
00488   LinRel<IntVar>
00489   operator >=(const LinExpr<IntVar>& l, const IntVar& r);
00491   LinRel<IntVar>
00492   operator >=(const LinExpr<IntVar>& l, const LinExpr<IntVar>& r);
00493 
00494 
00496   LinRel<BoolVar>
00497   operator ==(int l, const BoolVar& r);
00499   LinRel<BoolVar>
00500   operator ==(int l, const LinExpr<BoolVar>& r);
00502   LinRel<BoolVar>
00503   operator ==(const BoolVar& l, int r);
00505   LinRel<BoolVar>
00506   operator ==(const LinExpr<BoolVar>& l, int r);
00508   LinRel<BoolVar>
00509   operator ==(const BoolVar& l, const BoolVar& r);
00511   LinRel<BoolVar>
00512   operator ==(const BoolVar& l, const LinExpr<BoolVar>& r);
00514   LinRel<BoolVar>
00515   operator ==(const LinExpr<BoolVar>& l, const BoolVar& r);
00517   LinRel<BoolVar>
00518   operator ==(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00519 
00521   LinRel<BoolVar>
00522   operator !=(int l, const BoolVar& r);
00524   LinRel<BoolVar>
00525   operator !=(int l, const LinExpr<BoolVar>& r);
00527   LinRel<BoolVar>
00528   operator !=(const BoolVar& l, int r);
00530   LinRel<BoolVar>
00531   operator !=(const LinExpr<BoolVar>& l, int r);
00533   LinRel<BoolVar>
00534   operator !=(const BoolVar& l, const BoolVar& r);
00536   LinRel<BoolVar>
00537   operator !=(const BoolVar& l, const LinExpr<BoolVar>& r);
00539   LinRel<BoolVar>
00540   operator !=(const LinExpr<BoolVar>& l, const BoolVar& r);
00542   LinRel<BoolVar>
00543   operator !=(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00544 
00546   LinRel<BoolVar>
00547   operator <(int l, const BoolVar& r);
00549   LinRel<BoolVar>
00550   operator <(int l, const LinExpr<BoolVar>& r);
00552   LinRel<BoolVar>
00553   operator <(const BoolVar& l, int r);
00555   LinRel<BoolVar>
00556   operator <(const LinExpr<BoolVar>& l, int r);
00558   LinRel<BoolVar>
00559   operator <(const BoolVar& l, const BoolVar& r);
00561   LinRel<BoolVar>
00562   operator <(const BoolVar& l, const LinExpr<BoolVar>& r);
00564   LinRel<BoolVar>
00565   operator <(const LinExpr<BoolVar>& l, const BoolVar& r);
00567   LinRel<BoolVar>
00568   operator <(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00569 
00571   LinRel<BoolVar>
00572   operator <=(int l, const BoolVar& r);
00574   LinRel<BoolVar>
00575   operator <=(int l, const LinExpr<BoolVar>& r);
00577   LinRel<BoolVar>
00578   operator <=(const BoolVar& l, int r);
00580   LinRel<BoolVar>
00581   operator <=(const LinExpr<BoolVar>& l, int r);
00583   LinRel<BoolVar>
00584   operator <=(const BoolVar& l, const BoolVar& r);
00586   LinRel<BoolVar>
00587   operator <=(const BoolVar& l, const LinExpr<BoolVar>& r);
00589   LinRel<BoolVar>
00590   operator <=(const LinExpr<BoolVar>& l, const BoolVar& r);
00592   LinRel<BoolVar>
00593   operator <=(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00594 
00596   LinRel<BoolVar>
00597   operator >(int l, const BoolVar& r);
00599   LinRel<BoolVar>
00600   operator >(int l, const LinExpr<BoolVar>& r);
00602   LinRel<BoolVar>
00603   operator >(const BoolVar& l, int r);
00605   LinRel<BoolVar>
00606   operator >(const LinExpr<BoolVar>& l, int r);
00608   LinRel<BoolVar>
00609   operator >(const BoolVar& l, const BoolVar& r);
00611   LinRel<BoolVar>
00612   operator >(const BoolVar& l, const LinExpr<BoolVar>& r);
00614   LinRel<BoolVar>
00615   operator >(const LinExpr<BoolVar>& l, const BoolVar& r);
00617   LinRel<BoolVar>
00618   operator >(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00619 
00621   LinRel<BoolVar>
00622   operator >=(int l, const BoolVar& r);
00624   LinRel<BoolVar>
00625   operator >=(int l, const LinExpr<BoolVar>& r);
00627   LinRel<BoolVar>
00628   operator >=(const BoolVar& l, int r);
00630   LinRel<BoolVar>
00631   operator >=(const LinExpr<BoolVar>& l, int r);
00633   LinRel<BoolVar>
00634   operator >=(const BoolVar& l, const BoolVar& r);
00636   LinRel<BoolVar>
00637   operator >=(const BoolVar& l, const LinExpr<BoolVar>& r);
00639   LinRel<BoolVar>
00640   operator >=(const LinExpr<BoolVar>& l, const BoolVar& r);
00642   LinRel<BoolVar>
00643   operator >=(const LinExpr<BoolVar>& l, const LinExpr<BoolVar>& r);
00644 
00646 
00647 
00649   class BoolExpr {
00650   public:
00652     enum NodeType {
00653       NT_VAR,       
00654       NT_NOT,       
00655       NT_AND,       
00656       NT_OR,        
00657       NT_EQV,       
00658       NT_RLIN_INT,  
00659       NT_RLIN_BOOL  
00660     };
00662     class Node {
00663     public:
00665       unsigned int use;
00667       unsigned int same;
00669       NodeType t;
00671       Node *l, *r;
00673       BoolVar x;
00675       LinRel<IntVar> rl_int;
00677       LinRel<BoolVar> rl_bool;
00678 
00680       Node(void);
00682       GECODE_MINIMODEL_EXPORT
00683       bool decrement(void);
00685       static void* operator new(size_t size);
00687       static void  operator delete(void* p, size_t size);
00688     };
00690     class NNF {
00691     public:
00693       NodeType t;
00695       unsigned int p;
00697       unsigned int n;
00699       union {
00701         struct {
00703           NNF* l;
00705           NNF* r;
00706         } b;
00708         struct {
00710           bool neg;
00712           Node* x;
00713         } a;
00714       } u;
00716       GECODE_MINIMODEL_EXPORT
00717       static NNF* nnf(Region& r, Node* n, bool neg);
00719       GECODE_MINIMODEL_EXPORT
00720       void post(Home home, NodeType t,
00721                 BoolVarArgs& bp, BoolVarArgs& bn,
00722                 int& ip, int& in,
00723                 IntConLevel icl) const;
00725       GECODE_MINIMODEL_EXPORT
00726       BoolVar post(Home home, IntConLevel icl) const;
00728       GECODE_MINIMODEL_EXPORT
00729       void post(Home home, bool t, IntConLevel icl) const;
00731       static void* operator new(size_t s, Region& r);
00733       static void operator delete(void*);
00735       static void operator delete(void*, Region&);
00736     };
00737   private:
00739     Node* n;
00740   public:
00742     BoolExpr(const BoolExpr& e);
00744     GECODE_MINIMODEL_EXPORT
00745     BoolExpr(const BoolExpr& l, NodeType t, const BoolExpr& r);
00747     GECODE_MINIMODEL_EXPORT
00748     BoolExpr(const BoolVar& x);
00750     GECODE_MINIMODEL_EXPORT
00751     BoolExpr(const BoolExpr& e, NodeType t);
00753     GECODE_MINIMODEL_EXPORT
00754     BoolExpr(const LinRel<IntVar>& rl);
00756     GECODE_MINIMODEL_EXPORT
00757     BoolExpr(const LinRel<BoolVar>& rl);
00759     BoolVar post(Home home, IntConLevel icl) const;
00761     void post(Home home, bool t, IntConLevel icl) const;
00762 
00764     GECODE_MINIMODEL_EXPORT
00765     const BoolExpr& operator =(const BoolExpr& e);
00767     GECODE_MINIMODEL_EXPORT
00768     ~BoolExpr(void);
00769   };
00770 
00772   class BoolRel {
00773   private:
00775     BoolExpr e;
00777     bool t;
00778   public:
00780     BoolRel(const BoolExpr& e, bool t);
00782     void post(Home home, IntConLevel icl) const;
00783   };
00784 
00799 
00800   BoolExpr
00801   operator !(const BoolExpr&);
00803   BoolExpr
00804   operator &&(const BoolExpr&, const BoolExpr&);
00806   BoolExpr
00807   operator ||(const BoolExpr&, const BoolExpr&);
00809   BoolExpr
00810   operator ^(const BoolExpr&, const BoolExpr&);
00812   template<class Var>
00813   BoolExpr
00814   operator ~(const LinRel<Var>&);
00815 
00817   BoolExpr
00818   eqv(const BoolExpr&, const BoolExpr&);
00820   BoolExpr
00821   imp(const BoolExpr&, const BoolExpr&);
00822 
00824   BoolRel
00825   tt(const BoolExpr&);
00826 
00828   BoolRel
00829   ff(const BoolExpr&);
00831 
00838 
00839   template<class Var>
00840   IntVar post(Home home, const LinExpr<Var>& e,
00841               IntConLevel icl=ICL_DEF);
00843   IntVar post(Home home, const IntVar& x,
00844               IntConLevel icl=ICL_DEF);
00846   IntVar post(Home home, int n,
00847               IntConLevel icl=ICL_DEF);
00848 
00850   template<class Var>
00851   void post(Home home, const LinRel<Var>& r,
00852             IntConLevel icl=ICL_DEF);
00854   void post(Home home, bool r,
00855             IntConLevel icl=ICL_DEF);
00856 
00858   BoolVar post(Home home, const BoolExpr& e,
00859                IntConLevel icl=ICL_DEF);
00861   BoolVar post(Home home, const BoolVar& b,
00862                IntConLevel icl=ICL_DEF);
00864   void post(Home home, const BoolRel& r,
00865             IntConLevel icl=ICL_DEF);
00867 
00868 }
00869 
00870 #include <gecode/minimodel/lin-expr.hpp>
00871 #include <gecode/minimodel/lin-rel.hpp>
00872 #include <gecode/minimodel/bool-expr.hpp>
00873 #include <gecode/minimodel/bool-rel.hpp>
00874 
00875 namespace Gecode {
00876 
00877   namespace MiniModel {
00878     class ExpInfo;
00879   }
00880 
00886   class GECODE_MINIMODEL_EXPORT REG {
00887     friend class MiniModel::ExpInfo;
00888   private:
00890     class Exp;
00892     Exp* e;
00894     REG(Exp* e);
00895   public:
00897     REG(void);
00899     REG(int s);
00906     REG(const IntArgs& x);
00907 
00909     REG(const REG& r);
00911     const REG& operator =(const REG& r);
00912 
00914     REG operator +(const REG& r);
00916     REG& operator +=(const REG& r);
00918     REG operator |(const REG& r);
00920     REG& operator |=(const REG& r);
00922     REG operator *(void);
00924     REG operator +(void);
00926     REG operator ()(unsigned int n, unsigned int m);
00928     REG operator ()(unsigned int n);
00930     template<class Char, class Traits>
00931     std::basic_ostream<Char,Traits>&
00932     print(std::basic_ostream<Char,Traits>& os) const;
00934     operator DFA(void);
00936     ~REG(void);
00937   };
00938 
00942   template<class Char, class Traits>
00943   std::basic_ostream<Char,Traits>&
00944   operator <<(std::basic_ostream<Char,Traits>& os, const REG& r);
00945 
00946 
00958   IntVar
00959   abs(Home home, IntVar x,
00960       IntConLevel icl=ICL_DEF);
00966   IntVar
00967   min(Home home, IntVar x, IntVar y,
00968       IntConLevel icl=ICL_DEF);
00974   IntVar
00975   min(Home home, const IntVarArgs& x,
00976       IntConLevel icl=ICL_DEF);
00982   IntVar
00983   max(Home home, IntVar x, IntVar y,
00984       IntConLevel icl=ICL_DEF);
00990   IntVar
00991   max(Home home, const IntVarArgs& x,
00992       IntConLevel icl=ICL_DEF);
00998   IntVar
00999   mult(Home home, IntVar x, IntVar y,
01000        IntConLevel icl=ICL_DEF);
01005   IntVar
01006   div(Home home, IntVar x, IntVar y,
01007       IntConLevel icl=ICL_DEF);
01012   IntVar
01013   mod(Home home, IntVar x, IntVar y,
01014       IntConLevel icl=ICL_DEF);
01020   IntVar
01021   sqr(Home home, IntVar x,
01022       IntConLevel icl=ICL_DEF);
01028   IntVar
01029   sqrt(Home home, IntVar x,
01030        IntConLevel icl=ICL_DEF);
01036   IntVar
01037   plus(Home home, IntVar x, IntVar y,
01038        IntConLevel icl=ICL_DEF);
01044   IntVar
01045   minus(Home home, IntVar x, IntVar y,
01046         IntConLevel icl=ICL_DEF);
01048 }
01049 
01050 #include <gecode/minimodel/arithmetic.hpp>
01051 
01052 namespace Gecode {
01053 
01060 
01061   inline BoolVar
01062   channel(Home home, IntVar x,
01063           IntConLevel icl=ICL_DEF) {
01064     (void) icl;
01065     BoolVar b(home,0,1); channel(home,b,x);
01066     return b;
01067   }
01069   inline IntVar
01070   channel(Home home, BoolVar b,
01071           IntConLevel icl=ICL_DEF) {
01072     (void) icl;
01073     IntVar x(home,0,1); channel(home,b,x);
01074     return x;
01075   }
01077 
01078 }
01079 
01080 namespace Gecode {
01081 
01096   inline void
01097   atmost(Home home, const IntVarArgs& x, int n, int m,
01098          IntConLevel icl=ICL_DEF) {
01099     count(home,x,n,IRT_LQ,m,icl);
01100   }
01105   inline void
01106   atmost(Home home, const IntVarArgs& x, IntVar y, int m,
01107          IntConLevel icl=ICL_DEF) {
01108     count(home,x,y,IRT_LQ,m,icl);
01109   }
01117   inline void
01118   atmost(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01119          IntConLevel icl=ICL_DEF) {
01120     count(home,x,y,IRT_LQ,m,icl);
01121   }
01126   inline void
01127   atmost(Home home, const IntVarArgs& x, int n, IntVar z,
01128          IntConLevel icl=ICL_DEF) {
01129     count(home,x,n,IRT_LQ,z,icl);
01130   }
01135   inline void
01136   atmost(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01137          IntConLevel icl=ICL_DEF) {
01138     count(home,x,y,IRT_LQ,z,icl);
01139   }
01147   inline void
01148   atmost(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01149          IntConLevel icl=ICL_DEF) {
01150     count(home,x,y,IRT_LQ,z,icl);
01151   }
01152 
01157   inline void
01158   atleast(Home home, const IntVarArgs& x, int n, int m,
01159           IntConLevel icl=ICL_DEF) {
01160     count(home,x,n,IRT_GQ,m,icl);
01161   }
01166   inline void
01167   atleast(Home home, const IntVarArgs& x, IntVar y, int m,
01168           IntConLevel icl=ICL_DEF) {
01169     count(home,x,y,IRT_GQ,m,icl);
01170   }
01178   inline void
01179   atleast(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01180           IntConLevel icl=ICL_DEF) {
01181     count(home,x,y,IRT_GQ,m,icl);
01182   }
01187   inline void
01188   atleast(Home home, const IntVarArgs& x, int n, IntVar z,
01189           IntConLevel icl=ICL_DEF) {
01190     count(home,x,n,IRT_GQ,z,icl);
01191   }
01196   inline void
01197   atleast(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01198           IntConLevel icl=ICL_DEF) {
01199     count(home,x,y,IRT_GQ,z,icl);
01200   }
01208   inline void
01209   atleast(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01210           IntConLevel icl=ICL_DEF) {
01211     count(home,x,y,IRT_GQ,z,icl);
01212   }
01213 
01218   inline void
01219   exactly(Home home, const IntVarArgs& x, int n, int m,
01220           IntConLevel icl=ICL_DEF) {
01221     count(home,x,n,IRT_EQ,m,icl);
01222   }
01227   inline void
01228   exactly(Home home, const IntVarArgs& x, IntVar y, int m,
01229           IntConLevel icl=ICL_DEF) {
01230     count(home,x,y,IRT_EQ,m,icl);
01231   }
01239   inline void
01240   exactly(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01241           IntConLevel icl=ICL_DEF) {
01242     count(home,x,y,IRT_EQ,m,icl);
01243   }
01248   inline void
01249   exactly(Home home, const IntVarArgs& x, int n, IntVar z,
01250           IntConLevel icl=ICL_DEF) {
01251     count(home,x,n,IRT_EQ,z,icl);
01252   }
01257   inline void
01258   exactly(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01259           IntConLevel icl=ICL_DEF) {
01260     count(home,x,y,IRT_EQ,z,icl);
01261   }
01269   inline void
01270   exactly(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01271           IntConLevel icl=ICL_DEF) {
01272     count(home,x,y,IRT_EQ,z,icl);
01273   }
01279   inline void
01280   lex(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
01281       IntConLevel icl=ICL_DEF) {
01282     rel(home,x,r,y,icl);
01283   }
01289   inline void
01290   lex(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
01291       IntConLevel icl=ICL_DEF) {
01292     rel(home,x,r,y,icl);
01293   }
01294 
01296 
01297 }
01298 
01299 namespace Gecode {
01300 
01311   template<class A>
01312   class Matrix {
01313   public:
01315     typedef typename ArrayTraits<A>::value_type value_type;
01317     typedef typename ArrayTraits<A>::args_type args_type;
01318 
01326     class Slice {
01327       args_type _r;     
01328       unsigned int _fc, 
01329         _tc,            
01330         _fr,            
01331         _tr;            
01332     public:
01334       Slice(Matrix<A>& a, int fc, int tc, int fr, int tr);
01338       Slice& reverse(void);
01340       operator typename Matrix<A>::args_type(void);
01342       operator Matrix<typename Matrix<A>::args_type>(void);
01343     };
01344 
01345   private:
01347     typedef typename ArrayTraits<A>::storage_type storage_type;
01348     storage_type _a; 
01349     int _w; 
01350     int _h; 
01351 
01352   public:
01365     Matrix(A a, int w, int h);
01366 
01379     Matrix(A a, int n);
01380 
01382     int width(void) const;
01384     int height(void) const;
01386     args_type const get_array(void) const;
01387 
01393     value_type& operator ()(int c, int r);
01394 
01404     Slice slice(int fc, int tc, int fr, int tr);
01405 
01407     Slice row(int r);
01408 
01410     Slice col(int c);
01411   };
01412 
01419   void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,  
01420                IntVar z, IntConLevel icl=ICL_DEF);
01427   void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,  
01428                BoolVar z, IntConLevel icl=ICL_DEF);
01435   void element(Home home, const Matrix<IntVarArgs>& m, IntVar x, IntVar y,  
01436                IntVar z, IntConLevel icl=ICL_DEF);
01443   void element(Home home, const Matrix<BoolVarArgs>& m, IntVar x, IntVar y,  
01444                BoolVar z, IntConLevel icl=ICL_DEF);
01445 #ifdef GECODE_HAS_SET_VARS
01446 
01452   void element(Home home, const Matrix<IntSetArgs>& m, IntVar x, IntVar y,  
01453                SetVar z);
01460   void element(Home home, const Matrix<SetVarArgs>& m, IntVar x, IntVar y,  
01461                SetVar z);
01462 #endif
01463 
01464 }
01465 
01466 #include <gecode/minimodel/matrix.hpp>
01467 
01468 namespace Gecode {
01469 
01479   namespace MiniModel {
01480 
01482     template<IntRelType irt>
01483     class OptimizeSpace : public Space {
01484     public:
01486       OptimizeSpace(void);
01488       OptimizeSpace(bool share, OptimizeSpace& s);
01490       virtual void constrain(const Space& best);
01492       virtual IntVar cost(void) const = 0;
01493     };
01494 
01495   }
01496 
01498   typedef MiniModel::OptimizeSpace<IRT_LE> MinimizeSpace;
01499 
01501   typedef MiniModel::OptimizeSpace<IRT_GR> MaximizeSpace;
01503 
01504 }
01505 
01506 #include <gecode/minimodel/optimize.hpp>
01507 
01508 #endif
01509 
01510 // IFDEF: GECODE_HAS_INT_VARS
01511 // STATISTICS: minimodel-any
01512