Generated on Thu Apr 11 13:59:20 2019 for Gecode by doxygen 1.6.3

set.cpp

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  *     Gabor Szokoli <szokoli@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Guido Tack, 2004
00010  *     Christian Schulte, 2004
00011  *     Gabor Szokoli, 2004
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 
00039 #include <gecode/set.hh>
00040 
00041 namespace Gecode {
00042 
00043   SetVar::SetVar(Space& home)
00044     : VarImpVar<Set::SetVarImp>(new (home) Set::SetVarImp(home)) {}
00045 
00046   SetVar::SetVar(Space& home,int lbMin,int lbMax,int ubMin,int ubMax,
00047                  unsigned int minCard, unsigned int maxCard)
00048     : VarImpVar<Set::SetVarImp>(new (home) Set::SetVarImp(home,lbMin,lbMax,
00049                                                           ubMin,ubMax,
00050                                                           minCard,maxCard)) {
00051     Set::Limits::check(lbMin,"SetVar::SetVar");
00052     Set::Limits::check(lbMax,"SetVar::SetVar");
00053     Set::Limits::check(ubMin,"SetVar::SetVar");
00054     Set::Limits::check(ubMax,"SetVar::SetVar");
00055     Set::Limits::check(maxCard,"SetVar::SetVar");
00056     if (minCard > maxCard || minCard > lubSize() || maxCard < glbSize() ||
00057         lbMin < ubMin || lbMax > ubMax)
00058       throw Set::VariableEmptyDomain("SetVar::SetVar");
00059   }
00060 
00061   SetVar::SetVar(Space& home, const IntSet& glb,int ubMin,int ubMax,
00062                  unsigned int minCard, unsigned int maxCard)
00063     : VarImpVar<Set::SetVarImp>(new (home) Set::SetVarImp(home,glb,ubMin,ubMax,
00064                                                           minCard,maxCard)) {
00065     Set::Limits::check(glb,"SetVar::SetVar");
00066     Set::Limits::check(ubMin,"SetVar::SetVar");
00067     Set::Limits::check(ubMax,"SetVar::SetVar");
00068     Set::Limits::check(maxCard,"SetVar::SetVar");
00069     if (minCard > maxCard || minCard > lubSize() || maxCard < glbSize() ||
00070         glb.min() < ubMin || glb.max() > ubMax)
00071       throw Set::VariableEmptyDomain("SetVar::SetVar");
00072   }
00073 
00074   SetVar::SetVar(Space& home,int lbMin,int lbMax,const IntSet& lub,
00075                  unsigned int minCard, unsigned int maxCard)
00076     : VarImpVar<Set::SetVarImp>(new (home) Set::SetVarImp(home,lbMin,lbMax,lub,
00077                                                           minCard,maxCard)) {
00078     Set::Limits::check(lbMin,"SetVar::SetVar");
00079     Set::Limits::check(lbMax,"SetVar::SetVar");
00080     Set::Limits::check(lub,"SetVar::SetVar");
00081     Set::Limits::check(maxCard,"SetVar::SetVar");
00082     Iter::Ranges::Singleton glbr(lbMin,lbMax);
00083     IntSetRanges lubr(lub);
00084     if (minCard > maxCard || minCard > lubSize() || maxCard < glbSize() ||
00085         !Iter::Ranges::subset(glbr,lubr))
00086       throw Set::VariableEmptyDomain("SetVar::SetVar");
00087   }
00088 
00089   SetVar::SetVar(Space& home,
00090                  const IntSet& glb, const IntSet& lub,
00091                  unsigned int minCard, unsigned int maxCard)
00092     : VarImpVar<Set::SetVarImp>(new (home) Set::SetVarImp(home,glb,lub,minCard,
00093                                                           maxCard)) {
00094     Set::Limits::check(glb,"SetVar::SetVar");
00095     Set::Limits::check(lub,"SetVar::SetVar");
00096     Set::Limits::check(maxCard,"SetVar::SetVar");
00097     IntSetRanges glbr(glb);
00098     IntSetRanges lubr(lub);
00099     if (minCard > maxCard || minCard > lubSize() || maxCard < glbSize() ||
00100         !Iter::Ranges::subset(glbr,lubr))
00101       throw Set::VariableEmptyDomain("SetVar::SetVar");
00102   }
00103 
00104 }
00105 
00106 // STATISTICS: set-var
00107