/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Patrick Pekczynski * * Copyright: * Patrick Pekczynski, 2006 * * Last modified: * $Date: 2008-02-16 10:42:26 +0100 (Sat, 16 Feb 2008) $ by $Author: tack $ * $Revision: 6185 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ namespace Gecode { namespace CpltSet { namespace Branch { template forceinline int ValMinUnknown::val(const Space*, CpltSetView x) const { UnknownValues unknown(x); int v = unknown.val(); return v; } template forceinline ModEvent ValMinUnknown::tell(Space* home, unsigned int a, CpltSetView x, int v) { return (a == (int) exclude) ? x.include(home,v) : x.exclude(home,v); } template inline Support::Symbol ValMinUnknown::type(void) { return Support::Symbol("CpltSet::Branch::ValMinUnknown"); } template forceinline void ValMinUnknown::branchingSpec(const Space* home, Reflection::VarMap& m, Reflection::BranchingSpec& bs, int alt, CpltSetView x, int n) const { assert(alt <= 2); Reflection::ArrayArg* a0 = Reflection::Arg::newArray(2); std::stringstream s; s << n; if (exclude) { (*a0)[0] = Reflection::Arg::newString((s.str()+" not in ").c_str()); } else { (*a0)[0] = Reflection::Arg::newString((s.str()+" in ").c_str()); } (*a0)[1] = x.spec(home, m); bs[0] = a0; if (alt == 2) { Reflection::ArrayArg* a1 = Reflection::Arg::newArray(2); if (exclude) { (*a1)[0] = Reflection::Arg::newString((s.str()+" in ").c_str()); } else { (*a1)[0] = Reflection::Arg::newString((s.str()+" not in ").c_str()); } (*a1)[1] = x.spec(home, m); bs[1] = a1; } } template forceinline int ValMaxUnknown::val(const Space*, CpltSetView x) const { int maxElem = 0; Set::UnknownRanges unknown(x); while (unknown()) { maxElem = unknown.max(); ++unknown; } return maxElem; } template forceinline ModEvent ValMaxUnknown::tell(Space* home, unsigned int a, CpltSetView x, int v) { return (a == (int) exclude) ? x.include(home,v) : x.exclude(home,v); } template inline Support::Symbol ValMaxUnknown::type(void) { return Support::Symbol("CpltSet::Branch::ValMaxUnknown"); } template forceinline void ValMaxUnknown::branchingSpec(const Space* home, Reflection::VarMap& m, Reflection::BranchingSpec& bs, int alt, CpltSetView x, int n) const { assert(alt <= 2); Reflection::ArrayArg* a0 = Reflection::Arg::newArray(2); std::stringstream s; s << n; if (exclude) { (*a0)[0] = Reflection::Arg::newString((s.str()+" not in ").c_str()); } else { (*a0)[0] = Reflection::Arg::newString((s.str()+" in ").c_str()); } (*a0)[1] = x.spec(home, m); bs[0] = a0; if (alt == 2) { Reflection::ArrayArg* a1 = Reflection::Arg::newArray(2); if (exclude) { (*a1)[0] = Reflection::Arg::newString((s.str()+" in ").c_str()); } else { (*a1)[0] = Reflection::Arg::newString((s.str()+" not in ").c_str()); } (*a1)[1] = x.spec(home, m); bs[1] = a1; } } template static void create(Space* home, ViewArray& x, CpltSetValBranch vals) { switch (vals) { case CPLTSET_VAL_MIN_UNKNOWN: (void) new (home) ViewValBranching >(home,x); break; case CPLTSET_VAL_MIN_UNKNOWN_EX_FIRST: (void) new (home) ViewValBranching >(home,x); break; case CPLTSET_VAL_MAX_UNKNOWN: (void) new (home) ViewValBranching >(home,x); break; case CPLTSET_VAL_MAX_UNKNOWN_EX_FIRST: (void) new (home) ViewValBranching >(home,x); break; default: throw UnknownBranching("CpltSet::branch"); } } }}} // STATISTICS: cpltset-branch