Generated on Wed Nov 1 15:04:40 2006 for Gecode by doxygen 1.4.5

imp.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2004
00008  *     Christian Schulte, 2004
00009  *
00010  *  Last modified:
00011  *     $Date: 2006-08-25 10:43:21 +0200 (Fri, 25 Aug 2006) $ by $Author: schulte $
00012  *     $Revision: 3568 $
00013  *
00014  *  This file is part of Gecode, the generic constraint
00015  *  development environment:
00016  *     http://www.gecode.org
00017  *
00018  *  See the file "LICENSE" for information on usage and
00019  *  redistribution of this file, and for a
00020  *     DISCLAIMER OF ALL WARRANTIES.
00021  *
00022  */
00023 
00024 #include "gecode/set.hh"
00025 
00026 #include "gecode/set/var/imp-body.icc"
00027 
00028 namespace Gecode { namespace Set {
00029 
00030   /*
00031    * "Standard" tell operations
00032    *
00033    */
00034   ModEvent
00035   SetVarImp::cardMin_full(Space* home,unsigned int newMin) {
00036     ModEvent me = ME_SET_CARD;
00037     if (_cardMin == _cardMax)
00038       me = checkLubCardAssigned(home,ME_SET_CARD);
00039     if (!me_failed(me))
00040       notify(home, me);
00041     return me;
00042   }
00043 
00044   ModEvent
00045   SetVarImp::cardMax_full(Space* home,unsigned int newMax) {
00046     ModEvent me = ME_SET_CARD;
00047     if (_cardMin == _cardMax)
00048       me = checkGlbCardAssigned(home,ME_SET_CARD);
00049     if (!me_failed(me))
00050       notify(home, me);
00051     return me;
00052   }
00053 
00054   ModEvent
00055   SetVarImp::processLubChange(Space* home) {
00056     if (!boundsConsistent()) {
00057       return ME_SET_FAILED;
00058     }
00059     ModEvent me;
00060     if (_cardMax > lub.size()) {
00061       _cardMax = lub.size();
00062       if (cardMin() > cardMax())
00063         return ME_SET_FAILED;
00064       if (assigned()) {
00065         lub.linkTo(home, glb);
00066         me = ME_SET_VAL;
00067       } else {
00068         me = checkLubCardAssigned(home, ME_SET_CLUB);
00069       }
00070     } else {
00071       me = checkLubCardAssigned(home, ME_SET_LUB);
00072     }
00073     if (!me_failed(me))
00074       notify(home, me);
00075     return me;
00076   }
00077 
00078   ModEvent
00079   SetVarImp::processGlbChange(Space* home) {
00080     if (!boundsConsistent())
00081       return ME_SET_FAILED;
00082     ModEvent me;
00083     if (_cardMin < glb.size()) {
00084       _cardMin = glb.size();
00085       if (cardMin() > cardMax())
00086         return ME_SET_FAILED;
00087       if (assigned()) {
00088         lub.linkTo(home, glb);
00089         me = ME_SET_VAL;
00090       } else {
00091         me = checkGlbCardAssigned(home, ME_SET_CGLB);
00092       }
00093     } else {
00094       me = checkGlbCardAssigned(home, ME_SET_GLB);
00095     }
00096     if (me!=ME_SET_FAILED)
00097       notify(home, me);
00098     return me;
00099   }
00100 
00101   /*
00102    * Copying variables
00103    *
00104    */
00105 
00106   forceinline
00107   SetVarImp::SetVarImp(Space* home, bool share, SetVarImp& x)
00108     : SetVarImpBase(home,share,x),
00109       _cardMin(x._cardMin), _cardMax(x._cardMax) {
00110     lub.update(home, x.lub);
00111     if (x.assigned()) {
00112       glb.linkTo(home,lub);
00113     } else {
00114       glb.update(home,x.glb);
00115     }
00116   }
00117 
00118 
00119   SetVarImp*
00120   SetVarImp::perform_copy(Space* home, bool share) {
00121     return new (home) SetVarImp(home,share,*this);
00122   }
00123 
00124 }}
00125 
00126 // STATISTICS: set-var
00127