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

card.icc

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  *     Gabor Szokoli <szokoli@gecode.org>
00007  *
00008  *  Copyright:
00009  *     Guido Tack, 2004
00010  *     Christian Schulte, 2004
00011  *     Gabor Szokoli, 2004
00012  *
00013  *  Last modified:
00014  *     $Date: 2008-02-06 18:48:22 +0100 (Wed, 06 Feb 2008) $ by $Author: schulte $
00015  *     $Revision: 6102 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 #include "gecode/set.hh"
00043 #include "gecode/int.hh"
00044 
00045 namespace Gecode { namespace Set { namespace Int {
00046 
00047   template <class View>
00048   forceinline
00049   Card<View>::Card(Space* home, View y0, Gecode::Int::IntView y1)
00050     : IntSetPropagator<View,PC_SET_CARD,
00051                        Gecode::Int::PC_INT_BND> (home, y0, y1) {}
00052 
00053   template <class View>
00054   forceinline ExecStatus
00055   Card<View>::post(Space* home, View x0, Gecode::Int::IntView x1) {
00056     GECODE_ME_CHECK(x1.gq(home,0));
00057     GECODE_ME_CHECK(x0.cardMax(home, Gecode::Int::Limits::max));
00058     (void) new (home) Card(home,x0,x1);
00059     return ES_OK;
00060   }
00061 
00062   template <class View>
00063   forceinline
00064   Card<View>::Card(Space* home, bool share, Card& p)
00065     : IntSetPropagator<View,PC_SET_CARD,
00066                        Gecode::Int::PC_INT_BND> (home, share, p) {}
00067 
00068   template <class View>
00069   Actor*
00070   Card<View>::copy(Space* home, bool share) {
00071    return new (home) Card(home,share,*this);
00072   }
00073 
00074   template <class View>
00075   Support::Symbol
00076   Card<View>::ati(void) {
00077    return Reflection::mangle<View>("Gecode::Set::Int::Card");
00078   }
00079 
00080   template <class View>
00081   Reflection::ActorSpec
00082   Card<View>::spec(const Space* home, Reflection::VarMap& m) const {
00083    return IntSetPropagator<View,PC_SET_CARD,Gecode::Int::PC_INT_BND>
00084      ::spec(home, m, ati());
00085   }
00086 
00087   template <class View>
00088   ExecStatus
00089   Card<View>::propagate(Space* home, ModEventDelta) {
00090    int x1min, x1max;
00091    do {
00092      x1min = x1.min();
00093      x1max = x1.max();
00094      GECODE_ME_CHECK(x0.cardMin(home,x1min));
00095      GECODE_ME_CHECK(x0.cardMax(home,x1max));
00096      GECODE_ME_CHECK(x1.gq(home,(int)x0.cardMin()));
00097      GECODE_ME_CHECK(x1.lq(home,(int)x0.cardMax()));
00098    } while (x1.min() > x1min || x1.max() < x1max);
00099    if (x1.assigned())
00100      return ES_SUBSUMED(this,home);
00101    return ES_FIX;
00102   }
00103 
00104   template <class View>
00105   void
00106   Card<View>::post(Space* home, Reflection::VarMap& vars,
00107                    const Reflection::ActorSpec& spec) {
00108     spec.checkArity(2);
00109     View x0(home, vars, spec[0]);
00110     Gecode::Int::IntView x1(home, vars, spec[1]);
00111     (void) new (home) Card<View>(home,x0,x1);
00112   }
00113 
00114 }}}
00115 
00116 // STATISTICS: set-prop