Generated on Mon Jul 6 18:09:09 2009 for Gecode by doxygen 1.5.9

extensional.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Mikael Lagerkvist <lagerkvist@gecode.org>
00005  *     Christian Schulte <schulte@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Mikael Lagerkvist, 2007
00009  *     Christian Schulte, 2004
00010  *
00011  *  Last modified:
00012  *     $Date: 2009-02-25 14:52:22 +0100 (Wed, 25 Feb 2009) $ by $Author: schulte $
00013  *     $Revision: 8296 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  Permission is hereby granted, free of charge, to any person obtaining
00020  *  a copy of this software and associated documentation files (the
00021  *  "Software"), to deal in the Software without restriction, including
00022  *  without limitation the rights to use, copy, modify, merge, publish,
00023  *  distribute, sublicense, and/or sell copies of the Software, and to
00024  *  permit persons to whom the Software is furnished to do so, subject to
00025  *  the following conditions:
00026  *
00027  *  The above copyright notice and this permission notice shall be
00028  *  included in all copies or substantial portions of the Software.
00029  *
00030  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00031  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00032  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00033  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00034  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00035  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00036  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00037  *
00038  */
00039 
00040 #include <gecode/int/extensional.hh>
00041 
00042 namespace Gecode {
00043 
00044   void
00045   extensional(Space& home, const IntVarArgs& x, DFA dfa,
00046               IntConLevel) {
00047     using namespace Int;
00048     if (x.same(home))
00049       throw ArgumentSame("Int::extensional");
00050     if (home.failed()) return;
00051     ViewArray<IntView> xv(home,x);
00052     GECODE_ES_FAIL(home,Extensional::post_lgp<IntView>(home,xv,dfa));
00053   }
00054 
00055   void
00056   extensional(Space& home, const BoolVarArgs& x, DFA dfa,
00057               IntConLevel) {
00058     using namespace Int;
00059     if (x.same(home))
00060       throw ArgumentSame("Int::extensional");
00061     if (home.failed()) return;
00062     ViewArray<BoolView> xv(home,x);
00063     GECODE_ES_FAIL(home,Extensional::post_lgp<BoolView>(home,xv,dfa));
00064   }
00065 
00066   void
00067   extensional(Space& home, const IntVarArgs& x, const TupleSet& t,
00068               ExtensionalPropKind epk, IntConLevel) {
00069     using namespace Int;
00070     if (!t.finalized())
00071       throw NotYetFinalized("Int::extensional");
00072     if (t.arity() != x.size())
00073       throw ArgumentSizeMismatch("Int::extensional");
00074     if (home.failed()) return;
00075 
00076     // Construct view array
00077     ViewArray<IntView> xv(home,x);
00078     switch (epk) {
00079     case EPK_SPEED:
00080       GECODE_ES_FAIL(home,(Extensional::Incremental<IntView>
00081                            ::post(home,xv,t)));
00082       break;
00083     default:
00084       if (x.same(home)) {
00085         GECODE_ES_FAIL(home,(Extensional::Basic<IntView,true>
00086                              ::post(home,xv,t)));
00087       } else {
00088         GECODE_ES_FAIL(home,(Extensional::Basic<IntView,false>
00089                              ::post(home,xv,t)));
00090       }
00091       break;
00092     }
00093   }
00094 
00095   void
00096   extensional(Space& home, const BoolVarArgs& x, const TupleSet& t,
00097               ExtensionalPropKind epk, IntConLevel) {
00098     using namespace Int;
00099     if (!t.finalized())
00100       throw NotYetFinalized("Int::extensional");
00101     if (t.arity() != x.size())
00102       throw ArgumentSizeMismatch("Int::extensional");
00103     if (home.failed()) return;
00104 
00105     // Construct view array
00106     ViewArray<BoolView> xv(home,x);
00107     switch (epk) {
00108     case EPK_SPEED:
00109       GECODE_ES_FAIL(home,(Extensional::Incremental<BoolView>
00110                            ::post(home,xv,t)));
00111       break;
00112     default:
00113       if (x.same(home)) {
00114         GECODE_ES_FAIL(home,(Extensional::Basic<BoolView,true>
00115                              ::post(home,xv,t)));
00116       } else {
00117         GECODE_ES_FAIL(home,(Extensional::Basic<BoolView,false>
00118                              ::post(home,xv,t)));
00119       }
00120       break;
00121     }
00122   }
00123 
00124 }
00125 
00126 // STATISTICS: int-post