/* * Main authors: * Guido Tack * Christian Schulte * * Contributing authors: * Gabor Szokoli * * Copyright: * Guido Tack, 2004 * Christian Schulte, 2004 * Gabor Szokoli, 2004 * * Last modified: * $Date: 2006-07-19 14:57:38 +0200 (Wed, 19 Jul 2006) $ by $Author: schulte $ * $Revision: 3413 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * See the file "LICENSE" for information on usage and * redistribution of this file, and for a * DISCLAIMER OF ALL WARRANTIES. * */ namespace Gecode { namespace Set { namespace Branch { forceinline ViewSelStatus ByNone::init(const Space*, SetView) { return VSS_COMMIT; } forceinline ViewSelStatus ByNone::select(const Space*, SetView) { GECODE_NEVER; return VSS_NONE; } forceinline ViewSelStatus ByMinCard::init(const Space*, SetView x) { minCard = x.unknownSize(); return (minCard == 1) ? VSS_COMMIT : VSS_SELECT; } forceinline ViewSelStatus ByMinCard::select(const Space*, SetView x) { unsigned int us = x.unknownSize(); if (us < minCard) { minCard = us; return (minCard == 1) ? VSS_COMMIT : VSS_SELECT; } return VSS_NONE; } forceinline ViewSelStatus ByMaxCard::init(const Space*, SetView x) { maxCard = x.unknownSize(); return VSS_SELECT; } forceinline ViewSelStatus ByMaxCard::select(const Space*, SetView x) { unsigned int us = x.unknownSize(); if (us > maxCard) { maxCard = us; return VSS_SELECT; } return VSS_NONE; } forceinline ViewSelStatus ByMinUnknown::init(const Space*, SetView x) { UnknownRanges unknown(x); minUnknown = unknown.min(); return VSS_SELECT; } forceinline ViewSelStatus ByMinUnknown::select(const Space*, SetView x) { UnknownRanges unknown(x); int um = unknown.min(); if (um < minUnknown) { minUnknown = um; return VSS_SELECT; } return VSS_NONE; } forceinline ViewSelStatus ByMaxUnknown::init(const Space*, SetView x) { UnknownRanges unknown(x); do { maxUnknown = unknown.max(); ++unknown; } while(unknown()); return VSS_SELECT; } forceinline ViewSelStatus ByMaxUnknown::select(const Space*, SetView x) { UnknownRanges unknown(x); int um = 0; assert(unknown()); do { um = unknown.max(); ++unknown; } while(unknown()); if (um > maxUnknown) { maxUnknown = um; return VSS_SELECT; } return VSS_NONE; } }}} // STATISTICS: set-branch