Generated on Tue Apr 18 10:22:11 2017 for Gecode by doxygen 1.6.3

set.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *     Christian Schulte <schulte@gecode.org>
00006  *
00007  *  Contributing authors:
00008  *     Gabor Szokoli <szokoli@gecode.org>
00009  *
00010  *  Copyright:
00011  *     Guido Tack, 2004
00012  *     Christian Schulte, 2004
00013  *     Gabor Szokoli, 2004
00014  *
00015  *  Last modified:
00016  *     $Date: 2017-04-01 20:27:10 +0200 (Sat, 01 Apr 2017) $ by $Author: schulte $
00017  *     $Revision: 15623 $
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_SET_HH__
00045 #define __GECODE_SET_HH__
00046 
00047 #include <gecode/kernel.hh>
00048 #include <gecode/int.hh>
00049 #include <gecode/iter.hh>
00050 
00051 #include <functional>
00052 
00053 /*
00054  * Configure linking
00055  *
00056  */
00057 #if !defined(GECODE_STATIC_LIBS) && \
00058     (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
00059 
00060 #ifdef GECODE_BUILD_SET
00061 #define GECODE_SET_EXPORT __declspec( dllexport )
00062 #else
00063 #define GECODE_SET_EXPORT __declspec( dllimport )
00064 #endif
00065 
00066 #else
00067 
00068 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
00069 #define GECODE_SET_EXPORT __attribute__ ((visibility("default")))
00070 #else
00071 #define GECODE_SET_EXPORT
00072 #endif
00073 
00074 #endif
00075 
00076 // Configure auto-linking
00077 #ifndef GECODE_BUILD_SET
00078 #define GECODE_LIBRARY_NAME "Set"
00079 #include <gecode/support/auto-link.hpp>
00080 #endif
00081 
00082 
00094 #include <gecode/set/exception.hpp>
00095 
00096 namespace Gecode { namespace Set {
00097 
00099   namespace Limits {
00101     const int max = (Gecode::Int::Limits::max / 2) - 1;
00103     const int min = -max;
00105     const unsigned int card = max-min+1;
00107     void check(int n, const char* l);
00109     void check(unsigned int n, const char* l);
00111     void check(const IntSet& s, const char* l);
00112   }
00113 
00114 }}
00115 
00116 #include <gecode/set/limits.hpp>
00117 
00118 #include <gecode/set/var-imp.hpp>
00119 
00120 namespace Gecode {
00121 
00122   namespace Set {
00123     class SetView;
00124   }
00125 
00131   class SetVar : public VarImpVar<Set::SetVarImp> {
00132     friend class SetVarArray;
00133     friend class SetVarArgs;
00134     using VarImpVar<Set::SetVarImp>::x;
00135   public:
00137 
00138 
00139     SetVar(void);
00141     SetVar(const SetVar& y);
00143     SetVar(const Set::SetView& y);
00144 
00146     GECODE_SET_EXPORT SetVar(Space& home);
00147 
00165     GECODE_SET_EXPORT
00166     SetVar(Space& home,int glbMin,int glbMax,int lubMin,int lubMax,
00167            unsigned int cardMin = 0,
00168            unsigned int cardMax = Set::Limits::card);
00169 
00186     GECODE_SET_EXPORT
00187     SetVar(Space& home,const IntSet& glbD,int lubMin,int lubMax,
00188            unsigned int cardMin = 0,
00189            unsigned int cardMax = Set::Limits::card);
00190 
00208     GECODE_SET_EXPORT
00209     SetVar(Space& home,int glbMin,int glbMax,const IntSet& lubD,
00210            unsigned int cardMin = 0,
00211            unsigned int cardMax = Set::Limits::card);
00212 
00230     GECODE_SET_EXPORT
00231     SetVar(Space& home,const IntSet& glbD,const IntSet& lubD,
00232            unsigned int cardMin = 0,
00233            unsigned int cardMax = Set::Limits::card);
00235 
00237 
00238 
00239     unsigned int glbSize(void) const;
00241     unsigned int lubSize(void) const;
00243     unsigned int unknownSize(void) const;
00245     unsigned int cardMin(void) const;
00247     unsigned int cardMax(void) const;
00249     int lubMin(void) const;
00251     int lubMax(void) const;
00253     int glbMin(void) const;
00255     int glbMax(void) const;
00257 
00259 
00260 
00261     bool contains(int i) const;
00263     bool notContains(int i) const;
00265   };
00266 
00272 
00274   class SetVarGlbRanges {
00275   private:
00276     Set::GlbRanges<Set::SetVarImp*> iter;
00277   public:
00279 
00280 
00281     SetVarGlbRanges(void);
00283     SetVarGlbRanges(const SetVar& x);
00285 
00287 
00288 
00289     bool operator ()(void) const;
00291     void operator ++(void);
00293 
00295 
00296 
00297     int min(void) const;
00299     int max(void) const;
00301     unsigned int width(void) const;
00303   };
00304 
00306   class SetVarLubRanges {
00307   private:
00308     Set::LubRanges<Set::SetVarImp*> iter;
00309   public:
00311 
00312 
00313     SetVarLubRanges(void);
00315     SetVarLubRanges(const SetVar& x);
00317 
00319 
00320 
00321     bool operator ()(void) const;
00323     void operator ++(void);
00325 
00327 
00328 
00329     int min(void) const;
00331     int max(void) const;
00333     unsigned int width(void) const;
00335   };
00336 
00338   class SetVarUnknownRanges {
00339   private:
00340     Set::UnknownRanges<Set::SetVarImp*> iter;
00341   public:
00343 
00344 
00345     SetVarUnknownRanges(void);
00347     SetVarUnknownRanges(const SetVar& x);
00349 
00351 
00352 
00353     bool operator ()(void) const;
00355     void operator ++(void);
00357 
00359 
00360 
00361     int min(void) const;
00363     int max(void) const;
00365     unsigned int width(void) const;
00367   };
00368 
00370   class SetVarGlbValues {
00371   private:
00372     Iter::Ranges::ToValues<SetVarGlbRanges> iter;
00373   public:
00375 
00376 
00377     SetVarGlbValues(void);
00379     SetVarGlbValues(const SetVar& x);
00381 
00383 
00384 
00385     bool operator ()(void) const;
00387     void operator ++(void);
00389 
00391 
00392 
00393     int  val(void) const;
00395   };
00396 
00398   class SetVarLubValues {
00399   private:
00400     Iter::Ranges::ToValues<SetVarLubRanges> iter;
00401   public:
00403 
00404 
00405     SetVarLubValues(void);
00407     SetVarLubValues(const SetVar& x);
00409 
00411 
00412 
00413     bool operator ()(void) const;
00415     void operator ++(void);
00417 
00419 
00420 
00421     int  val(void) const;
00423   };
00424 
00426   class SetVarUnknownValues {
00427   private:
00428     Iter::Ranges::ToValues<SetVarUnknownRanges> iter;
00429   public:
00431 
00432 
00433     SetVarUnknownValues(void);
00435     SetVarUnknownValues(const SetVar& x);
00437 
00439 
00440 
00441     bool operator ()(void) const;
00443     void operator ++(void);
00445 
00447 
00448 
00449     int  val(void) const;
00451   };
00452 
00454 
00459   template<class Char, class Traits>
00460   std::basic_ostream<Char,Traits>&
00461   operator <<(std::basic_ostream<Char,Traits>& os, const SetVar& x);
00462 
00463 }
00464 
00465 #include <gecode/set/view.hpp>
00466 
00467 namespace Gecode {
00477 
00478 }
00479 
00480 #include <gecode/set/array-traits.hpp>
00481 
00482 namespace Gecode {
00483 
00492   class SetVarArgs : public VarArgArray<SetVar> {
00493   public:
00495 
00496 
00497     SetVarArgs(void);
00499     explicit SetVarArgs(int n);
00501     SetVarArgs(const SetVarArgs& a);
00503     SetVarArgs(const VarArray<SetVar>& a);
00505     SetVarArgs(const std::vector<SetVar>& a);
00507     template<class InputIterator>
00508     SetVarArgs(InputIterator first, InputIterator last);
00515     GECODE_SET_EXPORT
00516     SetVarArgs(Space& home,int n,int glbMin,int glbMax,
00517                int lubMin,int lubMax,
00518                unsigned int minCard = 0,
00519                unsigned int maxCard = Set::Limits::card);
00526     GECODE_SET_EXPORT
00527     SetVarArgs(Space& home,int n,const IntSet& glb,
00528                int lubMin, int lubMax,
00529                unsigned int minCard = 0,
00530                unsigned int maxCard = Set::Limits::card);
00537     GECODE_SET_EXPORT
00538     SetVarArgs(Space& home,int n,int glbMin,int glbMax,
00539                const IntSet& lub,
00540                unsigned int minCard = 0,
00541                unsigned int maxCard = Set::Limits::card);
00548     GECODE_SET_EXPORT
00549     SetVarArgs(Space& home,int n,
00550                const IntSet& glb,const IntSet& lub,
00551                unsigned int minCard = 0,
00552                unsigned int maxCard = Set::Limits::card);
00554   };
00556 
00572   class SetVarArray : public VarArray<SetVar> {
00573   public:
00575 
00576 
00577     SetVarArray(void);
00579     SetVarArray(const SetVarArray&);
00581     SetVarArray(Space& home, const SetVarArgs&);
00583     GECODE_SET_EXPORT SetVarArray(Space& home, int n);
00590     GECODE_SET_EXPORT
00591     SetVarArray(Space& home,int n,int glbMin,int glbMax,int lubMin,int lubMax,
00592                 unsigned int minCard = 0,
00593                 unsigned int maxCard = Set::Limits::card);
00600     GECODE_SET_EXPORT
00601     SetVarArray(Space& home,int n,const IntSet& glb, int lubMin, int lubMax,
00602                 unsigned int minCard = 0,
00603                 unsigned int maxCard = Set::Limits::card);
00610     GECODE_SET_EXPORT
00611     SetVarArray(Space& home,int n,int glbMin,int glbMax,const IntSet& lub,
00612                 unsigned int minCard = 0,
00613                 unsigned int maxCard = Set::Limits::card);
00620     GECODE_SET_EXPORT
00621     SetVarArray(Space& home,int n,
00622                 const IntSet& glb,const IntSet& lub,
00623                 unsigned int minCard = 0,
00624                 unsigned int maxCard = Set::Limits::card);
00626   };
00627 
00628 }
00629 
00630 #include <gecode/set/array.hpp>
00631 
00632 namespace Gecode {
00633 
00645   enum SetRelType {
00646     SRT_EQ,   
00647     SRT_NQ,   
00648     SRT_SUB,  
00649     SRT_SUP,  
00650     SRT_DISJ, 
00651     SRT_CMPL, 
00652     SRT_LQ,   
00653     SRT_LE,   
00654     SRT_GQ,   
00655     SRT_GR    
00656   };
00657 
00662   enum SetOpType {
00663     SOT_UNION,  
00664     SOT_DUNION, 
00665     SOT_INTER,  
00666     SOT_MINUS   
00667   };
00668 
00676 
00678   GECODE_SET_EXPORT void
00679   dom(Home home, SetVar x, SetRelType r, int i);
00681   GECODE_SET_EXPORT void
00682   dom(Home home, const SetVarArgs& x, SetRelType r, int i);
00684   GECODE_SET_EXPORT void
00685   dom(Home home, SetVar x, SetRelType r, int i, int j);
00687   GECODE_SET_EXPORT void
00688   dom(Home home, const SetVarArgs& x, SetRelType r, int i, int j);
00690   GECODE_SET_EXPORT void
00691   dom(Home home, SetVar x, SetRelType r, const IntSet& s);
00693   GECODE_SET_EXPORT void
00694   dom(Home home, const SetVarArgs& x, SetRelType r, const IntSet& s);
00696   GECODE_SET_EXPORT void
00697   cardinality(Home home, SetVar x, unsigned int i, unsigned int j);
00699   GECODE_SET_EXPORT void
00700   cardinality(Home home, const SetVarArgs& x, unsigned int i, unsigned int j);
00702   GECODE_SET_EXPORT void
00703   dom(Home home, SetVar x, SetRelType rt, int i, Reify r);
00705   GECODE_SET_EXPORT void
00706   dom(Home home, SetVar x, SetRelType rt, int i, int j, Reify r);
00708   GECODE_SET_EXPORT void
00709   dom(Home home, SetVar x, SetRelType rt, const IntSet& s, Reify r);
00711   GECODE_SET_EXPORT void
00712   dom(Home home, SetVar x, SetVar d);
00714   GECODE_SET_EXPORT void
00715   dom(Home home, const SetVarArgs& x, const SetVarArgs& d);
00717 
00718 
00726 
00728   GECODE_SET_EXPORT void
00729   rel(Home home, SetVar x, SetRelType r, SetVar y);
00730 
00732   GECODE_SET_EXPORT void
00733   rel(Home home, SetVar x, SetRelType rt, SetVar y, Reify r);
00734 
00736   GECODE_SET_EXPORT void
00737   rel(Home home, SetVar s, SetRelType r, IntVar x);
00738 
00740   GECODE_SET_EXPORT void
00741   rel(Home home, IntVar x, SetRelType r, SetVar s);
00742 
00744   GECODE_SET_EXPORT void
00745   rel(Home home, SetVar s, SetRelType rt, IntVar x, Reify r);
00746 
00748   GECODE_SET_EXPORT void
00749   rel(Home home, IntVar x, SetRelType rt, SetVar s, Reify r);
00750 
00752   GECODE_SET_EXPORT void
00753   rel(Home home, SetVar s, IntRelType rt, IntVar x);
00754 
00756   void
00757   rel(Home home, IntVar x, IntRelType rt, SetVar s);
00758 
00760   GECODE_SET_EXPORT void
00761   rel(Home home, SetVar s, IntRelType rt, IntVar x, Reify r);
00762 
00764   void
00765   rel(Home home, IntVar x, IntRelType rt, SetVar s, Reify r);
00767 
00768 }
00769 
00770 #include <gecode/set/int.hpp>
00771 
00772 namespace Gecode {
00773 
00781 
00783   GECODE_SET_EXPORT void
00784   rel(Home home, SetVar x, SetOpType op, SetVar y, SetRelType r, SetVar z);
00785 
00787   GECODE_SET_EXPORT void
00788   rel(Home home, SetOpType op, const SetVarArgs& x, SetVar y);
00789 
00791   GECODE_SET_EXPORT void
00792   rel(Home home, SetOpType op, const SetVarArgs& x, const IntSet& z, SetVar y);
00793 
00795   GECODE_SET_EXPORT void
00796   rel(Home home, SetOpType op, const IntVarArgs& x, const IntSet& z, SetVar y);
00797 
00799   GECODE_SET_EXPORT void
00800   rel(Home home, SetOpType op, const IntVarArgs& x, SetVar y);
00801 
00803   GECODE_SET_EXPORT void
00804   rel(Home home, const IntSet& x, SetOpType op, SetVar y,
00805       SetRelType r, SetVar z);
00806 
00808   GECODE_SET_EXPORT void
00809   rel(Home home, SetVar x, SetOpType op, const IntSet& y,
00810       SetRelType r, SetVar z);
00811 
00813   GECODE_SET_EXPORT void
00814   rel(Home home, SetVar x, SetOpType op, SetVar y,
00815       SetRelType r, const IntSet& z);
00816 
00818   GECODE_SET_EXPORT void
00819   rel(Home home, const IntSet& x, SetOpType op, SetVar y, SetRelType r,
00820       const IntSet& z);
00821 
00823   GECODE_SET_EXPORT void
00824   rel(Home home, SetVar x, SetOpType op, const IntSet& y, SetRelType r,
00825       const IntSet& z);
00826 
00831   GECODE_SET_EXPORT void
00832   ite(Home home, BoolVar b, SetVar x, SetVar y, SetVar z);
00833 
00835 
00836 
00843 
00845   GECODE_SET_EXPORT void
00846   convex(Home home, SetVar x);
00847 
00849   GECODE_SET_EXPORT void
00850   convex(Home home, SetVar x, SetVar y);
00851 
00853 
00860 
00862   GECODE_SET_EXPORT void
00863   sequence(Home home, const SetVarArgs& x);
00864 
00866   GECODE_SET_EXPORT void
00867   sequence(Home home, const SetVarArgs& y, SetVar x);
00868 
00870 
00877 
00878 
00880   GECODE_SET_EXPORT void
00881   atmostOne(Home home, const SetVarArgs& x, unsigned int c);
00882 
00884 
00892 
00895   GECODE_SET_EXPORT void
00896   min(Home home, SetVar s, IntVar x);
00897 
00900   GECODE_SET_EXPORT void
00901   notMin(Home home, SetVar s, IntVar x);
00902 
00905   GECODE_SET_EXPORT void
00906   min(Home home, SetVar s, IntVar x, Reify r);
00907 
00910   GECODE_SET_EXPORT void
00911   max(Home home, SetVar s, IntVar x);
00912 
00915   GECODE_SET_EXPORT void
00916   notMax(Home home, SetVar s, IntVar x);
00917 
00920   GECODE_SET_EXPORT void
00921   max(Home home, SetVar s, IntVar x, Reify r);
00922 
00924   GECODE_SET_EXPORT void
00925   cardinality(Home home, SetVar s, IntVar x);
00926 
00928   GECODE_SET_EXPORT void
00929   cardinality(Home home, SetVar s, IntVar x, Reify r);
00930 
00941   GECODE_SET_EXPORT void
00942   weights(Home home, IntSharedArray elements, IntSharedArray weights,
00943           SetVar x, IntVar y);
00944 
00946 
00954 
00956   GECODE_SET_EXPORT void
00957   channel(Home home, const IntVarArgs& x,const SetVarArgs& y);
00958 
00960   GECODE_SET_EXPORT void
00961   channelSorted(Home home, const IntVarArgs& x, SetVar y);
00962 
00964   GECODE_SET_EXPORT void
00965   channel(Home home, const BoolVarArgs& x, SetVar y);
00966 
00968   GECODE_SET_EXPORT void
00969   channel(Home home, const SetVarArgs& x, const SetVarArgs& y);
00970 
00972 
00984   GECODE_SET_EXPORT void
00985   precede(Home home, const SetVarArgs& x, int s, int t);
00989   GECODE_SET_EXPORT void
00990   precede(Home home, const SetVarArgs& x, const IntArgs& c);
00991 
01005 
01015   GECODE_SET_EXPORT void
01016   element(Home home, SetOpType op, const SetVarArgs& x, SetVar y, SetVar z,
01017     const IntSet& u = IntSet(Set::Limits::min,Set::Limits::max));
01018 
01028   GECODE_SET_EXPORT void
01029   element(Home home, SetOpType op, const IntVarArgs& x, SetVar y, SetVar z,
01030           const IntSet& u = IntSet(Set::Limits::min,Set::Limits::max));
01031 
01041   GECODE_SET_EXPORT void
01042   element(Home home, SetOpType op, const IntSetArgs& x, SetVar y, SetVar z,
01043           const IntSet& u = IntSet(Set::Limits::min,Set::Limits::max));
01044 
01054   GECODE_SET_EXPORT void
01055   element(Home home, SetOpType op, const IntArgs& x, SetVar y, SetVar z,
01056           const IntSet& u = IntSet(Set::Limits::min,Set::Limits::max));
01057 
01063   GECODE_SET_EXPORT void
01064   element(Home home, const SetVarArgs& x, IntVar y, SetVar z);
01065 
01071   GECODE_SET_EXPORT void
01072   element(Home home, const IntSetArgs& s, IntVar y, SetVar z);
01073 
01079   GECODE_SET_EXPORT void
01080   element(Home home, const IntSetArgs& a,
01081           IntVar x, int w, IntVar y, int h, SetVar z);
01087   GECODE_SET_EXPORT void
01088   element(Home home, const SetVarArgs& a,
01089           IntVar x, int w, IntVar y, int h, SetVar z);
01091 
01102 
01103   GECODE_SET_EXPORT void
01104   wait(Home home, SetVar x, std::function<void(Space& home)> c);
01106   GECODE_SET_EXPORT void
01107   wait(Home home, const SetVarArgs& x,
01108        std::function<void(Space& home)> c);
01110 
01111 }
01112 
01113 namespace Gecode {
01114 
01128   typedef std::function<bool(const Space& home, SetVar x, int i)>
01129     SetBranchFilter;
01140   typedef std::function<double(const Space& home, SetVar x, int i)>
01141     SetBranchMerit;
01142 
01153   typedef std::function<int(const Space& home, SetVar x, int i)>
01154     SetBranchVal;
01155 
01167   typedef std::function<void(Space& home, unsigned int a,
01168                              SetVar x, int i, int n)>
01169     SetBranchCommit;
01170 
01171 }
01172 
01173 #include <gecode/set/branch/traits.hpp>
01174 
01175 namespace Gecode {
01176 
01182   class SetAFC : public AFC {
01183   public:
01191     SetAFC(void);
01193     SetAFC(const SetAFC& a);
01195     SetAFC& operator =(const SetAFC& a);
01197     SetAFC(Home home, const SetVarArgs& x, double d=1.0);
01205     void init(Home home, const SetVarArgs& x, double d=1.0);
01206   };
01207 
01208 }
01209 
01210 #include <gecode/set/branch/afc.hpp>
01211 
01212 namespace Gecode {
01213 
01214 
01220   class SetAction : public Action {
01221   public:
01229     SetAction(void);
01231     SetAction(const SetAction& a);
01233     SetAction& operator =(const SetAction& a);
01242     GECODE_SET_EXPORT
01243     SetAction(Home home, const SetVarArgs& x, double d=1.0,
01244                 SetBranchMerit bm=nullptr);
01256     GECODE_SET_EXPORT void
01257     init(Home home, const SetVarArgs& x, double d=1.0,
01258          SetBranchMerit bm=nullptr);
01259   };
01260 
01261 }
01262 
01263 #include <gecode/set/branch/action.hpp>
01264 
01265 namespace Gecode {
01266 
01272   class SetCHB : public CHB {
01273   public:
01281     SetCHB(void);
01283     SetCHB(const SetCHB& chb);
01285     SetCHB& operator =(const SetCHB& chb);
01294     GECODE_SET_EXPORT
01295     SetCHB(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
01307     GECODE_SET_EXPORT void
01308     init(Home home, const SetVarArgs& x, SetBranchMerit bm=nullptr);
01309   };
01310 
01311 }
01312 
01313 #include <gecode/set/branch/chb.hpp>
01314 
01315 namespace Gecode {
01316 
01318   typedef std::function<void(const Space &home, const Brancher& b,
01319                              unsigned int a,
01320                              SetVar x, int i, const int& n,
01321                              std::ostream& o)>
01322     SetVarValPrint;
01323 
01324 }
01325 
01326 namespace Gecode {
01327 
01333   class SetVarBranch : public VarBranch<SetVar> {
01334   public:
01336     enum Select {
01337       SEL_NONE = 0,        
01338       SEL_RND,             
01339       SEL_MERIT_MIN,       
01340       SEL_MERIT_MAX,       
01341       SEL_DEGREE_MIN,      
01342       SEL_DEGREE_MAX,      
01343       SEL_AFC_MIN,         
01344       SEL_AFC_MAX,         
01345       SEL_ACTION_MIN,      
01346       SEL_ACTION_MAX,      
01347       SEL_CHB_MIN,         
01348       SEL_CHB_MAX,         
01349       SEL_MIN_MIN,         
01350       SEL_MIN_MAX,         
01351       SEL_MAX_MIN,         
01352       SEL_MAX_MAX,         
01353       SEL_SIZE_MIN,        
01354       SEL_SIZE_MAX,        
01355       SEL_DEGREE_SIZE_MIN, 
01356       SEL_DEGREE_SIZE_MAX, 
01357       SEL_AFC_SIZE_MIN,    
01358       SEL_AFC_SIZE_MAX,    
01359       SEL_ACTION_SIZE_MIN, 
01360       SEL_ACTION_SIZE_MAX, 
01361       SEL_CHB_SIZE_MIN,    
01362       SEL_CHB_SIZE_MAX     
01363     };
01364   protected:
01366     Select s;
01367   public:
01369     SetVarBranch(void);
01371     SetVarBranch(Rnd r);
01373     SetVarBranch(Select s, BranchTbl t);
01375     SetVarBranch(Select s, double d, BranchTbl t);
01377     SetVarBranch(Select s, SetAFC a, BranchTbl t);
01379     SetVarBranch(Select s, SetAction a, BranchTbl t);
01381     SetVarBranch(Select s, SetCHB c, BranchTbl t);
01383     SetVarBranch(Select s, SetBranchMerit mf, BranchTbl t);
01385     Select select(void) const;
01387     void expand(Home home, const SetVarArgs& x);
01388   };
01389 
01395 
01396   SetVarBranch SET_VAR_NONE(void);
01398   SetVarBranch SET_VAR_RND(Rnd r);
01400   SetVarBranch SET_VAR_MERIT_MIN(SetBranchMerit bm, BranchTbl tbl=nullptr);
01402   SetVarBranch SET_VAR_MERIT_MAX(SetBranchMerit bm, BranchTbl tbl=nullptr);
01404   SetVarBranch SET_VAR_DEGREE_MIN(BranchTbl tbl=nullptr);
01406   SetVarBranch SET_VAR_DEGREE_MAX(BranchTbl tbl=nullptr);
01408   SetVarBranch SET_VAR_AFC_MIN(double d=1.0, BranchTbl tbl=nullptr);
01410   SetVarBranch SET_VAR_AFC_MIN(SetAFC a, BranchTbl tbl=nullptr);
01412   SetVarBranch SET_VAR_AFC_MAX(double d=1.0, BranchTbl tbl=nullptr);
01414   SetVarBranch SET_VAR_AFC_MAX(SetAFC a, BranchTbl tbl=nullptr);
01416   SetVarBranch SET_VAR_ACTION_MIN(double d=1.0, BranchTbl tbl=nullptr);
01418   SetVarBranch SET_VAR_ACTION_MIN(SetAction a, BranchTbl tbl=nullptr);
01420   SetVarBranch SET_VAR_ACTION_MAX(double d=1.0, BranchTbl tbl=nullptr);
01422   SetVarBranch SET_VAR_ACTION_MAX(SetAction a, BranchTbl tbl=nullptr);
01424   SetVarBranch SET_VAR_CHB_MIN(BranchTbl tbl=nullptr);
01426   SetVarBranch SET_VAR_CHB_MIN(SetCHB c, BranchTbl tbl=nullptr);
01428   SetVarBranch SET_VAR_CHB_MAX(BranchTbl tbl=nullptr);
01430   SetVarBranch SET_VAR_CHB_MAX(SetCHB c, BranchTbl tbl=nullptr);
01432   SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl=nullptr);
01434   SetVarBranch SET_VAR_MIN_MAX(BranchTbl tbl=nullptr);
01436   SetVarBranch SET_VAR_MAX_MIN(BranchTbl tbl=nullptr);
01438   SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl=nullptr);
01440   SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl=nullptr);
01442   SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl=nullptr);
01444   SetVarBranch SET_VAR_DEGREE_SIZE_MIN(BranchTbl tbl=nullptr);
01446   SetVarBranch SET_VAR_DEGREE_SIZE_MAX(BranchTbl tbl=nullptr);
01448   SetVarBranch SET_VAR_AFC_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01450   SetVarBranch SET_VAR_AFC_SIZE_MIN(SetAFC a, BranchTbl tbl=nullptr);
01452   SetVarBranch SET_VAR_AFC_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01454   SetVarBranch SET_VAR_AFC_SIZE_MAX(SetAFC a, BranchTbl tbl=nullptr);
01456   SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d=1.0, BranchTbl tbl=nullptr);
01458   SetVarBranch SET_VAR_ACTION_SIZE_MIN(SetAction a, BranchTbl tbl=nullptr);
01460   SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d=1.0, BranchTbl tbl=nullptr);
01462   SetVarBranch SET_VAR_ACTION_SIZE_MAX(SetAction a, BranchTbl tbl=nullptr);
01464   SetVarBranch SET_VAR_CHB_SIZE_MIN(BranchTbl tbl=nullptr);
01466   SetVarBranch SET_VAR_CHB_SIZE_MIN(SetCHB c, BranchTbl tbl=nullptr);
01468   SetVarBranch SET_VAR_CHB_SIZE_MAX(BranchTbl tbl=nullptr);
01470   SetVarBranch SET_VAR_CHB_SIZE_MAX(SetCHB c, BranchTbl tbl=nullptr);
01472 
01473 }
01474 
01475 #include <gecode/set/branch/var.hpp>
01476 
01477 namespace Gecode {
01478 
01484   class SetValBranch : public ValBranch<SetVar> {
01485   public:
01487     enum Select {
01488       SEL_MIN_INC,   
01489       SEL_MIN_EXC,   
01490       SEL_MED_INC,   
01491       SEL_MED_EXC,   
01492       SEL_MAX_INC,   
01493       SEL_MAX_EXC,   
01494       SEL_RND_INC,   
01495       SEL_RND_EXC,   
01496       SEL_VAL_COMMIT 
01497     };
01498   protected:
01500     Select s;
01501   public:
01503     SetValBranch(Select s = SEL_MIN_INC);
01505     SetValBranch(Select s, Rnd r);
01507     SetValBranch(SetBranchVal v, SetBranchCommit c);
01509     Select select(void) const;
01510   };
01511 
01517 
01518   SetValBranch SET_VAL_MIN_INC(void);
01520   SetValBranch SET_VAL_MIN_EXC(void);
01522   SetValBranch SET_VAL_MED_INC(void);
01524   SetValBranch SET_VAL_MED_EXC(void);
01526   SetValBranch SET_VAL_MAX_INC(void);
01528   SetValBranch SET_VAL_MAX_EXC(void);
01530   SetValBranch SET_VAL_RND_INC(Rnd r);
01532   SetValBranch SET_VAL_RND_EXC(Rnd r);
01540   SetValBranch SET_VAL(SetBranchVal v, SetBranchCommit c=nullptr);
01542 
01543 }
01544 
01545 #include <gecode/set/branch/val.hpp>
01546 
01547 namespace Gecode {
01548 
01554   class SetAssign : public ValBranch<SetVar> {
01555   public:
01557     enum Select {
01558       SEL_MIN_INC,   
01559       SEL_MIN_EXC,   
01560       SEL_MED_INC,   
01561       SEL_MED_EXC,   
01562       SEL_MAX_INC,   
01563       SEL_MAX_EXC,   
01564       SEL_RND_INC,   
01565       SEL_RND_EXC,   
01566       SEL_VAL_COMMIT 
01567     };
01568   protected:
01570     Select s;
01571   public:
01573     SetAssign(Select s = SEL_MIN_INC);
01575     SetAssign(Select s, Rnd r);
01577     SetAssign(SetBranchVal v, SetBranchCommit c);
01579     Select select(void) const;
01580   };
01581 
01587 
01588   SetAssign SET_ASSIGN_MIN_INC(void);
01590   SetAssign SET_ASSIGN_MIN_EXC(void);
01592   SetAssign SET_ASSIGN_MED_INC(void);
01594   SetAssign SET_ASSIGN_MED_EXC(void);
01596   SetAssign SET_ASSIGN_MAX_INC(void);
01598   SetAssign SET_ASSIGN_MAX_EXC(void);
01600   SetAssign SET_ASSIGN_RND_INC(Rnd r);
01602   SetAssign SET_ASSIGN_RND_EXC(Rnd r);
01609   SetAssign SET_ASSIGN(SetBranchVal v, SetBranchCommit c=nullptr);
01611 
01612 }
01613 
01614 #include <gecode/set/branch/assign.hpp>
01615 
01616 namespace Gecode {
01617 
01623   GECODE_SET_EXPORT void
01624   branch(Home home, const SetVarArgs& x,
01625          SetVarBranch vars, SetValBranch vals,
01626          SetBranchFilter bf=nullptr,
01627          SetVarValPrint vvp=nullptr);
01633   GECODE_SET_EXPORT void
01634   branch(Home home, const SetVarArgs& x,
01635          TieBreak<SetVarBranch> vars, SetValBranch vals,
01636          SetBranchFilter bf=nullptr,
01637          SetVarValPrint vvp=nullptr);
01643   GECODE_SET_EXPORT void
01644   branch(Home home, SetVar x, SetValBranch vals,
01645          SetVarValPrint vvp=nullptr);
01651   GECODE_SET_EXPORT void
01652   assign(Home home, const SetVarArgs& x, SetAssign vals,
01653          SetBranchFilter bf=nullptr,
01654          SetVarValPrint vvp=nullptr);
01660   GECODE_SET_EXPORT void
01661   assign(Home home, SetVar x, SetAssign vals,
01662          SetVarValPrint vvp=nullptr);
01663 
01664 }
01665 
01666 // LDSB-related declarations.
01667 namespace Gecode {
01669   GECODE_SET_EXPORT SymmetryHandle VariableSymmetry(const SetVarArgs& x);
01675   GECODE_SET_EXPORT
01676   SymmetryHandle VariableSequenceSymmetry(const SetVarArgs& x, int ss);
01683   GECODE_SET_EXPORT void
01684   branch(Home home, const SetVarArgs& x,
01685          SetVarBranch vars, SetValBranch vals,
01686          const Symmetries& syms,
01687          SetBranchFilter bf=nullptr,
01688          SetVarValPrint vvp=nullptr);
01695   GECODE_SET_EXPORT void
01696   branch(Home home, const SetVarArgs& x,
01697          TieBreak<SetVarBranch> vars, SetValBranch vals,
01698          const Symmetries& syms,
01699          SetBranchFilter bf=nullptr,
01700          SetVarValPrint vvp=nullptr);
01701 }
01702 
01703 namespace Gecode {
01704 
01705   /*
01706    * \brief Relaxed assignment of variables in \a x from values in \a sx
01707    *
01708    * The variables in \a x are assigned values from the assigned variables
01709    * in the solution \a sx with a relaxation probability \a p. That is,
01710    * if \$fp=0.1\f$ approximately 10% of the variables in \a x will be
01711    * assigned a value from \a sx.
01712    *
01713    * The random numbers are generated from the generator \a r. At least
01714    * one variable will not be assigned: in case the relaxation attempt
01715    * would suggest that all variables should be assigned, a single
01716    * variable will be selected randomly to remain unassigned.
01717    *
01718    * Throws an exception of type Set::ArgumentSizeMismatch, if \a x and
01719    * \a sx are of different size.
01720    *
01721    * Throws an exception of type Set::OutOfLimits, if \a p is not between
01722    * \a 0.0 and \a 1.0.
01723    *
01724    * \ingroup TaskModeSet
01725    */
01726   GECODE_SET_EXPORT void
01727   relax(Home home, const SetVarArgs& x, const SetVarArgs& sx,
01728         Rnd r, double p);
01729 
01730 }
01731 
01732 #include <gecode/set/trace/trace-view.hpp>
01733 
01734 namespace Gecode {
01735 
01745   class SetTraceDelta {
01746   protected:
01748   public:
01750     class Glb
01751       : public Iter::Ranges::Diff<Set::GlbRanges<Set::SetView>,
01752                                   Iter::Ranges::RangeList> {
01753     protected:
01755       Iter::Ranges::RangeList o;
01757       Set::GlbRanges<Set::SetView> n;
01758     public:
01760 
01761 
01762       Glb(RangeList* o, Set::SetView n);
01764     };
01765     Glb _glb;
01767     class Lub
01768       : public Iter::Ranges::Diff<Iter::Ranges::RangeList,
01769                                   Set::LubRanges<Set::SetView> > {
01770     protected:
01772       Iter::Ranges::RangeList o;
01774       Set::LubRanges<Set::SetView> n;
01775     public:
01777 
01778 
01779       Lub(RangeList* o, Set::SetView n);
01781     };
01782     Lub _lub;
01784 
01785 
01786     SetTraceDelta(Set::SetTraceView o, Set::SetView n, const Delta& d);
01788 
01789 
01790 
01791     Glb& glb(void);
01793     Lub& lub(void);
01795   };
01796 
01797 }
01798 
01799 #include <gecode/set/trace/delta.hpp>
01800 
01801 #include <gecode/set/trace/traits.hpp>
01802 
01803 namespace Gecode {
01804 
01809   typedef ViewTracer<Set::SetView> SetTracer;
01814   typedef ViewTraceRecorder<Set::SetView> SetTraceRecorder;
01815 
01820   class GECODE_SET_EXPORT StdSetTracer : public SetTracer {
01821   protected:
01823     std::ostream& os;
01824   public:
01826     StdSetTracer(std::ostream& os0 = std::cerr);
01828     virtual void init(const Space& home, const SetTraceRecorder& t);
01830     virtual void prune(const Space& home, const SetTraceRecorder& t,
01831                        const ViewTraceInfo& vti, int i, SetTraceDelta& d);
01833     virtual void fix(const Space& home, const SetTraceRecorder& t);
01835     virtual void fail(const Space& home, const SetTraceRecorder& t);
01837     virtual void done(const Space& home, const SetTraceRecorder& t);
01839     static StdSetTracer def;
01840   };
01841 
01842 
01847   GECODE_SET_EXPORT void
01848   trace(Home home, const SetVarArgs& x,
01849         TraceFilter tf,
01850         int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
01851         SetTracer& t = StdSetTracer::def);
01856   void
01857   trace(Home home, const SetVarArgs& x,
01858         int te = (TE_INIT | TE_PRUNE | TE_FIX | TE_FAIL | TE_DONE),
01859         SetTracer& t = StdSetTracer::def);
01860 
01861 }
01862 
01863 #include <gecode/set/trace.hpp>
01864 
01865 #endif
01866 
01867 // IFDEF: GECODE_HAS_SET_VARS
01868 // STATISTICS: set-post