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

select-view.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  *
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  *  Last modified:
00016  *     $Date: 2008-01-31 18:29:16 +0100 (Thu, 31 Jan 2008) $ by $Author: tack $
00017  *     $Revision: 6017 $
00018  *
00019  *  This file is part of Gecode, the generic constraint
00020  *  development environment:
00021  *     http://www.gecode.org
00022  *
00023  *  Permission is hereby granted, free of charge, to any person obtaining
00024  *  a copy of this software and associated documentation files (the
00025  *  "Software"), to deal in the Software without restriction, including
00026  *  without limitation the rights to use, copy, modify, merge, publish,
00027  *  distribute, sublicense, and/or sell copies of the Software, and to
00028  *  permit persons to whom the Software is furnished to do so, subject to
00029  *  the following conditions:
00030  *
00031  *  The above copyright notice and this permission notice shall be
00032  *  included in all copies or substantial portions of the Software.
00033  *
00034  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00035  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00036  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00037  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00038  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00039  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00040  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00041  *
00042  */
00043 
00044 namespace Gecode { namespace Set { namespace Branch {
00045 
00046   forceinline ViewSelStatus
00047   ByNone::init(const Space*, SetView) {
00048     return VSS_COMMIT;
00049   }
00050   forceinline ViewSelStatus
00051   ByNone::select(const Space*, SetView) {
00052     GECODE_NEVER;
00053     return VSS_NONE;
00054   }
00055   inline Support::Symbol
00056   ByNone::type(void) {
00057     return Support::Symbol("Gecode::Set::Branch::ByNone");
00058   }
00059 
00060   forceinline ViewSelStatus
00061   ByMinCard::init(const Space*, SetView x) { 
00062     minCard = x.unknownSize();
00063     return (minCard == 1) ? VSS_COMMIT : VSS_SELECT;
00064   }
00065   forceinline ViewSelStatus
00066   ByMinCard::select(const Space*, SetView x) {
00067     unsigned int us = x.unknownSize();
00068     if (us < minCard) {
00069       minCard = us;
00070       return (minCard == 1) ? VSS_COMMIT : VSS_SELECT;
00071     }
00072     return VSS_NONE;
00073   }
00074   inline Support::Symbol
00075   ByMinCard::type(void) {
00076     return Support::Symbol("Gecode::Set::Branch::ByMinCard");
00077   }
00078 
00079   forceinline ViewSelStatus
00080   ByMaxCard::init(const Space*, SetView x) { 
00081     maxCard = x.unknownSize();
00082     return VSS_SELECT;
00083   }
00084   forceinline ViewSelStatus
00085   ByMaxCard::select(const Space*, SetView x) {
00086     unsigned int us = x.unknownSize();
00087     if (us > maxCard) {
00088       maxCard = us; return VSS_SELECT;
00089     }
00090     return VSS_NONE;
00091   }
00092   inline Support::Symbol
00093   ByMaxCard::type(void) {
00094     return Support::Symbol("Gecode::Set::Branch::ByMaxCard");
00095   }
00096 
00097   forceinline ViewSelStatus
00098   ByMinUnknown::init(const Space*, SetView x) {
00099     UnknownRanges<SetView> unknown(x);
00100     minUnknown = unknown.min();
00101     return VSS_SELECT;
00102   }
00103   forceinline ViewSelStatus
00104   ByMinUnknown::select(const Space*, SetView x) {
00105     UnknownRanges<SetView> unknown(x);
00106     int um = unknown.min();
00107     if (um < minUnknown) {
00108       minUnknown = um; return VSS_SELECT;
00109     }
00110     return VSS_NONE;
00111   }
00112   inline Support::Symbol
00113   ByMinUnknown::type(void) {
00114     return Support::Symbol("Gecode::Set::Branch::ByMinUnknown");
00115   }
00116 
00117   forceinline ViewSelStatus
00118   ByMaxUnknown::init(const Space*, SetView x) {
00119     UnknownRanges<SetView> unknown(x);
00120     do {
00121       maxUnknown = unknown.max();
00122       ++unknown;
00123     } while(unknown());
00124     return VSS_SELECT;
00125   }
00126   forceinline ViewSelStatus
00127   ByMaxUnknown::select(const Space*, SetView x) {
00128     UnknownRanges<SetView> unknown(x);
00129     int um = 0;
00130     assert(unknown());
00131     do {
00132       um = unknown.max();
00133       ++unknown;
00134     } while(unknown());
00135     if (um > maxUnknown) {
00136       maxUnknown = um; return VSS_SELECT;
00137     }
00138     return VSS_NONE;
00139   }
00140   inline Support::Symbol
00141   ByMaxUnknown::type(void) {
00142     return Support::Symbol("Gecode::Set::Branch::ByMaxUnknown");
00143   }
00144 
00145 }}}
00146 
00147 // STATISTICS: set-branch
00148