/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Christian Schulte * * Copyright: * Christian Schulte, 2002 * * Last modified: * $Date: 2008-02-28 14:12:40 +0100 (Thu, 28 Feb 2008) $ by $Author: tack $ * $Revision: 6344 $ * * 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. * */ #include "gecode/int/branch.hh" namespace Gecode { using namespace Int; void branch(Space* home, const IntVarArgs& x, IntVarBranch vars, IntValBranch vals) { ViewArray xv(home,x); switch (vars) { case INT_VAR_NONE: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_MIN_MIN: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_MIN_MAX: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_MAX_MIN: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_MAX_MAX: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_SIZE_MIN: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_SIZE_MAX: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_DEGREE_MIN: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_DEGREE_MAX: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_SIZE_DEGREE_MIN: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_SIZE_DEGREE_MAX: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_REGRET_MIN_MIN: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_REGRET_MIN_MAX: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_REGRET_MAX_MIN: if (home->failed()) return; Branch::create(home,xv,vals); break; case INT_VAR_REGRET_MAX_MAX: if (home->failed()) return; Branch::create(home,xv,vals); break; default: throw UnknownBranching("Int::branch"); } } void branch(Space* home, const BoolVarArgs& x, IntVarBranch vars, IntValBranch vals) { ViewArray xv(home,x); switch (vars) { case INT_VAR_NONE: case INT_VAR_MIN_MIN: case INT_VAR_MIN_MAX: case INT_VAR_MAX_MIN: case INT_VAR_MAX_MAX: case INT_VAR_SIZE_MIN: case INT_VAR_SIZE_MAX: case INT_VAR_REGRET_MIN_MIN: case INT_VAR_REGRET_MIN_MAX: case INT_VAR_REGRET_MAX_MIN: case INT_VAR_REGRET_MAX_MAX: switch (vals) { case INT_VAL_MIN: case INT_VAL_MED: case INT_VAL_SPLIT_MIN: if (home->failed()) return; (void) new (home) ViewValBranching, Branch::ValZeroOne >(home,xv); break; case INT_VAL_MAX: case INT_VAL_SPLIT_MAX: if (home->failed()) return; (void) new (home) ViewValBranching, Branch::ValOneZero >(home,xv); break; default: throw UnknownBranching("Int::branch"); } break; case INT_VAR_DEGREE_MIN: case INT_VAR_SIZE_DEGREE_MAX: switch (vals) { case INT_VAL_MIN: case INT_VAL_MED: case INT_VAL_SPLIT_MIN: if (home->failed()) return; (void) new (home) ViewValBranching, Branch::ValZeroOne >(home,xv); break; case INT_VAL_MAX: case INT_VAL_SPLIT_MAX: if (home->failed()) return; (void) new (home) ViewValBranching, Branch::ValOneZero >(home,xv); break; default: throw UnknownBranching("Int::branch"); } break; case INT_VAR_DEGREE_MAX: case INT_VAR_SIZE_DEGREE_MIN: switch (vals) { case INT_VAL_MIN: case INT_VAL_MED: case INT_VAL_SPLIT_MIN: if (home->failed()) return; (void) new (home) ViewValBranching, Branch::ValZeroOne >(home,xv); break; case INT_VAL_MAX: case INT_VAL_SPLIT_MAX: if (home->failed()) return; (void) new (home) ViewValBranching, Branch::ValOneZero >(home,xv); break; default: throw UnknownBranching("Int::branch"); } break; default: throw UnknownBranching("Int::branch"); } } void assign(Space* home, const IntVarArgs& x, IntAssign vals) { ViewArray xv(home,x); switch (vals) { case INT_ASSIGN_MIN: if (home->failed()) return; (void) new (home) ViewValAssignment >(home,xv); break; case INT_ASSIGN_MED: if (home->failed()) return; (void) new (home) ViewValAssignment >(home,xv); break; case INT_ASSIGN_MAX: if (home->failed()) return; (void) new (home) ViewValAssignment >(home,xv); break; default: throw UnknownBranching("Int::assign"); } } void assign(Space* home, const BoolVarArgs& x, IntAssign vals) { ViewArray xv(home,x); switch (vals) { case INT_ASSIGN_MIN: case INT_ASSIGN_MED: if (home->failed()) return; (void) new (home) ViewValAssignment >(home,xv); break; case INT_ASSIGN_MAX: if (home->failed()) return; (void) new (home) ViewValAssignment >(home,xv); break; default: throw UnknownBranching("Int::assign"); } } namespace Int { namespace Branch { template class SelView> /// Register reflection for branchings class Creator { public: Reflection::ActorRegistrar, Branch::ValMin > > r1; Reflection::ActorRegistrar, ValMed > > r2; Reflection::ActorRegistrar, ValMax > > r3; Reflection::ActorRegistrar, ValSplitMin > > r4; Reflection::ActorRegistrar, ValSplitMax > > r5; }; Creator c1; Creator c2; Creator c3; Creator c4; Creator c5; Creator c6; Creator c7; Creator c8; Creator c9; Creator c10; Creator c11; Creator c12; Creator c13; Reflection::ActorRegistrar,ValOneZero > > r1; Reflection::ActorRegistrar,ValZeroOne > > r2; Reflection::ActorRegistrar,ValOneZero > > r3; Reflection::ActorRegistrar,ValZeroOne > > r4; Reflection::ActorRegistrar,ValOneZero > > r5; Reflection::ActorRegistrar,ValZeroOne > > r6; Reflection::ActorRegistrar > > r7; Reflection::ActorRegistrar > > r8; Reflection::ActorRegistrar > > r9; Reflection::ActorRegistrar > > r10; Reflection::ActorRegistrar > > r11; }} } // STATISTICS: int-post