Generated on Fri Mar 20 15:56:18 2015 for Gecode by doxygen 1.6.3

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  *     Vincent Barichard <Vincent.Barichard@univ-angers.fr>
00008  *
00009  *  Copyright:
00010  *     Christian Schulte, 2004
00011  *     Guido Tack, 2004
00012  *     Mikael Lagerkvist, 2005
00013  *     Vincent Barichard, 2012
00014  *
00015  *  Last modified:
00016  *     $Date: 2015-03-20 15:37:34 +0100 (Fri, 20 Mar 2015) $ by $Author: schulte $
00017  *     $Revision: 14471 $
00018  *
00019  *  This file is part of Gecode, the generic constraint
00020  *  development environment:
00021  *     http://www.gecode.org
00022  *
00023  *  Permission is hereby granted, free of charge, to any person obtaining
00024  *  a copy of this software and associated documentation files (the
00025  *  "Software"), to deal in the Software without restriction, including
00026  *  without limitation the rights to use, copy, modify, merge, publish,
00027  *  distribute, sublicense, and/or sell copies of the Software, and to
00028  *  permit persons to whom the Software is furnished to do so, subject to
00029  *  the following conditions:
00030  *
00031  *  The above copyright notice and this permission notice shall be
00032  *  included in all copies or substantial portions of the Software.
00033  *
00034  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00035  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00036  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00037  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00038  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00039  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00040  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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 <gecode/minimodel/exception.hpp>
00057 
00058 #include <iostream>
00059 
00060 /*
00061  * Support for DLLs under Windows
00062  *
00063  */
00064 
00065 #if !defined(GECODE_STATIC_LIBS) && \
00066     (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00067 
00068 #ifdef GECODE_BUILD_MINIMODEL
00069 #define GECODE_MINIMODEL_EXPORT __declspec( dllexport )
00070 #else
00071 #define GECODE_MINIMODEL_EXPORT __declspec( dllimport )
00072 #endif
00073 
00074 #else
00075 
00076 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00077 
00078 #define GECODE_MINIMODEL_EXPORT __attribute__ ((visibility("default")))
00079 
00080 #else
00081 
00082 #define GECODE_MINIMODEL_EXPORT
00083 
00084 #endif
00085 #endif
00086 
00087 // Configure auto-linking
00088 #ifndef GECODE_BUILD_MINIMODEL
00089 #define GECODE_LIBRARY_NAME "MiniModel"
00090 #include <gecode/support/auto-link.hpp>
00091 #endif
00092 
00093 namespace Gecode {
00094 
00096   namespace MiniModel {}
00097 
00098   class LinIntRel;
00099 #ifdef GECODE_HAS_SET_VARS
00100   class SetExpr;
00101 #endif
00102 #ifdef GECODE_HAS_FLOAT_VARS
00103   class LinFloatExpr;
00104 #endif
00105 
00107   class NonLinIntExpr {
00108   public:
00110     virtual IntVar post(Home home, IntVar* ret, IntConLevel icl) const = 0;
00112     virtual void post(Home home, IntRelType irt, int c,
00113                       IntConLevel icl) const = 0;
00115     virtual void post(Home home, IntRelType irt, int c,
00116                       BoolVar b, IntConLevel icl) const = 0;
00118     virtual ~NonLinIntExpr(void) {}
00120     static IntVar result(Home home, IntVar* x) {
00121       if (x==NULL)
00122         return IntVar(home,Int::Limits::min,Int::Limits::max);
00123       return *x;
00124     }
00126     static IntVar result(Home home, IntVar* x, IntVar y) {
00127       if (x!=NULL)
00128         rel(home,*x,IRT_EQ,y);
00129       return y;
00130     }
00132     void* operator new(size_t size) { return heap.ralloc(size); }
00134     void operator delete(void* p, size_t) { heap.rfree(p); }
00135   };
00136 
00138   class LinIntExpr {
00139     friend class LinIntRel;
00140 #ifdef GECODE_HAS_SET_VARS
00141     friend class SetExpr;
00142 #endif
00143 #ifdef GECODE_HAS_FLOAT_VARS
00144     friend class LinFloatExpr;
00145 #endif
00146   public:
00148     enum NodeType {
00149       NT_CONST,    
00150       NT_VAR_INT,  
00151       NT_VAR_BOOL, 
00152       NT_NONLIN,   
00153       NT_SUM_INT,  
00154       NT_SUM_BOOL, 
00155       NT_ADD,      
00156       NT_SUB,      
00157       NT_MUL       
00158     };
00159   private:
00161     class Node;
00162     Node* n;
00163   public:
00165     GECODE_MINIMODEL_EXPORT
00166     LinIntExpr(void);
00168     GECODE_MINIMODEL_EXPORT
00169     LinIntExpr(int c);
00171     GECODE_MINIMODEL_EXPORT
00172     LinIntExpr(const IntVar& x, int a=1);
00174     GECODE_MINIMODEL_EXPORT
00175     LinIntExpr(const BoolVar& x, int a=1);
00177     GECODE_MINIMODEL_EXPORT
00178     explicit LinIntExpr(const IntVarArgs& x);
00180     GECODE_MINIMODEL_EXPORT
00181     LinIntExpr(const IntArgs& a, const IntVarArgs& x);
00183     GECODE_MINIMODEL_EXPORT
00184     explicit LinIntExpr(const BoolVarArgs& x);
00186     GECODE_MINIMODEL_EXPORT
00187     LinIntExpr(const IntArgs& a, const BoolVarArgs& x);
00189     GECODE_MINIMODEL_EXPORT
00190     LinIntExpr(const LinIntExpr& e);
00192     GECODE_MINIMODEL_EXPORT
00193     LinIntExpr(const LinIntExpr& e0, NodeType t, const LinIntExpr& e1);
00195     GECODE_MINIMODEL_EXPORT
00196     LinIntExpr(const LinIntExpr& e0, NodeType t, int c);
00198     GECODE_MINIMODEL_EXPORT
00199     LinIntExpr(int a, const LinIntExpr& e);
00201     GECODE_MINIMODEL_EXPORT
00202     explicit LinIntExpr(NonLinIntExpr* e);
00204     GECODE_MINIMODEL_EXPORT
00205     const LinIntExpr& operator =(const LinIntExpr& e);
00207     GECODE_MINIMODEL_EXPORT
00208     void post(Home home, IntRelType irt, IntConLevel icl) const;
00210     GECODE_MINIMODEL_EXPORT
00211     void post(Home home, IntRelType irt, const BoolVar& b,
00212               IntConLevel icl) const;
00214     GECODE_MINIMODEL_EXPORT
00215     IntVar post(Home home, IntConLevel icl) const;
00217     GECODE_MINIMODEL_EXPORT
00218     NonLinIntExpr* nle(void) const;
00220     GECODE_MINIMODEL_EXPORT
00221     ~LinIntExpr(void);
00222   };
00223 
00224   class BoolExpr;
00225 
00227   class LinIntRel {
00228     friend class BoolExpr;
00229   private:
00231     LinIntExpr e;
00233     IntRelType irt;
00235     static IntRelType neg(IntRelType irt);
00237     LinIntRel(void);
00238   public:
00240     LinIntRel(const LinIntExpr& l, IntRelType irt, const LinIntExpr& r);
00242     LinIntRel(const LinIntExpr& l, IntRelType irt, int r);
00244     LinIntRel(int l, IntRelType irt, const LinIntExpr& r);
00246     void post(Home home, bool t,  IntConLevel icl) const;
00248     void post(Home home, const BoolVar& b, bool t, IntConLevel icl) const;
00249   };
00250 
00269 
00270   GECODE_MINIMODEL_EXPORT LinIntExpr
00271   operator +(int, const IntVar&);
00273   GECODE_MINIMODEL_EXPORT LinIntExpr
00274   operator +(int, const BoolVar&);
00276   GECODE_MINIMODEL_EXPORT LinIntExpr
00277   operator +(int, const LinIntExpr&);
00279   GECODE_MINIMODEL_EXPORT LinIntExpr
00280   operator +(const IntVar&, int);
00282   GECODE_MINIMODEL_EXPORT LinIntExpr
00283   operator +(const BoolVar&, int);
00285   GECODE_MINIMODEL_EXPORT LinIntExpr
00286   operator +(const LinIntExpr&, int);
00288   GECODE_MINIMODEL_EXPORT LinIntExpr
00289   operator +(const IntVar&, const IntVar&);
00291   GECODE_MINIMODEL_EXPORT LinIntExpr
00292   operator +(const IntVar&, const BoolVar&);
00294   GECODE_MINIMODEL_EXPORT LinIntExpr
00295   operator +(const BoolVar&, const IntVar&);
00297   GECODE_MINIMODEL_EXPORT LinIntExpr
00298   operator +(const BoolVar&, const BoolVar&);
00300   GECODE_MINIMODEL_EXPORT LinIntExpr
00301   operator +(const IntVar&, const LinIntExpr&);
00303   GECODE_MINIMODEL_EXPORT LinIntExpr
00304   operator +(const BoolVar&, const LinIntExpr&);
00306   GECODE_MINIMODEL_EXPORT LinIntExpr
00307   operator +(const LinIntExpr&, const IntVar&);
00309   GECODE_MINIMODEL_EXPORT LinIntExpr
00310   operator +(const LinIntExpr&, const BoolVar&);
00312   GECODE_MINIMODEL_EXPORT LinIntExpr
00313   operator +(const LinIntExpr&, const LinIntExpr&);
00314 
00316   GECODE_MINIMODEL_EXPORT LinIntExpr
00317   operator -(int, const IntVar&);
00319   GECODE_MINIMODEL_EXPORT LinIntExpr
00320   operator -(int, const BoolVar&);
00322   GECODE_MINIMODEL_EXPORT LinIntExpr
00323   operator -(int, const LinIntExpr&);
00325   GECODE_MINIMODEL_EXPORT LinIntExpr
00326   operator -(const IntVar&, int);
00328   GECODE_MINIMODEL_EXPORT LinIntExpr
00329   operator -(const BoolVar&, int);
00331   GECODE_MINIMODEL_EXPORT LinIntExpr
00332   operator -(const LinIntExpr&, int);
00334   GECODE_MINIMODEL_EXPORT LinIntExpr
00335   operator -(const IntVar&, const IntVar&);
00337   GECODE_MINIMODEL_EXPORT LinIntExpr
00338   operator -(const IntVar&, const BoolVar&);
00340   GECODE_MINIMODEL_EXPORT LinIntExpr
00341   operator -(const BoolVar&, const IntVar&);
00343   GECODE_MINIMODEL_EXPORT LinIntExpr
00344   operator -(const BoolVar&, const BoolVar&);
00346   GECODE_MINIMODEL_EXPORT LinIntExpr
00347   operator -(const IntVar&, const LinIntExpr&);
00349   GECODE_MINIMODEL_EXPORT LinIntExpr
00350   operator -(const BoolVar&, const LinIntExpr&);
00352   GECODE_MINIMODEL_EXPORT LinIntExpr
00353   operator -(const LinIntExpr&, const IntVar&);
00355   GECODE_MINIMODEL_EXPORT LinIntExpr
00356   operator -(const LinIntExpr&, const BoolVar&);
00358   GECODE_MINIMODEL_EXPORT LinIntExpr
00359   operator -(const LinIntExpr&, const LinIntExpr&);
00360 
00362   GECODE_MINIMODEL_EXPORT LinIntExpr
00363   operator -(const IntVar&);
00365   GECODE_MINIMODEL_EXPORT LinIntExpr
00366   operator -(const BoolVar&);
00368   GECODE_MINIMODEL_EXPORT LinIntExpr
00369   operator -(const LinIntExpr&);
00370 
00372   GECODE_MINIMODEL_EXPORT LinIntExpr
00373   operator *(int, const IntVar&);
00375   GECODE_MINIMODEL_EXPORT LinIntExpr
00376   operator *(int, const BoolVar&);
00378   GECODE_MINIMODEL_EXPORT LinIntExpr
00379   operator *(const IntVar&, int);
00381   GECODE_MINIMODEL_EXPORT LinIntExpr
00382   operator *(const BoolVar&, int);
00384   GECODE_MINIMODEL_EXPORT LinIntExpr
00385   operator *(const LinIntExpr&, int);
00387   GECODE_MINIMODEL_EXPORT LinIntExpr
00388   operator *(int, const LinIntExpr&);
00389 
00391   GECODE_MINIMODEL_EXPORT LinIntExpr
00392   sum(const IntVarArgs& x);
00394   GECODE_MINIMODEL_EXPORT LinIntExpr
00395   sum(const IntArgs& a, const IntVarArgs& x);
00397   GECODE_MINIMODEL_EXPORT LinIntExpr
00398   sum(const BoolVarArgs& x);
00400   GECODE_MINIMODEL_EXPORT LinIntExpr
00401   sum(const IntArgs& a, const BoolVarArgs& x);
00403   GECODE_MINIMODEL_EXPORT LinIntExpr
00404   sum(const IntArgs& args);
00405 
00407   GECODE_MINIMODEL_EXPORT LinIntRel
00408   operator ==(int l, const IntVar& r);
00410   GECODE_MINIMODEL_EXPORT LinIntRel
00411   operator ==(int l, const BoolVar& r);
00413   GECODE_MINIMODEL_EXPORT LinIntRel
00414   operator ==(int l, const LinIntExpr& r);
00416   GECODE_MINIMODEL_EXPORT LinIntRel
00417   operator ==(const IntVar& l, int r);
00419   GECODE_MINIMODEL_EXPORT LinIntRel
00420   operator ==(const BoolVar& l, int r);
00422   GECODE_MINIMODEL_EXPORT LinIntRel
00423   operator ==(const LinIntExpr& l, int r);
00425   GECODE_MINIMODEL_EXPORT LinIntRel
00426   operator ==(const IntVar& l, const IntVar& r);
00428   GECODE_MINIMODEL_EXPORT LinIntRel
00429   operator ==(const IntVar& l, const BoolVar& r);
00431   GECODE_MINIMODEL_EXPORT LinIntRel
00432   operator ==(const BoolVar& l, const IntVar& r);
00434   GECODE_MINIMODEL_EXPORT LinIntRel
00435   operator ==(const BoolVar& l, const BoolVar& r);
00437   GECODE_MINIMODEL_EXPORT LinIntRel
00438   operator ==(const IntVar& l, const LinIntExpr& r);
00440   GECODE_MINIMODEL_EXPORT LinIntRel
00441   operator ==(const BoolVar& l, const LinIntExpr& r);
00443   GECODE_MINIMODEL_EXPORT LinIntRel
00444   operator ==(const LinIntExpr& l, const IntVar& r);
00446   GECODE_MINIMODEL_EXPORT LinIntRel
00447   operator ==(const LinIntExpr& l, const BoolVar& r);
00449   GECODE_MINIMODEL_EXPORT LinIntRel
00450   operator ==(const LinIntExpr& l, const LinIntExpr& r);
00451 
00453   GECODE_MINIMODEL_EXPORT LinIntRel
00454   operator !=(int l, const IntVar& r);
00456   GECODE_MINIMODEL_EXPORT LinIntRel
00457   operator !=(int l, const BoolVar& r);
00459   GECODE_MINIMODEL_EXPORT LinIntRel
00460   operator !=(int l, const LinIntExpr& r);
00462   GECODE_MINIMODEL_EXPORT LinIntRel
00463   operator !=(const IntVar& l, int r);
00465   GECODE_MINIMODEL_EXPORT LinIntRel
00466   operator !=(const BoolVar& l, int r);
00468   GECODE_MINIMODEL_EXPORT LinIntRel
00469   operator !=(const LinIntExpr& l, int r);
00471   GECODE_MINIMODEL_EXPORT LinIntRel
00472   operator !=(const IntVar& l, const IntVar& r);
00474   GECODE_MINIMODEL_EXPORT LinIntRel
00475   operator !=(const IntVar& l, const BoolVar& r);
00477   GECODE_MINIMODEL_EXPORT LinIntRel
00478   operator !=(const BoolVar& l, const IntVar& r);
00480   GECODE_MINIMODEL_EXPORT LinIntRel
00481   operator !=(const BoolVar& l, const BoolVar& r);
00483   GECODE_MINIMODEL_EXPORT LinIntRel
00484   operator !=(const IntVar& l, const LinIntExpr& r);
00486   GECODE_MINIMODEL_EXPORT LinIntRel
00487   operator !=(const BoolVar& l, const LinIntExpr& r);
00489   GECODE_MINIMODEL_EXPORT LinIntRel
00490   operator !=(const LinIntExpr& l, const IntVar& r);
00492   GECODE_MINIMODEL_EXPORT LinIntRel
00493   operator !=(const LinIntExpr& l, const BoolVar& r);
00495   GECODE_MINIMODEL_EXPORT LinIntRel
00496   operator !=(const LinIntExpr& l, const LinIntExpr& r);
00497 
00499   GECODE_MINIMODEL_EXPORT LinIntRel
00500   operator <(int l, const IntVar& r);
00502   GECODE_MINIMODEL_EXPORT LinIntRel
00503   operator <(int l, const BoolVar& r);
00505   GECODE_MINIMODEL_EXPORT LinIntRel
00506   operator <(int l, const LinIntExpr& r);
00508   GECODE_MINIMODEL_EXPORT LinIntRel
00509   operator <(const IntVar& l, int r);
00511   GECODE_MINIMODEL_EXPORT LinIntRel
00512   operator <(const BoolVar& l, int r);
00514   GECODE_MINIMODEL_EXPORT LinIntRel
00515   operator <(const LinIntExpr& l, int r);
00517   GECODE_MINIMODEL_EXPORT LinIntRel
00518   operator <(const IntVar& l, const IntVar& r);
00520   GECODE_MINIMODEL_EXPORT LinIntRel
00521   operator <(const IntVar& l, const BoolVar& r);
00523   GECODE_MINIMODEL_EXPORT LinIntRel
00524   operator <(const BoolVar& l, const IntVar& r);
00526   GECODE_MINIMODEL_EXPORT LinIntRel
00527   operator <(const BoolVar& l, const BoolVar& r);
00529   GECODE_MINIMODEL_EXPORT LinIntRel
00530   operator <(const IntVar& l, const LinIntExpr& r);
00532   GECODE_MINIMODEL_EXPORT LinIntRel
00533   operator <(const BoolVar& l, const LinIntExpr& r);
00535   GECODE_MINIMODEL_EXPORT LinIntRel
00536   operator <(const LinIntExpr& l, const IntVar& r);
00538   GECODE_MINIMODEL_EXPORT LinIntRel
00539   operator <(const LinIntExpr& l, const BoolVar& r);
00541   GECODE_MINIMODEL_EXPORT LinIntRel
00542   operator <(const LinIntExpr& l, const LinIntExpr& r);
00543 
00545   GECODE_MINIMODEL_EXPORT LinIntRel
00546   operator <=(int l, const IntVar& r);
00548   GECODE_MINIMODEL_EXPORT LinIntRel
00549   operator <=(int l, const BoolVar& r);
00551   GECODE_MINIMODEL_EXPORT LinIntRel
00552   operator <=(int l, const LinIntExpr& r);
00554   GECODE_MINIMODEL_EXPORT LinIntRel
00555   operator <=(const IntVar& l, int r);
00557   GECODE_MINIMODEL_EXPORT LinIntRel
00558   operator <=(const BoolVar& l, int r);
00560   GECODE_MINIMODEL_EXPORT LinIntRel
00561   operator <=(const LinIntExpr& l, int r);
00563   GECODE_MINIMODEL_EXPORT LinIntRel
00564   operator <=(const IntVar& l, const IntVar& r);
00566   GECODE_MINIMODEL_EXPORT LinIntRel
00567   operator <=(const IntVar& l, const BoolVar& r);
00569   GECODE_MINIMODEL_EXPORT LinIntRel
00570   operator <=(const BoolVar& l, const IntVar& r);
00572   GECODE_MINIMODEL_EXPORT LinIntRel
00573   operator <=(const BoolVar& l, const BoolVar& r);
00575   GECODE_MINIMODEL_EXPORT LinIntRel
00576   operator <=(const IntVar& l, const LinIntExpr& r);
00578   GECODE_MINIMODEL_EXPORT LinIntRel
00579   operator <=(const BoolVar& l, const LinIntExpr& r);
00581   GECODE_MINIMODEL_EXPORT LinIntRel
00582   operator <=(const LinIntExpr& l, const IntVar& r);
00584   GECODE_MINIMODEL_EXPORT LinIntRel
00585   operator <=(const LinIntExpr& l, const BoolVar& r);
00587   GECODE_MINIMODEL_EXPORT LinIntRel
00588   operator <=(const LinIntExpr& l, const LinIntExpr& r);
00589 
00591   GECODE_MINIMODEL_EXPORT LinIntRel
00592   operator >(int l, const IntVar& r);
00594   GECODE_MINIMODEL_EXPORT LinIntRel
00595   operator >(int l, const BoolVar& r);
00597   GECODE_MINIMODEL_EXPORT LinIntRel
00598   operator >(int l, const LinIntExpr& r);
00600   GECODE_MINIMODEL_EXPORT LinIntRel
00601   operator >(const IntVar& l, int r);
00603   GECODE_MINIMODEL_EXPORT LinIntRel
00604   operator >(const BoolVar& l, int r);
00606   GECODE_MINIMODEL_EXPORT LinIntRel
00607   operator >(const LinIntExpr& l, int r);
00609   GECODE_MINIMODEL_EXPORT LinIntRel
00610   operator >(const IntVar& l, const IntVar& r);
00612   GECODE_MINIMODEL_EXPORT LinIntRel
00613   operator >(const IntVar& l, const BoolVar& r);
00615   GECODE_MINIMODEL_EXPORT LinIntRel
00616   operator >(const BoolVar& l, const IntVar& r);
00618   GECODE_MINIMODEL_EXPORT LinIntRel
00619   operator >(const BoolVar& l, const BoolVar& r);
00621   GECODE_MINIMODEL_EXPORT LinIntRel
00622   operator >(const IntVar& l, const LinIntExpr& r);
00624   GECODE_MINIMODEL_EXPORT LinIntRel
00625   operator >(const BoolVar& l, const LinIntExpr& r);
00627   GECODE_MINIMODEL_EXPORT LinIntRel
00628   operator >(const LinIntExpr& l, const IntVar& r);
00630   GECODE_MINIMODEL_EXPORT LinIntRel
00631   operator >(const LinIntExpr& l, const BoolVar& r);
00633   GECODE_MINIMODEL_EXPORT LinIntRel
00634   operator >(const LinIntExpr& l, const LinIntExpr& r);
00635 
00637   GECODE_MINIMODEL_EXPORT LinIntRel
00638   operator >=(int l, const IntVar& r);
00640   GECODE_MINIMODEL_EXPORT LinIntRel
00641   operator >=(int l, const BoolVar& r);
00643   GECODE_MINIMODEL_EXPORT LinIntRel
00644   operator >=(int l, const LinIntExpr& r);
00646   GECODE_MINIMODEL_EXPORT LinIntRel
00647   operator >=(const IntVar& l, int r);
00649   GECODE_MINIMODEL_EXPORT LinIntRel
00650   operator >=(const BoolVar& l, int r);
00652   GECODE_MINIMODEL_EXPORT LinIntRel
00653   operator >=(const LinIntExpr& l, int r);
00655   GECODE_MINIMODEL_EXPORT LinIntRel
00656   operator >=(const IntVar& l, const IntVar& r);
00658   GECODE_MINIMODEL_EXPORT LinIntRel
00659   operator >=(const IntVar& l, const BoolVar& r);
00661   GECODE_MINIMODEL_EXPORT LinIntRel
00662   operator >=(const BoolVar& l, const IntVar& r);
00664   GECODE_MINIMODEL_EXPORT LinIntRel
00665   operator >=(const BoolVar& l, const BoolVar& r);
00667   GECODE_MINIMODEL_EXPORT LinIntRel
00668   operator >=(const IntVar& l, const LinIntExpr& r);
00670   GECODE_MINIMODEL_EXPORT LinIntRel
00671   operator >=(const BoolVar& l, const LinIntExpr& r);
00673   GECODE_MINIMODEL_EXPORT LinIntRel
00674   operator >=(const LinIntExpr& l, const IntVar& r);
00676   GECODE_MINIMODEL_EXPORT LinIntRel
00677   operator >=(const LinIntExpr& l, const BoolVar& r);
00679   GECODE_MINIMODEL_EXPORT LinIntRel
00680   operator >=(const LinIntExpr& l, const LinIntExpr& r);
00682 
00683 #ifdef GECODE_HAS_FLOAT_VARS
00684 
00685   class NonLinFloatExpr {
00686   public:
00688     virtual FloatVar post(Home home, FloatVar* ret) const = 0;
00690     virtual void post(Home home, FloatRelType frt, FloatVal c) const = 0;
00692     virtual void post(Home home, FloatRelType frt, FloatVal c,
00693                       BoolVar b) const = 0;
00695     virtual ~NonLinFloatExpr(void) {}
00697     static FloatVar result(Home home, FloatVar* x) {
00698       if (x == NULL)
00699         return FloatVar(home,Float::Limits::min,Float::Limits::max);
00700       return *x;
00701     }
00703     static FloatVar result(Home home, FloatVar* x, FloatVar y) {
00704       if (x!=NULL)
00705         rel(home,*x,FRT_EQ,y);
00706       return y;
00707     }
00709     void* operator new(size_t size) { return heap.ralloc(size); }
00711     void operator delete(void* p, size_t) { heap.rfree(p); }
00712   };
00713 
00715   class LinFloatExpr {
00716     friend class LinFloatRel;
00717   public:
00719     enum NodeType {
00720       NT_CONST,    
00721       NT_VAR,      
00722       NT_NONLIN,   
00723       NT_SUM,      
00724       NT_ADD,      
00725       NT_SUB,      
00726       NT_MUL       
00727     };
00728   private:
00730     class Node;
00731     Node* n;
00732   public:
00734     GECODE_MINIMODEL_EXPORT
00735     LinFloatExpr(void);
00737     GECODE_MINIMODEL_EXPORT
00738     LinFloatExpr(const FloatVal& c);
00740     GECODE_MINIMODEL_EXPORT
00741     LinFloatExpr(const FloatVar& x);
00743     GECODE_MINIMODEL_EXPORT
00744     LinFloatExpr(const FloatVar& x, FloatVal a);
00746     GECODE_MINIMODEL_EXPORT
00747     explicit LinFloatExpr(const FloatVarArgs& x);
00749     GECODE_MINIMODEL_EXPORT
00750     LinFloatExpr(const FloatValArgs& a, const FloatVarArgs& x);
00752     GECODE_MINIMODEL_EXPORT
00753     LinFloatExpr(const LinFloatExpr& e);
00755     GECODE_MINIMODEL_EXPORT
00756     LinFloatExpr(const LinFloatExpr& e0, NodeType t, const LinFloatExpr& e1);
00758     GECODE_MINIMODEL_EXPORT
00759     LinFloatExpr(const LinFloatExpr& e0, NodeType t, const FloatVal& c);
00761     GECODE_MINIMODEL_EXPORT
00762     LinFloatExpr(FloatVal a, const LinFloatExpr& e);
00764     GECODE_MINIMODEL_EXPORT
00765     explicit LinFloatExpr(NonLinFloatExpr* e);
00767     GECODE_MINIMODEL_EXPORT
00768     const LinFloatExpr& operator =(const LinFloatExpr& e);
00770     GECODE_MINIMODEL_EXPORT
00771     void post(Home home, FloatRelType frt) const;
00773     GECODE_MINIMODEL_EXPORT
00774     void post(Home home, FloatRelType frt, const BoolVar& b) const;
00776     GECODE_MINIMODEL_EXPORT
00777     FloatVar post(Home home) const;
00779     GECODE_MINIMODEL_EXPORT
00780     NonLinFloatExpr* nlfe(void) const;
00782     GECODE_MINIMODEL_EXPORT
00783     ~LinFloatExpr(void);
00784   };
00785 
00786   class BoolExpr;
00787 
00789   class LinFloatRel {
00790     friend class BoolExpr;
00791   private:
00793     LinFloatExpr e;
00795     FloatRelType frt;
00797     static FloatRelType neg(FloatRelType frt);
00799     LinFloatRel(void);
00800   public:
00802     LinFloatRel(const LinFloatExpr& l, FloatRelType frt, const LinFloatExpr& r);
00804     LinFloatRel(const LinFloatExpr& l, FloatRelType frt, FloatVal r);
00806     LinFloatRel(FloatVal l, FloatRelType frt, const LinFloatExpr& r);
00808     void post(Home home, bool t) const;
00810     void post(Home home, const BoolVar& b, bool t) const;
00811   };
00812 
00826 
00827   GECODE_MINIMODEL_EXPORT LinFloatExpr
00828   operator +(const FloatVal&, const FloatVar&);
00830   GECODE_MINIMODEL_EXPORT LinFloatExpr
00831   operator +(const FloatVal&, const LinFloatExpr&);
00833   GECODE_MINIMODEL_EXPORT LinFloatExpr
00834   operator +(const FloatVar&, const FloatVal&);
00836   GECODE_MINIMODEL_EXPORT LinFloatExpr
00837   operator +(const LinFloatExpr&, const FloatVal&);
00839   GECODE_MINIMODEL_EXPORT LinFloatExpr
00840   operator +(const FloatVar&, const FloatVar&);
00842   GECODE_MINIMODEL_EXPORT LinFloatExpr
00843   operator +(const FloatVar&, const LinFloatExpr&);
00845   GECODE_MINIMODEL_EXPORT LinFloatExpr
00846   operator +(const LinFloatExpr&, const FloatVar&);
00848   GECODE_MINIMODEL_EXPORT LinFloatExpr
00849   operator +(const LinFloatExpr&, const LinFloatExpr&);
00850 
00852   GECODE_MINIMODEL_EXPORT LinFloatExpr
00853   operator -(const FloatVal&, const FloatVar&);
00855   GECODE_MINIMODEL_EXPORT LinFloatExpr
00856   operator -(const FloatVal&, const LinFloatExpr&);
00858   GECODE_MINIMODEL_EXPORT LinFloatExpr
00859   operator -(const FloatVar&, const FloatVal&);
00861   GECODE_MINIMODEL_EXPORT LinFloatExpr
00862   operator -(const LinFloatExpr&, const FloatVal&);
00864   GECODE_MINIMODEL_EXPORT LinFloatExpr
00865   operator -(const FloatVar&, const FloatVar&);
00867   GECODE_MINIMODEL_EXPORT LinFloatExpr
00868   operator -(const FloatVar&, const LinFloatExpr&);
00870   GECODE_MINIMODEL_EXPORT LinFloatExpr
00871   operator -(const LinFloatExpr&, const FloatVar&);
00873   GECODE_MINIMODEL_EXPORT LinFloatExpr
00874   operator -(const LinFloatExpr&, const LinFloatExpr&);
00875 
00877   GECODE_MINIMODEL_EXPORT LinFloatExpr
00878   operator -(const FloatVar&);
00880   GECODE_MINIMODEL_EXPORT LinFloatExpr
00881   operator -(const LinFloatExpr&);
00882 
00884   GECODE_MINIMODEL_EXPORT LinFloatExpr
00885   operator *(const FloatVal&, const FloatVar&);
00887   GECODE_MINIMODEL_EXPORT LinFloatExpr
00888   operator *(const FloatVar&, const FloatVal&);
00890   GECODE_MINIMODEL_EXPORT LinFloatExpr
00891   operator *(const LinFloatExpr&, const FloatVal&);
00893   GECODE_MINIMODEL_EXPORT LinFloatExpr
00894   operator *(const FloatVal&, const LinFloatExpr&);
00895 
00897   GECODE_MINIMODEL_EXPORT LinFloatExpr
00898   sum(const FloatVarArgs& x);
00900   GECODE_MINIMODEL_EXPORT LinFloatExpr
00901   sum(const FloatValArgs& a, const FloatVarArgs& x);
00902 
00904   GECODE_MINIMODEL_EXPORT LinFloatRel
00905   operator ==(const FloatVal& l, const FloatVar& r);
00907   GECODE_MINIMODEL_EXPORT LinFloatRel
00908   operator ==(const FloatVal& l, const LinFloatExpr& r);
00910   GECODE_MINIMODEL_EXPORT LinFloatRel
00911   operator ==(const FloatVar& l, const FloatVal& r);
00913   GECODE_MINIMODEL_EXPORT LinFloatRel
00914   operator ==(const LinFloatExpr& l, const FloatVal& r);
00916   GECODE_MINIMODEL_EXPORT LinFloatRel
00917   operator ==(const FloatVar& l, const FloatVar& r);
00919   GECODE_MINIMODEL_EXPORT LinFloatRel
00920   operator ==(const FloatVar& l, const BoolVar& r);
00922   GECODE_MINIMODEL_EXPORT LinFloatRel
00923   operator ==(const FloatVar& l, const LinFloatExpr& r);
00925   GECODE_MINIMODEL_EXPORT LinFloatRel
00926   operator ==(const LinFloatExpr& l, const FloatVar& r);
00928   GECODE_MINIMODEL_EXPORT LinFloatRel
00929   operator ==(const LinFloatExpr& l, const BoolVar& r);
00931   GECODE_MINIMODEL_EXPORT LinFloatRel
00932   operator ==(const LinFloatExpr& l, const LinFloatExpr& r);
00933 
00935   GECODE_MINIMODEL_EXPORT LinFloatRel
00936   operator !=(const FloatVal& l, const FloatVar& r);
00938   GECODE_MINIMODEL_EXPORT LinFloatRel
00939   operator !=(const FloatVal& l, const LinFloatExpr& r);
00941   GECODE_MINIMODEL_EXPORT LinFloatRel
00942   operator !=(const FloatVar& l, const FloatVal& r);
00944   GECODE_MINIMODEL_EXPORT LinFloatRel
00945   operator !=(const LinFloatExpr& l, const FloatVal& r);
00947   GECODE_MINIMODEL_EXPORT LinFloatRel
00948   operator !=(const FloatVar& l, const FloatVar& r);
00950   GECODE_MINIMODEL_EXPORT LinFloatRel
00951   operator !=(const FloatVar& l, const BoolVar& r);
00953   GECODE_MINIMODEL_EXPORT LinFloatRel
00954   operator !=(const FloatVar& l, const LinFloatExpr& r);
00956   GECODE_MINIMODEL_EXPORT LinFloatRel
00957   operator !=(const LinFloatExpr& l, const FloatVar& r);
00959   GECODE_MINIMODEL_EXPORT LinFloatRel
00960   operator !=(const LinFloatExpr& l, const BoolVar& r);
00962   GECODE_MINIMODEL_EXPORT LinFloatRel
00963   operator !=(const LinFloatExpr& l, const LinFloatExpr& r);
00964 
00966   GECODE_MINIMODEL_EXPORT LinFloatRel
00967   operator <(const FloatVal& l, const FloatVar& r);
00969   GECODE_MINIMODEL_EXPORT LinFloatRel
00970   operator <(const FloatVal& l, const LinFloatExpr& r);
00972   GECODE_MINIMODEL_EXPORT LinFloatRel
00973   operator <(const FloatVar& l, const FloatVal& r);
00975   GECODE_MINIMODEL_EXPORT LinFloatRel
00976   operator <(const LinFloatExpr& l, const FloatVal& r);
00978   GECODE_MINIMODEL_EXPORT LinFloatRel
00979   operator <(const FloatVar& l, const FloatVar& r);
00981   GECODE_MINIMODEL_EXPORT LinFloatRel
00982   operator <(const FloatVar& l, const LinFloatExpr& r);
00984   GECODE_MINIMODEL_EXPORT LinFloatRel
00985   operator <(const LinFloatExpr& l, const FloatVar& r);
00987   GECODE_MINIMODEL_EXPORT LinFloatRel
00988   operator <(const LinFloatExpr& l, const LinFloatExpr& r);
00989 
00991   GECODE_MINIMODEL_EXPORT LinFloatRel
00992   operator <=(const FloatVal& l, const FloatVar& r);
00994   GECODE_MINIMODEL_EXPORT LinFloatRel
00995   operator <=(const FloatVal& l, const LinFloatExpr& r);
00997   GECODE_MINIMODEL_EXPORT LinFloatRel
00998   operator <=(const FloatVar& l, const FloatVal& r);
01000   GECODE_MINIMODEL_EXPORT LinFloatRel
01001   operator <=(const LinFloatExpr& l, const FloatVal& r);
01003   GECODE_MINIMODEL_EXPORT LinFloatRel
01004   operator <=(const FloatVar& l, const FloatVar& r);
01006   GECODE_MINIMODEL_EXPORT LinFloatRel
01007   operator <=(const FloatVar& l, const LinFloatExpr& r);
01009   GECODE_MINIMODEL_EXPORT LinFloatRel
01010   operator <=(const LinFloatExpr& l, const FloatVar& r);
01012   GECODE_MINIMODEL_EXPORT LinFloatRel
01013   operator <=(const LinFloatExpr& l, const LinFloatExpr& r);
01014 
01016   GECODE_MINIMODEL_EXPORT LinFloatRel
01017   operator >(const FloatVal& l, const FloatVar& r);
01019   GECODE_MINIMODEL_EXPORT LinFloatRel
01020   operator >(const FloatVal& l, const LinFloatExpr& r);
01022   GECODE_MINIMODEL_EXPORT LinFloatRel
01023   operator >(const FloatVar& l, const FloatVal& r);
01025   GECODE_MINIMODEL_EXPORT LinFloatRel
01026   operator >(const LinFloatExpr& l, const FloatVal& r);
01028   GECODE_MINIMODEL_EXPORT LinFloatRel
01029   operator >(const FloatVar& l, const FloatVar& r);
01031   GECODE_MINIMODEL_EXPORT LinFloatRel
01032   operator >(const FloatVar& l, const LinFloatExpr& r);
01034   GECODE_MINIMODEL_EXPORT LinFloatRel
01035   operator >(const LinFloatExpr& l, const FloatVar& r);
01037   GECODE_MINIMODEL_EXPORT LinFloatRel
01038   operator >(const LinFloatExpr& l, const LinFloatExpr& r);
01039 
01041   GECODE_MINIMODEL_EXPORT LinFloatRel
01042   operator >=(const FloatVal& l, const FloatVar& r);
01044   GECODE_MINIMODEL_EXPORT LinFloatRel
01045   operator >=(const FloatVal& l, const LinFloatExpr& r);
01047   GECODE_MINIMODEL_EXPORT LinFloatRel
01048   operator >=(const FloatVar& l, const FloatVal& r);
01050   GECODE_MINIMODEL_EXPORT LinFloatRel
01051   operator >=(const LinFloatExpr& l, const FloatVal& r);
01053   GECODE_MINIMODEL_EXPORT LinFloatRel
01054   operator >=(const FloatVar& l, const FloatVar& r);
01056   GECODE_MINIMODEL_EXPORT LinFloatRel
01057   operator >=(const FloatVar& l, const LinFloatExpr& r);
01059   GECODE_MINIMODEL_EXPORT LinFloatRel
01060   operator >=(const LinFloatExpr& l, const FloatVar& r);
01062   GECODE_MINIMODEL_EXPORT LinFloatRel
01063   operator >=(const LinFloatExpr& l, const LinFloatExpr& r);
01065 #endif
01066 
01067 #ifdef GECODE_HAS_SET_VARS
01068 
01069   class SetExpr {
01070   public:
01072     enum NodeType {
01073       NT_VAR,    
01074       NT_CONST,  
01075       NT_LEXP,   
01076       NT_CMPL,   
01077       NT_INTER,  
01078       NT_UNION,  
01079       NT_DUNION  
01080     };
01082     class Node;
01083   private:
01085     Node* n;
01086   public:
01088     SetExpr(void);
01090     GECODE_MINIMODEL_EXPORT
01091     SetExpr(const SetExpr& e);
01093     GECODE_MINIMODEL_EXPORT
01094     SetExpr(const SetExpr& l, NodeType t, const SetExpr& r);
01096     GECODE_MINIMODEL_EXPORT
01097     SetExpr(const SetVar& x);
01099     GECODE_MINIMODEL_EXPORT
01100     explicit SetExpr(const LinIntExpr& x);
01102     GECODE_MINIMODEL_EXPORT
01103     SetExpr(const IntSet& s);
01105     GECODE_MINIMODEL_EXPORT
01106     SetExpr(const SetExpr& e, NodeType t);
01108     GECODE_MINIMODEL_EXPORT
01109     SetVar post(Home home) const;
01111     GECODE_MINIMODEL_EXPORT
01112     void post(Home home, SetRelType srt, const SetExpr& e) const;
01114     GECODE_MINIMODEL_EXPORT
01115     void post(Home home, BoolVar b, bool t,
01116               SetRelType srt, const SetExpr& e) const;
01118     GECODE_MINIMODEL_EXPORT
01119     const SetExpr& operator =(const SetExpr& e);
01121     GECODE_MINIMODEL_EXPORT
01122     ~SetExpr(void);
01123   };
01124 
01126   class SetCmpRel {
01127   public:
01129     SetExpr l;
01131     SetExpr r;
01133     SetRelType srt;
01135     SetCmpRel(const SetExpr& l, SetRelType srt, const SetExpr& r);
01136   };
01137 
01139   class SetRel {
01140   private:
01142     SetExpr _e0;
01144     SetRelType _srt;
01146     SetExpr _e1;
01147   public:
01149     SetRel(void);
01151     SetRel(const SetExpr& e0, SetRelType srt, const SetExpr& e1);
01153     SetRel(const SetCmpRel& r);
01155     void post(Home home, bool t) const;
01157     void post(Home home, BoolVar b, bool t) const;
01158   };
01159 
01170 
01171   GECODE_MINIMODEL_EXPORT SetExpr
01172   singleton(const LinIntExpr&);
01174   GECODE_MINIMODEL_EXPORT SetExpr
01175   operator -(const SetExpr&);
01177   GECODE_MINIMODEL_EXPORT SetExpr
01178   operator &(const SetExpr&, const SetExpr&);
01180   GECODE_MINIMODEL_EXPORT SetExpr
01181   operator |(const SetExpr&, const SetExpr&);
01183   GECODE_MINIMODEL_EXPORT SetExpr
01184   operator +(const SetExpr&, const SetExpr&);
01186   GECODE_MINIMODEL_EXPORT SetExpr
01187   operator -(const SetExpr&, const SetExpr&);
01188 
01190   GECODE_MINIMODEL_EXPORT SetExpr
01191   inter(const SetVarArgs&);
01193   GECODE_MINIMODEL_EXPORT SetExpr
01194   setunion(const SetVarArgs&);
01196   GECODE_MINIMODEL_EXPORT SetExpr
01197   setdunion(const SetVarArgs&);
01198 
01200   GECODE_MINIMODEL_EXPORT LinIntExpr
01201   cardinality(const SetExpr&);
01203   GECODE_MINIMODEL_EXPORT LinIntExpr
01204   min(const SetExpr&);
01206   GECODE_MINIMODEL_EXPORT LinIntExpr
01207   max(const SetExpr&);
01208 
01210   GECODE_MINIMODEL_EXPORT SetRel
01211   operator ==(const SetExpr&, const SetExpr&);
01213   GECODE_MINIMODEL_EXPORT SetRel
01214   operator !=(const SetExpr&, const SetExpr&);
01216   GECODE_MINIMODEL_EXPORT SetCmpRel
01217   operator <=(const SetExpr&, const SetExpr&);
01219   GECODE_MINIMODEL_EXPORT BoolExpr
01220   operator <=(const SetCmpRel&, const SetExpr&);
01222   GECODE_MINIMODEL_EXPORT SetCmpRel
01223   operator >=(const SetExpr&, const SetExpr&);
01225   GECODE_MINIMODEL_EXPORT BoolExpr
01226   operator >=(const SetCmpRel&, const SetExpr&);
01228   GECODE_MINIMODEL_EXPORT SetRel
01229   operator ||(const SetExpr&, const SetExpr&);
01231 #endif
01232 
01234   class BoolExpr {
01235   public:
01237     enum NodeType {
01238       NT_VAR,       
01239       NT_NOT,       
01240       NT_AND,       
01241       NT_OR,        
01242       NT_EQV,       
01243       NT_RLIN,      
01244       NT_RLINFLOAT, 
01245       NT_RSET,      
01246       NT_MISC       
01247     };
01249     class MiscExpr {
01250     public:
01254       virtual void post(Space& home, BoolVar b, bool neg,
01255                         IntConLevel icl) = 0;
01257       virtual GECODE_MINIMODEL_EXPORT ~MiscExpr(void);
01259       static void* operator new(size_t size);
01261       static void  operator delete(void* p, size_t size);
01262     };
01264     class Node;
01265   private:
01267     Node* n;
01268   public:
01270     GECODE_MINIMODEL_EXPORT
01271     BoolExpr(void);
01273     GECODE_MINIMODEL_EXPORT
01274     BoolExpr(const BoolExpr& e);
01276     GECODE_MINIMODEL_EXPORT
01277     BoolExpr(const BoolExpr& l, NodeType t, const BoolExpr& r);
01279     GECODE_MINIMODEL_EXPORT
01280     BoolExpr(const BoolVar& x);
01282     GECODE_MINIMODEL_EXPORT
01283     BoolExpr(const BoolExpr& e, NodeType t);
01285     GECODE_MINIMODEL_EXPORT
01286     BoolExpr(const LinIntRel& rl);
01287 #ifdef GECODE_HAS_FLOAT_VARS
01288 
01289     GECODE_MINIMODEL_EXPORT
01290     BoolExpr(const LinFloatRel& rfl);
01291 #endif
01292 #ifdef GECODE_HAS_SET_VARS
01293 
01294     GECODE_MINIMODEL_EXPORT
01295     BoolExpr(const SetRel& rs);
01297     GECODE_MINIMODEL_EXPORT
01298     BoolExpr(const SetCmpRel& rs);
01299 #endif
01300 
01301     GECODE_MINIMODEL_EXPORT
01302     explicit BoolExpr(MiscExpr* m);
01304     GECODE_MINIMODEL_EXPORT
01305     BoolVar expr(Home home, IntConLevel icl) const;
01307     GECODE_MINIMODEL_EXPORT
01308     void rel(Home home, IntConLevel icl) const;
01310     GECODE_MINIMODEL_EXPORT
01311     const BoolExpr& operator =(const BoolExpr& e);
01313     GECODE_MINIMODEL_EXPORT
01314     ~BoolExpr(void);
01315   };
01316 
01327 
01328   GECODE_MINIMODEL_EXPORT BoolExpr
01329   operator !(const BoolExpr&);
01331   GECODE_MINIMODEL_EXPORT BoolExpr
01332   operator &&(const BoolExpr&, const BoolExpr&);
01334   GECODE_MINIMODEL_EXPORT BoolExpr
01335   operator ||(const BoolExpr&, const BoolExpr&);
01337   GECODE_MINIMODEL_EXPORT BoolExpr
01338   operator ^(const BoolExpr&, const BoolExpr&);
01339 
01341   GECODE_MINIMODEL_EXPORT BoolExpr
01342   operator !=(const BoolExpr&, const BoolExpr&);
01344   GECODE_MINIMODEL_EXPORT BoolExpr
01345   operator ==(const BoolExpr&, const BoolExpr&);
01347   GECODE_MINIMODEL_EXPORT BoolExpr
01348   operator >>(const BoolExpr&, const BoolExpr&);
01350   GECODE_MINIMODEL_EXPORT BoolExpr
01351   operator <<(const BoolExpr&, const BoolExpr&);
01352 
01354 
01361 
01362   GECODE_MINIMODEL_EXPORT IntVar 
01363   expr(Home home, const LinIntExpr& e, IntConLevel icl=ICL_DEF);
01364 #ifdef GECODE_HAS_FLOAT_VARS
01365 
01366   GECODE_MINIMODEL_EXPORT FloatVar
01367   expr(Home home, const LinFloatExpr& e);
01368 #endif
01369 #ifdef GECODE_HAS_SET_VARS
01370 
01371   GECODE_MINIMODEL_EXPORT SetVar
01372   expr(Home home, const SetExpr& e);
01373 #endif
01374 
01375   GECODE_MINIMODEL_EXPORT BoolVar
01376   expr(Home home, const BoolExpr& e, IntConLevel icl=ICL_DEF);
01378   GECODE_MINIMODEL_EXPORT void 
01379   rel(Home home, const BoolExpr& e, IntConLevel icl=ICL_DEF);
01381 
01382 }
01383 
01384 #include <gecode/minimodel/int-rel.hpp>
01385 #include <gecode/minimodel/float-rel.hpp>
01386 #include <gecode/minimodel/bool-expr.hpp>
01387 #include <gecode/minimodel/set-expr.hpp>
01388 #include <gecode/minimodel/set-rel.hpp>
01389 
01390 namespace Gecode {
01391 
01392   namespace MiniModel {
01393     class ExpInfo;
01394   }
01395 
01401   class GECODE_MINIMODEL_EXPORT REG {
01402     friend class MiniModel::ExpInfo;
01403   private:
01405     class Exp;
01407     Exp* e;
01409     REG(Exp* e);
01410   public:
01412     REG(void);
01414     REG(int s);
01421     REG(const IntArgs& x);
01422 
01424     REG(const REG& r);
01426     const REG& operator =(const REG& r);
01427 
01429     REG operator +(const REG& r);
01431     REG& operator +=(const REG& r);
01433     REG operator |(const REG& r);
01435     REG& operator |=(const REG& r);
01437     REG operator *(void);
01439     REG operator +(void);
01441     REG operator ()(unsigned int n, unsigned int m);
01443     REG operator ()(unsigned int n);
01445     template<class Char, class Traits>
01446     std::basic_ostream<Char,Traits>&
01447     print(std::basic_ostream<Char,Traits>& os) const;
01449     operator DFA(void);
01451     ~REG(void);
01452   };
01453 
01457   template<class Char, class Traits>
01458   std::basic_ostream<Char,Traits>&
01459   operator <<(std::basic_ostream<Char,Traits>& os, const REG& r);
01460 
01461 
01468 
01469   GECODE_MINIMODEL_EXPORT LinIntExpr
01470   abs(const LinIntExpr& e);
01472   GECODE_MINIMODEL_EXPORT LinIntExpr
01473   min(const LinIntExpr& x, const LinIntExpr& y);
01475   GECODE_MINIMODEL_EXPORT LinIntExpr
01476   min(const IntVarArgs& x);
01478   GECODE_MINIMODEL_EXPORT LinIntExpr
01479   max(const LinIntExpr& x, const LinIntExpr& y);
01481   GECODE_MINIMODEL_EXPORT LinIntExpr
01482   max(const IntVarArgs& x);
01483 #ifdef GECODE_HAS_FLOAT_VARS
01484 
01485   GECODE_MINIMODEL_EXPORT LinFloatExpr
01486   operator *(const FloatVar&, const FloatVar&);
01488   GECODE_MINIMODEL_EXPORT LinFloatExpr
01489   operator *(const FloatVar&, const LinFloatExpr&);
01491   GECODE_MINIMODEL_EXPORT LinFloatExpr
01492   operator *(const LinFloatExpr&, const FloatVar&);
01493 #endif
01494 
01495   GECODE_MINIMODEL_EXPORT LinIntExpr
01496   operator *(const LinIntExpr& x, const LinIntExpr& y);
01498   GECODE_MINIMODEL_EXPORT LinIntExpr
01499   operator /(const LinIntExpr& x, const LinIntExpr& y);
01501   GECODE_MINIMODEL_EXPORT LinIntExpr
01502   operator %(const LinIntExpr& x, const LinIntExpr& y);
01504   GECODE_MINIMODEL_EXPORT LinIntExpr
01505   sqr(const LinIntExpr& x);
01507   GECODE_MINIMODEL_EXPORT LinIntExpr
01508   sqrt(const LinIntExpr& x);
01510   GECODE_MINIMODEL_EXPORT LinIntExpr
01511   pow(const LinIntExpr& x, int n);
01513   GECODE_MINIMODEL_EXPORT LinIntExpr
01514   nroot(const LinIntExpr& x, int n);
01516   GECODE_MINIMODEL_EXPORT LinIntExpr
01517   element(const IntVarArgs& x, const LinIntExpr& y);
01519   GECODE_MINIMODEL_EXPORT BoolExpr
01520   element(const BoolVarArgs& x, const LinIntExpr& y);
01522   GECODE_MINIMODEL_EXPORT LinIntExpr
01523   element(const IntArgs& x, const LinIntExpr& y);
01525   GECODE_MINIMODEL_EXPORT LinIntExpr
01526   ite(const BoolExpr& b, const LinIntExpr& x, const LinIntExpr& y);
01528 
01529 #ifdef GECODE_HAS_FLOAT_VARS
01530 
01531   GECODE_MINIMODEL_EXPORT LinFloatExpr
01532   abs(const LinFloatExpr& e);
01534   GECODE_MINIMODEL_EXPORT LinFloatExpr
01535   min(const LinFloatExpr& x, const LinFloatExpr& y);
01537   GECODE_MINIMODEL_EXPORT LinFloatExpr
01538   min(const FloatVarArgs& x);
01540   GECODE_MINIMODEL_EXPORT LinFloatExpr
01541   max(const LinFloatExpr& x, const LinFloatExpr& y);
01543   GECODE_MINIMODEL_EXPORT LinFloatExpr
01544   max(const FloatVarArgs& x);
01546   GECODE_MINIMODEL_EXPORT LinFloatExpr
01547   operator *(const LinFloatExpr& x, const LinFloatExpr& y);
01549   GECODE_MINIMODEL_EXPORT LinFloatExpr
01550   operator /(const LinFloatExpr& x, const LinFloatExpr& y);
01552   GECODE_MINIMODEL_EXPORT LinFloatExpr
01553   sqr(const LinFloatExpr& x);
01555   GECODE_MINIMODEL_EXPORT LinFloatExpr
01556   sqrt(const LinFloatExpr& x);
01558   GECODE_MINIMODEL_EXPORT LinFloatExpr
01559   pow(const LinFloatExpr& x, int n);
01561   GECODE_MINIMODEL_EXPORT LinFloatExpr
01562   nroot(const LinFloatExpr& x, int n);
01564 
01565 #ifdef GECODE_HAS_MPFR
01566 
01572 
01573   GECODE_MINIMODEL_EXPORT LinFloatExpr
01574   exp(const LinFloatExpr& x);
01576   GECODE_MINIMODEL_EXPORT LinFloatExpr
01577   log(const LinFloatExpr& x);
01579 
01586 
01587   GECODE_MINIMODEL_EXPORT LinFloatExpr
01588   asin(const LinFloatExpr& x);
01590   GECODE_MINIMODEL_EXPORT LinFloatExpr
01591   sin(const LinFloatExpr& x);
01593   GECODE_MINIMODEL_EXPORT LinFloatExpr
01594   acos(const LinFloatExpr& x);
01596   GECODE_MINIMODEL_EXPORT LinFloatExpr
01597   cos(const LinFloatExpr& x);
01599   GECODE_MINIMODEL_EXPORT LinFloatExpr
01600   atan(const LinFloatExpr& x);
01602   GECODE_MINIMODEL_EXPORT LinFloatExpr
01603   tan(const LinFloatExpr& x);
01605 #endif
01606 #endif
01607 
01614 
01615   inline BoolVar
01616   channel(Home home, IntVar x,
01617           IntConLevel icl=ICL_DEF) {
01618     (void) icl;
01619     BoolVar b(home,0,1); channel(home,b,x);
01620     return b;
01621   }
01623   inline IntVar
01624   channel(Home home, BoolVar b,
01625           IntConLevel icl=ICL_DEF) {
01626     (void) icl;
01627     IntVar x(home,0,1); channel(home,b,x);
01628     return x;
01629   }
01630 #ifdef GECODE_HAS_FLOAT_VARS 
01631 
01632   inline IntVar
01633   channel(Home home, FloatVar f) {
01634     int min = static_cast<int>(std::max(static_cast<double>(Int::Limits::min),
01635                                         std::ceil(f.min())));
01636     int max = static_cast<int>(std::min(static_cast<double>(Int::Limits::max),
01637                                         std::floor(f.max())));
01638     IntVar x(home,min,max);
01639     channel(home,f,x);
01640     return x;
01641   }
01642 #endif
01643 #ifdef GECODE_HAS_SET_VARS 
01644 
01645   inline SetVar
01646   channel(Home home, const IntVarArgs& x, IntConLevel icl=ICL_DEF) {
01647     (void) icl;
01648     SetVar s(home,IntSet::empty,Set::Limits::min,Set::Limits::max);
01649     rel(home,SOT_UNION,x,s);
01650     nvalues(home,x,IRT_EQ,expr(home,cardinality(s)));
01651     return s;
01652   }
01653 #endif
01654 
01655 
01656 }
01657 
01658 namespace Gecode {
01659 
01674   inline void
01675   atmost(Home home, const IntVarArgs& x, int n, int m,
01676          IntConLevel icl=ICL_DEF) {
01677     count(home,x,n,IRT_LQ,m,icl);
01678   }
01683   inline void
01684   atmost(Home home, const IntVarArgs& x, IntVar y, int m,
01685          IntConLevel icl=ICL_DEF) {
01686     count(home,x,y,IRT_LQ,m,icl);
01687   }
01695   inline void
01696   atmost(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01697          IntConLevel icl=ICL_DEF) {
01698     count(home,x,y,IRT_LQ,m,icl);
01699   }
01704   inline void
01705   atmost(Home home, const IntVarArgs& x, int n, IntVar z,
01706          IntConLevel icl=ICL_DEF) {
01707     count(home,x,n,IRT_LQ,z,icl);
01708   }
01713   inline void
01714   atmost(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01715          IntConLevel icl=ICL_DEF) {
01716     count(home,x,y,IRT_LQ,z,icl);
01717   }
01725   inline void
01726   atmost(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01727          IntConLevel icl=ICL_DEF) {
01728     count(home,x,y,IRT_LQ,z,icl);
01729   }
01730 
01735   inline void
01736   atleast(Home home, const IntVarArgs& x, int n, int m,
01737           IntConLevel icl=ICL_DEF) {
01738     count(home,x,n,IRT_GQ,m,icl);
01739   }
01744   inline void
01745   atleast(Home home, const IntVarArgs& x, IntVar y, int m,
01746           IntConLevel icl=ICL_DEF) {
01747     count(home,x,y,IRT_GQ,m,icl);
01748   }
01756   inline void
01757   atleast(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01758           IntConLevel icl=ICL_DEF) {
01759     count(home,x,y,IRT_GQ,m,icl);
01760   }
01765   inline void
01766   atleast(Home home, const IntVarArgs& x, int n, IntVar z,
01767           IntConLevel icl=ICL_DEF) {
01768     count(home,x,n,IRT_GQ,z,icl);
01769   }
01774   inline void
01775   atleast(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01776           IntConLevel icl=ICL_DEF) {
01777     count(home,x,y,IRT_GQ,z,icl);
01778   }
01786   inline void
01787   atleast(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01788           IntConLevel icl=ICL_DEF) {
01789     count(home,x,y,IRT_GQ,z,icl);
01790   }
01791 
01796   inline void
01797   exactly(Home home, const IntVarArgs& x, int n, int m,
01798           IntConLevel icl=ICL_DEF) {
01799     count(home,x,n,IRT_EQ,m,icl);
01800   }
01805   inline void
01806   exactly(Home home, const IntVarArgs& x, IntVar y, int m,
01807           IntConLevel icl=ICL_DEF) {
01808     count(home,x,y,IRT_EQ,m,icl);
01809   }
01817   inline void
01818   exactly(Home home, const IntVarArgs& x, const IntArgs& y, int m,
01819           IntConLevel icl=ICL_DEF) {
01820     count(home,x,y,IRT_EQ,m,icl);
01821   }
01826   inline void
01827   exactly(Home home, const IntVarArgs& x, int n, IntVar z,
01828           IntConLevel icl=ICL_DEF) {
01829     count(home,x,n,IRT_EQ,z,icl);
01830   }
01835   inline void
01836   exactly(Home home, const IntVarArgs& x, IntVar y, IntVar z,
01837           IntConLevel icl=ICL_DEF) {
01838     count(home,x,y,IRT_EQ,z,icl);
01839   }
01847   inline void
01848   exactly(Home home, const IntVarArgs& x, const IntArgs& y, IntVar z,
01849           IntConLevel icl=ICL_DEF) {
01850     count(home,x,y,IRT_EQ,z,icl);
01851   }
01854   inline void
01855   lex(Home home, const IntVarArgs& x, IntRelType r, const IntVarArgs& y,
01856       IntConLevel icl=ICL_DEF) {
01857     rel(home,x,r,y,icl);
01858   }
01861   inline void
01862   lex(Home home, const BoolVarArgs& x, IntRelType r, const BoolVarArgs& y,
01863       IntConLevel icl=ICL_DEF) {
01864     rel(home,x,r,y,icl);
01865   }
01868   inline void
01869   values(Home home, const IntVarArgs& x, IntSet y,
01870          IntConLevel icl=ICL_DEF) {
01871     dom(home,x,y,icl);
01872     nvalues(home,x,IRT_EQ,static_cast<int>(y.size()),icl);
01873   }
01874 
01876 
01877 #ifdef GECODE_HAS_SET_VARS
01878 
01893   inline void
01894   channel(Home home, const IntVarArgs& x, SetVar y) {
01895     rel(home,SOT_UNION,x,y);
01896     nvalues(home,x,IRT_EQ,expr(home,cardinality(y)));
01897   }
01898   
01901   inline void
01902   range(Home home, const IntVarArgs& x, SetVar y, SetVar z) {
01903     element(home,SOT_UNION,x,y,z);
01904   }
01905 
01911   inline void
01912   roots(Home home, const IntVarArgs& x, SetVar y, SetVar z) {
01913     SetVarArgs xiv(home,z.lubMax()+1,IntSet::empty,0,x.size()-1);
01914     channel(home,x,xiv);
01915     element(home,SOT_UNION,xiv,z,y);
01916   }
01917   
01919 #endif
01920 }
01921 
01922 namespace Gecode {
01923 
01924   template<class> class Matrix;
01925 
01933   template<class A>
01934   class Slice {
01935   public:
01937     typedef typename ArrayTraits<A>::ArgsType ArgsType;
01938   private:
01939     ArgsType _r;     
01940     unsigned int _fc, 
01941       _tc,            
01942       _fr,            
01943       _tr;            
01944   public:
01946     Slice(const Matrix<A>& a, int fc, int tc, int fr, int tr);
01950     Slice& reverse(void);
01952     operator ArgsType(void);
01954     operator Matrix<ArgsType>(void);
01955 
01957     operator const ArgsType(void) const;
01959     operator const Matrix<ArgsType>(void) const;
01960   };
01961   
01963   template<class A>
01964   typename Slice<A>::ArgsType
01965   operator+(const Slice<A>& x, const Slice<A>& y);
01966 
01968   template<class A>
01969   typename Slice<A>::ArgsType
01970   operator+(const Slice<A>& x, const typename ArrayTraits<A>::ArgsType& y);
01971 
01973   template<class A>
01974   typename Slice<A>::ArgsType
01975   operator+(const typename ArrayTraits<A>::ArgsType& x, const Slice<A>& y);
01976 
01978   template<class A>
01979   typename Slice<A>::ArgsType
01980   operator+(const Slice<A>& x, const typename ArrayTraits<A>::ValueType& y);
01981 
01983   template<class A>
01984   typename Slice<A>::ArgsType
01985   operator+(const typename ArrayTraits<A>::ValueType& x, const Slice<A>& y);
01986 
01997   template<class A>
01998   class Matrix {
01999   public:
02001     typedef typename ArrayTraits<A>::ValueType ValueType;
02003     typedef typename ArrayTraits<A>::ArgsType ArgsType;
02004 
02005   private:
02007     typedef typename ArrayTraits<A>::StorageType StorageType;
02008     StorageType _a; 
02009     int _w; 
02010     int _h; 
02011 
02012   public:
02025     Matrix(A a, int w, int h);
02026 
02039     Matrix(A a, int n);
02040 
02042     int width(void) const;
02044     int height(void) const;
02046     ArgsType const get_array(void) const;
02047 
02053     ValueType& operator ()(int c, int r);
02054 
02060     const ValueType& operator ()(int c, int r) const;
02061 
02071     Slice<A> slice(int fc, int tc, int fr, int tr) const;
02072 
02074     Slice<A> row(int r) const;
02075 
02077     Slice<A> col(int c) const;
02078   };
02079 
02083   template<class Char, class Traits, class A>
02084   std::basic_ostream<Char,Traits>&
02085   operator <<(std::basic_ostream<Char,Traits>& os, const Matrix<A>& m);
02086 
02090   template<class Char, class Traits, class A>
02091   std::basic_ostream<Char,Traits>&
02092   operator <<(std::basic_ostream<Char,Traits>& os, const Slice<A>& s);
02093 
02100   void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,  
02101                IntVar z, IntConLevel icl=ICL_DEF);
02108   void element(Home home, const Matrix<IntArgs>& m, IntVar x, IntVar y,  
02109                BoolVar z, IntConLevel icl=ICL_DEF);
02116   void element(Home home, const Matrix<IntVarArgs>& m, IntVar x, IntVar y,  
02117                IntVar z, IntConLevel icl=ICL_DEF);
02124   void element(Home home, const Matrix<BoolVarArgs>& m, IntVar x, IntVar y,  
02125                BoolVar z, IntConLevel icl=ICL_DEF);
02126 #ifdef GECODE_HAS_SET_VARS
02127 
02133   void element(Home home, const Matrix<IntSetArgs>& m, IntVar x, IntVar y,  
02134                SetVar z);
02141   void element(Home home, const Matrix<SetVarArgs>& m, IntVar x, IntVar y,  
02142                SetVar z);
02143 #endif
02144 
02148   template<class A>
02149   SymmetryHandle rows_interchange(const Matrix<A>& m);
02153   template<class A>
02154   SymmetryHandle columns_interchange(const Matrix<A>& m);
02158   template<class A>
02159   SymmetryHandle rows_reflect(const Matrix<A>& m);
02163   template<class A>
02164   SymmetryHandle columns_reflect(const Matrix<A>& m);
02170   template<class A>
02171   SymmetryHandle diagonal_reflect(const Matrix<A>& m);
02172 }
02173 
02174 #include <gecode/minimodel/matrix.hpp>
02175 #include <gecode/minimodel/ldsb.hpp>
02176 
02181 namespace Gecode {
02182 
02184   GECODE_MINIMODEL_EXPORT LinIntExpr 
02185   sum(const Slice<IntArgs>& slice);
02187   GECODE_MINIMODEL_EXPORT LinIntExpr 
02188   sum(const Matrix<IntArgs>& matrix);
02189 
02190 }
02193 namespace Gecode {
02194 
02208   class GECODE_VTABLE_EXPORT IntMinimizeSpace : public Space {
02209   public:
02211     IntMinimizeSpace(void);
02213     IntMinimizeSpace(bool share, IntMinimizeSpace& s);
02215     GECODE_MINIMODEL_EXPORT
02216     virtual void constrain(const Space& best);
02218     virtual IntVar cost(void) const = 0;
02219   };
02220 
02225   class GECODE_VTABLE_EXPORT IntMaximizeSpace : public Space {
02226   public:
02228     IntMaximizeSpace(void);
02230     IntMaximizeSpace(bool share, IntMaximizeSpace& s);
02232     GECODE_MINIMODEL_EXPORT
02233     virtual void constrain(const Space& best);
02235     virtual IntVar cost(void) const = 0;
02236   };
02237 
02242   typedef IntMinimizeSpace MinimizeSpace;
02247   typedef IntMaximizeSpace MaximizeSpace;
02248 
02249   
02250 #ifdef GECODE_HAS_FLOAT_VARS 
02251 
02261   class GECODE_VTABLE_EXPORT FloatMinimizeSpace : public Space {
02262   protected:
02264     FloatNum step;
02265   public:
02267     FloatMinimizeSpace(FloatNum s=0.0);
02269     FloatMinimizeSpace(bool share, FloatMinimizeSpace& s);
02271     GECODE_MINIMODEL_EXPORT
02272     virtual void constrain(const Space& best);
02274     virtual FloatVar cost(void) const = 0;
02275   };
02276 
02286   class GECODE_VTABLE_EXPORT FloatMaximizeSpace : public Space {
02287   protected:
02289     FloatNum step;
02290   public:
02292     FloatMaximizeSpace(FloatNum s=0.0);
02294     FloatMaximizeSpace(bool share, FloatMaximizeSpace& s);
02296     GECODE_MINIMODEL_EXPORT
02297     virtual void constrain(const Space& best);
02299     virtual FloatVar cost(void) const = 0;
02300   };
02301 
02302 #endif
02303 
02304 }
02305 
02306 #include <gecode/minimodel/optimize.hpp>
02307 
02308 #endif
02309 
02310 // IFDEF: GECODE_HAS_INT_VARS
02311 // STATISTICS: minimodel-any
02312