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

eq.hpp

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  *
00007  *  Contributing authors:
00008  *     Gabor Szokoli <szokoli@gecode.org>
00009  *
00010  *  Copyright:
00011  *     Guido Tack, 2004
00012  *     Christian Schulte, 2004
00013  *     Gabor Szokoli, 2004
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 namespace Gecode { namespace Set { namespace Rel {
00041 
00042   template<class View0, class View1>
00043   forceinline
00044   Eq<View0,View1>::Eq(Home home, View0 x, View1 y)
00045     : MixBinaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY>(home,x,y) {}
00046 
00047   template<class View0, class View1>
00048   forceinline
00049   Eq<View0,View1>::Eq(Space& home, Eq& p)
00050     : MixBinaryPropagator<View0,PC_SET_ANY,View1,PC_SET_ANY>(home,p) {}
00051 
00052   template<class View0, class View1>
00053   ExecStatus
00054   Eq<View0,View1>::post(Home home, View0 x, View1 y) {
00055     if (!same(x,y))
00056       (void) new (home) Eq(home,x,y);
00057     return ES_OK;
00058   }
00059 
00060   template<class View0, class View1>
00061   Actor*
00062   Eq<View0,View1>::copy(Space& home) {
00063     return new (home) Eq(home,*this);
00064   }
00065 
00066   template<class View0, class View1>
00067   ExecStatus
00068   Eq<View0,View1>::propagate(Space& home, const ModEventDelta& med) {
00069 
00070     ModEvent me0 = View0::me(med);
00071     ModEvent me1 = View1::me(med);
00072 
00073     Region r;
00074 
00075     if (testSetEventLB(me0,me1)) {
00076       GlbRanges<View0> x0lb(x0);
00077       GlbRanges<View1> x1lb(x1);
00078       Iter::Ranges::Union<GlbRanges<View0>,GlbRanges<View1> > lbu(x0lb,x1lb);
00079       Iter::Ranges::Cache lbuc(r,lbu);
00080       GECODE_ME_CHECK(x0.includeI(home,lbuc));
00081       lbuc.reset();
00082       GECODE_ME_CHECK(x1.includeI(home,lbuc));
00083     }
00084 
00085     if (testSetEventUB(me0,me1)) {
00086       LubRanges<View0> x0ub(x0);
00087       LubRanges<View1> x1ub(x1);
00088       Iter::Ranges::Inter<LubRanges<View0>,LubRanges<View1> > ubi(x0ub,x1ub);
00089       Iter::Ranges::Cache ubic(r,ubi);
00090       GECODE_ME_CHECK(x0.intersectI(home,ubic));
00091       ubic.reset();
00092       GECODE_ME_CHECK(x1.intersectI(home,ubic));
00093     }
00094 
00095     if (testSetEventCard(me0,me1)) {
00096       unsigned int max = std::min(x0.cardMax(),x1.cardMax());
00097       unsigned int min = std::max(x0.cardMin(),x1.cardMin());
00098       GECODE_ME_CHECK(x0.cardMax(home,max));
00099       GECODE_ME_CHECK(x1.cardMax(home,max));
00100       GECODE_ME_CHECK(x0.cardMin(home,min));
00101       GECODE_ME_CHECK(x1.cardMin(home,min));
00102     }
00103 
00104     if (x0.assigned()) {
00105       assert (x1.assigned());
00106       return home.ES_SUBSUMED(*this);
00107     }
00108     return shared(x0,x1) ? ES_NOFIX : ES_FIX;
00109   }
00110 
00111 }}}
00112 
00113 // STATISTICS: set-prop