Generated on Mon Aug 25 11:35:33 2008 for Gecode by doxygen 1.5.6

dom.cc

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  *
00006  *  Copyright:
00007  *     Christian Schulte, 2004
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-02-18 08:02:14 +0100 (Mon, 18 Feb 2008) $ by $Author: schulte $
00011  *     $Revision: 6199 $
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/int/dom.hh"
00040 
00041 namespace Gecode {
00042 
00043   using namespace Int;
00044 
00045   void
00046   dom(Space* home, IntVar x, int min, int max, IntConLevel, PropKind) {
00047     Limits::check(min,"Int::dom");
00048     Limits::check(max,"Int::dom");
00049     if (home->failed()) return;
00050     IntView xv(x);
00051     GECODE_ME_FAIL(home,xv.gq(home,min));
00052     GECODE_ME_FAIL(home,xv.lq(home,max));
00053   }
00054 
00055   void
00056   dom(Space* home, const IntVarArgs& x, int min, int max, IntConLevel, PropKind) {
00057     Limits::check(min,"Int::dom");
00058     Limits::check(max,"Int::dom");
00059     if (home->failed()) return;
00060     for (int i=x.size(); i--; ) {
00061       IntView xv(x[i]);
00062       GECODE_ME_FAIL(home,xv.gq(home,min));
00063       GECODE_ME_FAIL(home,xv.lq(home,max));
00064     }
00065   }
00066 
00067   void
00068   dom(Space* home, IntVar x, const IntSet& is, IntConLevel, PropKind) {
00069     Limits::check(is.min(),"Int::dom");
00070     Limits::check(is.max(),"Int::dom");
00071     if (home->failed()) return;
00072     IntView xv(x);
00073     IntSetRanges ris(is);
00074     GECODE_ME_FAIL(home,xv.inter_r(home,ris,false));
00075   }
00076 
00077   void
00078   dom(Space* home, const IntVarArgs& x, const IntSet& is, IntConLevel, PropKind) {
00079     Limits::check(is.min(),"Int::dom");
00080     Limits::check(is.max(),"Int::dom");
00081     if (home->failed()) return;
00082     for (int i = x.size(); i--; ) {
00083       IntSetRanges ris(is);
00084       IntView xv(x[i]);
00085       GECODE_ME_FAIL(home,xv.inter_r(home,ris,false));
00086     }
00087   }
00088 
00089   void
00090   dom(Space* home, IntVar x, int min, int max, BoolVar b, IntConLevel, 
00091       PropKind) {
00092     Limits::check(min,"Int::dom");
00093     Limits::check(max,"Int::dom");
00094     if (home->failed()) return;
00095     GECODE_ES_FAIL(home,Dom::ReRange<IntView>::post(home,x,min,max,b));
00096   }
00097 
00098 
00099   void
00100   dom(Space* home, IntVar x, const IntSet& is, BoolVar b, IntConLevel, 
00101       PropKind) {
00102     Limits::check(is.min(),"Int::dom");
00103     Limits::check(is.max(),"Int::dom");
00104     if (home->failed()) return;
00105     GECODE_ES_FAIL(home,Dom::ReIntSet<IntView>::post(home,x,is,b));
00106   }
00107 
00108   namespace {
00109     GECODE_REGISTER1(Dom::ReRange<IntView>);
00110     GECODE_REGISTER1(Dom::ReIntSet<IntView>);
00111   }
00112 
00113 }
00114 
00115 // STATISTICS: int-post
00116