Generated on Tue May 22 09:39:59 2018 for Gecode by doxygen 1.6.3

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  *     Linnea Ingmar <linnea.ingmar@hotmail.com>
00005  *     Mikael Lagerkvist <lagerkvist@gecode.org>
00006  *     Christian Schulte <schulte@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Linnea Ingmar, 2017
00010  *     Mikael Lagerkvist, 2007
00011  *     Christian Schulte, 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 #include <gecode/int/extensional.hh>
00039 
00040 namespace Gecode {
00041 
00042   void
00043   extensional(Home home, const IntVarArgs& x, DFA dfa,
00044               IntPropLevel) {
00045     using namespace Int;
00046     if (x.same())
00047       throw ArgumentSame("Int::extensional");
00048     GECODE_POST;
00049     GECODE_ES_FAIL(Extensional::post_lgp(home,x,dfa));
00050   }
00051 
00052   void
00053   extensional(Home home, const BoolVarArgs& x, DFA dfa,
00054               IntPropLevel) {
00055     using namespace Int;
00056     if (x.same())
00057       throw ArgumentSame("Int::extensional");
00058     GECODE_POST;
00059     GECODE_ES_FAIL(Extensional::post_lgp(home,x,dfa));
00060   }
00061 
00062   void
00063   extensional(Home home, const IntVarArgs& x, const TupleSet& t,
00064               IntPropLevel) {
00065     using namespace Int;
00066     if (!t.finalized())
00067       throw NotYetFinalized("Int::extensional");
00068     if (t.arity() != x.size())
00069       throw ArgumentSizeMismatch("Int::extensional");
00070     GECODE_POST;
00071 
00072     if (t.tuples()==0) {
00073       if (x.size()!=0) {
00074         home.fail();
00075       }
00076       return;
00077     }
00078 
00079     // Construct view array
00080     ViewArray<IntView> xv(home,x);
00081     GECODE_ES_FAIL(Extensional::postcompact<IntView>(home,xv,t));
00082   }
00083 
00084   void
00085   extensional(Home home, const BoolVarArgs& x, const TupleSet& t,
00086               IntPropLevel) {
00087     using namespace Int;
00088     if (!t.finalized())
00089       throw NotYetFinalized("Int::extensional");
00090     if (t.arity() != x.size())
00091       throw ArgumentSizeMismatch("Int::extensional");
00092     if ((t.min() < 0) || (t.max() > 1))
00093       throw NotZeroOne("Int::extensional");
00094     GECODE_POST;
00095 
00096     if (t.tuples()==0) {
00097       if (x.size()!=0) {
00098         home.fail();
00099       }
00100       return;
00101     }
00102 
00103     // Construct view array
00104     ViewArray<BoolView> xv(home,x);
00105     GECODE_ES_FAIL(Extensional::postcompact<BoolView>(home,xv,t));
00106   }
00107 
00108 }
00109 
00110 // STATISTICS: int-post