Generated on Wed Jan 4 17:49:08 2006 for Gecode by doxygen 1.4.6

bool.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2002
00007  *
00008  *  Last modified:
00009  *     $Date: 2005-10-27 18:45:00 +0200 (Thu, 27 Oct 2005) $ by $Author: schulte $
00010  *     $Revision: 2419 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 #include "int/bool.hh"
00023 
00024 namespace Gecode {
00025 
00026   using namespace Int;
00027 
00028   void
00029   bool_not(Space* home, BoolVar b0, BoolVar b1, IntConLevel) {
00030     if (home->failed()) return;
00031     NegBoolView n1(b1);
00032     if (Bool::Eq<BoolView,NegBoolView>::post(home,b0,n1) == ES_FAILED)
00033       home->fail();
00034   }
00035   void
00036   bool_eq(Space* home, BoolVar b0, BoolVar b1, IntConLevel) {
00037     if (home->failed()) return;
00038     if (Bool::Eq<BoolView,BoolView>::post(home,b0,b1) == ES_FAILED)
00039       home->fail();
00040   }
00041   void
00042   bool_and(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
00043     if (home->failed()) return;
00044     if (Bool::And<BoolView,BoolView,BoolView>::post(home,b0,b1,b2)
00045         == ES_FAILED)
00046       home->fail();
00047   }
00048   void
00049   bool_or(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
00050     if (home->failed()) return;
00051     NegBoolView n0(b0); NegBoolView n1(b1); NegBoolView n2(b2);
00052     if (Bool::And<NegBoolView,NegBoolView,NegBoolView>::post(home,n0,n1,n2)
00053         == ES_FAILED)
00054       home->fail();
00055   }
00056   void
00057   bool_imp(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
00058     if (home->failed()) return;
00059     NegBoolView n1(b1); NegBoolView n2(b2);
00060     if (Bool::And<BoolView,NegBoolView,NegBoolView>::post(home,b0,n1,n2)
00061         == ES_FAILED)
00062       home->fail();
00063   }
00064   void
00065   bool_eqv(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
00066     if (home->failed()) return;
00067     if (Bool::Eqv<BoolView,BoolView,BoolView>::post(home,b0,b1,b2)
00068         == ES_FAILED)
00069       home->fail();
00070   }
00071   void
00072   bool_xor(Space* home, BoolVar b0, BoolVar b1, BoolVar b2, IntConLevel) {
00073     if (home->failed()) return;
00074     NegBoolView n2(b2);
00075     if (Bool::Eqv<BoolView,BoolView,NegBoolView>::post(home,b0,b1,n2)
00076         == ES_FAILED)
00077       home->fail();
00078   }
00079   void
00080   bool_and(Space* home, const BoolVarArgs& b, BoolVar c, IntConLevel) {
00081     if (home->failed()) return;
00082     ViewArray<BoolView> x(home,b);
00083     GECODE_ES_FAIL(home,Bool::NaryAnd<BoolView>::post(home,x,c));
00084   }
00085   void
00086   bool_or(Space* home, const BoolVarArgs& b, BoolVar c, IntConLevel) {
00087     if (home->failed()) return;
00088     ViewArray<NegBoolView> x(home,b.size());
00089     for (int i=b.size(); i--; ) {
00090       NegBoolView nb(b[i]); x[i]=nb;
00091     }
00092     NegBoolView nc(c);
00093     GECODE_ES_FAIL(home,Bool::NaryAnd<NegBoolView>::post(home,x,nc));
00094   }
00095 
00096 }
00097 
00098 
00099 // STATISTICS: int-post
00100