view-sel.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2012
*
* 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 { namespace Int { namespace Branch {
ViewSel<IntView>*
viewsel(Space& home, const IntVarBranch& ivb) {
switch (ivb.select()) {
case IntVarBranch::SEL_NONE:
return new (home) ViewSelNone<IntView>(home,ivb);
case IntVarBranch::SEL_RND:
return new (home) ViewSelRnd<IntView>(home,ivb);
default: break;
}
if (ivb.tbl() != NULL) {
switch (ivb.select()) {
case IntVarBranch::SEL_MERIT_MIN:
return new (home) ViewSelMinTbl<MeritFunction<IntView>>(home,ivb);
case IntVarBranch::SEL_MERIT_MAX:
return new (home) ViewSelMaxTbl<MeritFunction<IntView>>(home,ivb);
case IntVarBranch::SEL_MIN_MIN:
return new (home) ViewSelMinTbl<MeritMin<IntView>>(home,ivb);
case IntVarBranch::SEL_MIN_MAX:
return new (home) ViewSelMaxTbl<MeritMin<IntView>>(home,ivb);
case IntVarBranch::SEL_MAX_MIN:
return new (home) ViewSelMinTbl<MeritMax<IntView>>(home,ivb);
case IntVarBranch::SEL_MAX_MAX:
return new (home) ViewSelMaxTbl<MeritMax<IntView>>(home,ivb);
case IntVarBranch::SEL_SIZE_MIN:
return new (home) ViewSelMinTbl<MeritSize<IntView>>(home,ivb);
case IntVarBranch::SEL_SIZE_MAX:
return new (home) ViewSelMaxTbl<MeritSize<IntView>>(home,ivb);
case IntVarBranch::SEL_DEGREE_MIN:
return new (home) ViewSelMinTbl<MeritDegree<IntView>>(home,ivb);
case IntVarBranch::SEL_DEGREE_MAX:
return new (home) ViewSelMaxTbl<MeritDegree<IntView>>(home,ivb);
case IntVarBranch::SEL_AFC_MIN:
return new (home) ViewSelMinTbl<MeritAFC<IntView>>(home,ivb);
case IntVarBranch::SEL_AFC_MAX:
return new (home) ViewSelMaxTbl<MeritAFC<IntView>>(home,ivb);
case IntVarBranch::SEL_ACTION_MIN:
return new (home) ViewSelMinTbl<MeritAction<IntView>>(home,ivb);
case IntVarBranch::SEL_ACTION_MAX:
return new (home) ViewSelMaxTbl<MeritAction<IntView>>(home,ivb);
case IntVarBranch::SEL_CHB_MIN:
return new (home) ViewSelMinTbl<MeritCHB<IntView>>(home,ivb);
case IntVarBranch::SEL_CHB_MAX:
return new (home) ViewSelMaxTbl<MeritCHB<IntView>>(home,ivb);
case IntVarBranch::SEL_DEGREE_SIZE_MIN:
return new (home) ViewSelMinTbl<MeritDegreeSize<IntView>>(home,ivb);
case IntVarBranch::SEL_DEGREE_SIZE_MAX:
return new (home) ViewSelMaxTbl<MeritDegreeSize<IntView>>(home,ivb);
case IntVarBranch::SEL_AFC_SIZE_MIN:
return new (home) ViewSelMinTbl<MeritAFCSize<IntView>>(home,ivb);
case IntVarBranch::SEL_AFC_SIZE_MAX:
return new (home) ViewSelMaxTbl<MeritAFCSize<IntView>>(home,ivb);
case IntVarBranch::SEL_ACTION_SIZE_MIN:
return new (home) ViewSelMinTbl<MeritActionSize<IntView>>(home,ivb);
case IntVarBranch::SEL_ACTION_SIZE_MAX:
return new (home) ViewSelMaxTbl<MeritActionSize<IntView>>(home,ivb);
case IntVarBranch::SEL_CHB_SIZE_MIN:
return new (home) ViewSelMinTbl<MeritCHBSize<IntView>>(home,ivb);
case IntVarBranch::SEL_CHB_SIZE_MAX:
return new (home) ViewSelMaxTbl<MeritCHBSize<IntView>>(home,ivb);
case IntVarBranch::SEL_REGRET_MIN_MIN:
return new (home) ViewSelMinTbl<MeritRegretMin<IntView>>(home,ivb);
case IntVarBranch::SEL_REGRET_MIN_MAX:
return new (home) ViewSelMaxTbl<MeritRegretMin<IntView>>(home,ivb);
case IntVarBranch::SEL_REGRET_MAX_MIN:
return new (home) ViewSelMinTbl<MeritRegretMax<IntView>>(home,ivb);
case IntVarBranch::SEL_REGRET_MAX_MAX:
return new (home) ViewSelMaxTbl<MeritRegretMax<IntView>>(home,ivb);
default:
throw UnknownBranching("Int::branch");
}
} else {
switch (ivb.select()) {
case IntVarBranch::SEL_MERIT_MIN:
return new (home) ViewSelMin<MeritFunction<IntView>>(home,ivb);
case IntVarBranch::SEL_MERIT_MAX:
return new (home) ViewSelMax<MeritFunction<IntView>>(home,ivb);
case IntVarBranch::SEL_MIN_MIN:
return new (home) ViewSelMin<MeritMin<IntView>>(home,ivb);
case IntVarBranch::SEL_MIN_MAX:
return new (home) ViewSelMax<MeritMin<IntView>>(home,ivb);
case IntVarBranch::SEL_MAX_MIN:
return new (home) ViewSelMin<MeritMax<IntView>>(home,ivb);
case IntVarBranch::SEL_MAX_MAX:
return new (home) ViewSelMax<MeritMax<IntView>>(home,ivb);
case IntVarBranch::SEL_SIZE_MIN:
return new (home) ViewSelMin<MeritSize<IntView>>(home,ivb);
case IntVarBranch::SEL_SIZE_MAX:
return new (home) ViewSelMax<MeritSize<IntView>>(home,ivb);
case IntVarBranch::SEL_DEGREE_MIN:
return new (home) ViewSelMin<MeritDegree<IntView>>(home,ivb);
case IntVarBranch::SEL_DEGREE_MAX:
return new (home) ViewSelMax<MeritDegree<IntView>>(home,ivb);
case IntVarBranch::SEL_AFC_MIN:
return new (home) ViewSelMin<MeritAFC<IntView>>(home,ivb);
case IntVarBranch::SEL_AFC_MAX:
return new (home) ViewSelMax<MeritAFC<IntView>>(home,ivb);
case IntVarBranch::SEL_ACTION_MIN:
return new (home) ViewSelMin<MeritAction<IntView>>(home,ivb);
case IntVarBranch::SEL_ACTION_MAX:
return new (home) ViewSelMax<MeritAction<IntView>>(home,ivb);
case IntVarBranch::SEL_CHB_MIN:
return new (home) ViewSelMin<MeritCHB<IntView>>(home,ivb);
case IntVarBranch::SEL_CHB_MAX:
return new (home) ViewSelMax<MeritCHB<IntView>>(home,ivb);
case IntVarBranch::SEL_DEGREE_SIZE_MIN:
return new (home) ViewSelMin<MeritDegreeSize<IntView>>(home,ivb);
case IntVarBranch::SEL_DEGREE_SIZE_MAX:
return new (home) ViewSelMax<MeritDegreeSize<IntView>>(home,ivb);
case IntVarBranch::SEL_AFC_SIZE_MIN:
return new (home) ViewSelMin<MeritAFCSize<IntView>>(home,ivb);
case IntVarBranch::SEL_AFC_SIZE_MAX:
return new (home) ViewSelMax<MeritAFCSize<IntView>>(home,ivb);
case IntVarBranch::SEL_ACTION_SIZE_MIN:
return new (home) ViewSelMin<MeritActionSize<IntView>>(home,ivb);
case IntVarBranch::SEL_ACTION_SIZE_MAX:
return new (home) ViewSelMax<MeritActionSize<IntView>>(home,ivb);
case IntVarBranch::SEL_CHB_SIZE_MIN:
return new (home) ViewSelMin<MeritCHBSize<IntView>>(home,ivb);
case IntVarBranch::SEL_CHB_SIZE_MAX:
return new (home) ViewSelMax<MeritCHBSize<IntView>>(home,ivb);
case IntVarBranch::SEL_REGRET_MIN_MIN:
return new (home) ViewSelMin<MeritRegretMin<IntView>>(home,ivb);
case IntVarBranch::SEL_REGRET_MIN_MAX:
return new (home) ViewSelMax<MeritRegretMin<IntView>>(home,ivb);
case IntVarBranch::SEL_REGRET_MAX_MIN:
return new (home) ViewSelMin<MeritRegretMax<IntView>>(home,ivb);
case IntVarBranch::SEL_REGRET_MAX_MAX:
return new (home) ViewSelMax<MeritRegretMax<IntView>>(home,ivb);
default:
throw UnknownBranching("Int::branch");
}
}
GECODE_NEVER;
return NULL;
}
ViewSel<BoolView>*
viewsel(Space& home, const BoolVarBranch& bvb) {
switch (bvb.select()) {
case BoolVarBranch::SEL_NONE:
return new (home) ViewSelNone<BoolView>(home,bvb);
case BoolVarBranch::SEL_RND:
return new (home) ViewSelRnd<BoolView>(home,bvb);
default: break;
}
if (bvb.tbl() != NULL) {
switch (bvb.select()) {
case BoolVarBranch::SEL_MERIT_MIN:
return new (home) ViewSelMinTbl<MeritFunction<BoolView>>(home,bvb);
case BoolVarBranch::SEL_MERIT_MAX:
return new (home) ViewSelMaxTbl<MeritFunction<BoolView>>(home,bvb);
case BoolVarBranch::SEL_DEGREE_MIN:
return new (home) ViewSelMinTbl<MeritDegree<BoolView>>(home,bvb);
case BoolVarBranch::SEL_DEGREE_MAX:
return new (home) ViewSelMaxTbl<MeritDegree<BoolView>>(home,bvb);
case BoolVarBranch::SEL_AFC_MIN:
return new (home) ViewSelMinTbl<MeritAFC<BoolView>>(home,bvb);
case BoolVarBranch::SEL_AFC_MAX:
return new (home) ViewSelMaxTbl<MeritAFC<BoolView>>(home,bvb);
case BoolVarBranch::SEL_ACTION_MIN:
return new (home) ViewSelMinTbl<MeritAction<BoolView>>(home,bvb);
case BoolVarBranch::SEL_ACTION_MAX:
return new (home) ViewSelMaxTbl<MeritAction<BoolView>>(home,bvb);
case BoolVarBranch::SEL_CHB_MIN:
return new (home) ViewSelMinTbl<MeritCHB<BoolView>>(home,bvb);
case BoolVarBranch::SEL_CHB_MAX:
return new (home) ViewSelMaxTbl<MeritCHB<BoolView>>(home,bvb);
default:
throw UnknownBranching("Int::branch");
}
} else {
switch (bvb.select()) {
case BoolVarBranch::SEL_MERIT_MIN:
return new (home) ViewSelMin<MeritFunction<BoolView>>(home,bvb);
case BoolVarBranch::SEL_MERIT_MAX:
return new (home) ViewSelMax<MeritFunction<BoolView>>(home,bvb);
case BoolVarBranch::SEL_DEGREE_MIN:
return new (home) ViewSelMin<MeritDegree<BoolView>>(home,bvb);
case BoolVarBranch::SEL_DEGREE_MAX:
return new (home) ViewSelMax<MeritDegree<BoolView>>(home,bvb);
case BoolVarBranch::SEL_AFC_MIN:
return new (home) ViewSelMin<MeritAFC<BoolView>>(home,bvb);
case BoolVarBranch::SEL_AFC_MAX:
return new (home) ViewSelMax<MeritAFC<BoolView>>(home,bvb);
case BoolVarBranch::SEL_ACTION_MIN:
return new (home) ViewSelMin<MeritAction<BoolView>>(home,bvb);
case BoolVarBranch::SEL_ACTION_MAX:
return new (home) ViewSelMax<MeritAction<BoolView>>(home,bvb);
case BoolVarBranch::SEL_CHB_MIN:
return new (home) ViewSelMin<MeritCHB<BoolView>>(home,bvb);
case BoolVarBranch::SEL_CHB_MAX:
return new (home) ViewSelMax<MeritCHB<BoolView>>(home,bvb);
default:
throw UnknownBranching("Int::branch");
}
}
GECODE_NEVER;
return NULL;
}
}}}
// STATISTICS: int-branch
Gecode::BoolVarBranch
Which Boolean variable to select for branching.
Definition int.hh:4656
Gecode::BoolVarBranch::select
Select select(void) const
Return selection strategy.
Definition var.hpp:340
Gecode::BoolVarBranch::SEL_DEGREE_MIN
@ SEL_DEGREE_MIN
With smallest degree.
Definition int.hh:4664
Gecode::BoolVarBranch::SEL_AFC_MAX
@ SEL_AFC_MAX
With largest accumulated failure count.
Definition int.hh:4667
Gecode::BoolVarBranch::SEL_CHB_MIN
@ SEL_CHB_MIN
With lowest CHB.
Definition int.hh:4670
Gecode::BoolVarBranch::SEL_MERIT_MIN
@ SEL_MERIT_MIN
With least merit.
Definition int.hh:4662
Gecode::BoolVarBranch::SEL_ACTION_MIN
@ SEL_ACTION_MIN
With lowest action.
Definition int.hh:4668
Gecode::BoolVarBranch::SEL_AFC_MIN
@ SEL_AFC_MIN
With smallest accumulated failure count.
Definition int.hh:4666
Gecode::BoolVarBranch::SEL_RND
@ SEL_RND
Random (uniform, for tie breaking).
Definition int.hh:4661
Gecode::BoolVarBranch::SEL_NONE
@ SEL_NONE
First unassigned.
Definition int.hh:4660
Gecode::BoolVarBranch::SEL_ACTION_MAX
@ SEL_ACTION_MAX
With highest action.
Definition int.hh:4669
Gecode::BoolVarBranch::SEL_CHB_MAX
@ SEL_CHB_MAX
With highest CHB.
Definition int.hh:4671
Gecode::BoolVarBranch::SEL_MERIT_MAX
@ SEL_MERIT_MAX
With highest merit.
Definition int.hh:4663
Gecode::BoolVarBranch::SEL_DEGREE_MAX
@ SEL_DEGREE_MAX
With largest degree.
Definition int.hh:4665
Gecode::IntVarBranch
Which integer variable to select for branching.
Definition int.hh:4570
Gecode::IntVarBranch::SEL_MAX_MIN
@ SEL_MAX_MIN
With smallest max.
Definition int.hh:4588
Gecode::IntVarBranch::SEL_CHB_MAX
@ SEL_CHB_MAX
With highest CHB Q-score.
Definition int.hh:4585
Gecode::IntVarBranch::SEL_AFC_SIZE_MAX
@ SEL_AFC_SIZE_MAX
With largest accumulated failure count divided by domain size.
Definition int.hh:4595
Gecode::IntVarBranch::SEL_MIN_MIN
@ SEL_MIN_MIN
With smallest min.
Definition int.hh:4586
Gecode::IntVarBranch::SEL_ACTION_SIZE_MAX
@ SEL_ACTION_SIZE_MAX
With largest action divided by domain size.
Definition int.hh:4597
Gecode::IntVarBranch::SEL_AFC_SIZE_MIN
@ SEL_AFC_SIZE_MIN
With smallest accumulated failure count divided by domain size.
Definition int.hh:4594
Gecode::IntVarBranch::SEL_REGRET_MIN_MIN
@ SEL_REGRET_MIN_MIN
With smallest min-regret.
Definition int.hh:4605
Gecode::IntVarBranch::SEL_DEGREE_SIZE_MIN
@ SEL_DEGREE_SIZE_MIN
With smallest degree divided by domain size.
Definition int.hh:4592
Gecode::IntVarBranch::SEL_MIN_MAX
@ SEL_MIN_MAX
With largest min.
Definition int.hh:4587
Gecode::IntVarBranch::SEL_REGRET_MIN_MAX
@ SEL_REGRET_MIN_MAX
With largest min-regret.
Definition int.hh:4611
Gecode::IntVarBranch::SEL_CHB_SIZE_MAX
@ SEL_CHB_SIZE_MAX
With largest CHB Q-score divided by domain size.
Definition int.hh:4599
Gecode::IntVarBranch::SEL_MAX_MAX
@ SEL_MAX_MAX
With largest max.
Definition int.hh:4589
Gecode::IntVarBranch::SEL_AFC_MIN
@ SEL_AFC_MIN
With smallest accumulated failure count.
Definition int.hh:4580
Gecode::IntVarBranch::SEL_SIZE_MIN
@ SEL_SIZE_MIN
With smallest domain size.
Definition int.hh:4590
Gecode::IntVarBranch::SEL_AFC_MAX
@ SEL_AFC_MAX
With largest accumulated failure count.
Definition int.hh:4581
Gecode::IntVarBranch::SEL_MERIT_MAX
@ SEL_MERIT_MAX
With highest merit.
Definition int.hh:4577
Gecode::IntVarBranch::SEL_DEGREE_MAX
@ SEL_DEGREE_MAX
With largest degree.
Definition int.hh:4579
Gecode::IntVarBranch::SEL_SIZE_MAX
@ SEL_SIZE_MAX
With largest domain size.
Definition int.hh:4591
Gecode::IntVarBranch::SEL_ACTION_MIN
@ SEL_ACTION_MIN
With lowest action.
Definition int.hh:4582
Gecode::IntVarBranch::SEL_ACTION_MAX
@ SEL_ACTION_MAX
With highest action.
Definition int.hh:4583
Gecode::IntVarBranch::SEL_CHB_MIN
@ SEL_CHB_MIN
With lowest CHB Q-score.
Definition int.hh:4584
Gecode::IntVarBranch::SEL_RND
@ SEL_RND
Random (uniform, for tie breaking).
Definition int.hh:4575
Gecode::IntVarBranch::SEL_NONE
@ SEL_NONE
First unassigned.
Definition int.hh:4574
Gecode::IntVarBranch::SEL_MERIT_MIN
@ SEL_MERIT_MIN
With least merit.
Definition int.hh:4576
Gecode::IntVarBranch::SEL_REGRET_MAX_MIN
@ SEL_REGRET_MAX_MIN
With smallest max-regret.
Definition int.hh:4617
Gecode::IntVarBranch::SEL_CHB_SIZE_MIN
@ SEL_CHB_SIZE_MIN
With smallest CHB Q-score divided by domain size.
Definition int.hh:4598
Gecode::IntVarBranch::SEL_DEGREE_MIN
@ SEL_DEGREE_MIN
With smallest degree.
Definition int.hh:4578
Gecode::IntVarBranch::SEL_REGRET_MAX_MAX
@ SEL_REGRET_MAX_MAX
With largest max-regret.
Definition int.hh:4623
Gecode::IntVarBranch::SEL_ACTION_SIZE_MIN
@ SEL_ACTION_SIZE_MIN
With smallest action divided by domain size.
Definition int.hh:4596
Gecode::IntVarBranch::SEL_DEGREE_SIZE_MAX
@ SEL_DEGREE_SIZE_MAX
With largest degree divided by domain size.
Definition int.hh:4593
Gecode::IntVarBranch::select
Select select(void) const
Return selection strategy.
Definition var.hpp:69
Gecode::Int::Branch::MeritAFCSize
Merit class for AFC over size.
Definition branch.hh:141
Gecode::Int::Branch::MeritActionSize
Merit class for action over size.
Definition branch.hh:166
Gecode::Int::Branch::MeritCHBSize
Merit class for CHB over size.
Definition branch.hh:191
Gecode::Int::Branch::MeritDegreeSize
Merit class for degree over size.
Definition branch.hh:123
Gecode::Int::Branch::MeritMax
Merit class for maximum.
Definition branch.hh:87
Gecode::Int::Branch::MeritMin
Merit class for mimimum of integer views.
Definition branch.hh:69
Gecode::Int::Branch::MeritRegretMax
Merit class for maximum regret.
Definition branch.hh:234
Gecode::Int::Branch::MeritRegretMin
Merit class for minimum regret.
Definition branch.hh:216
Gecode::Int::Branch::MeritSize
Merit class for size.
Definition branch.hh:105
Gecode::Int::UnknownBranching
Exception: Unknown value or variable selection passed as argument
Definition exception.hpp:108
Gecode::MeritAFC
Merit class for AFC.
Definition merit.hpp:108
Gecode::MeritAction
Merit class for action.
Definition merit.hpp:130
Gecode::MeritCHB
Merit class for CHB.
Definition merit.hpp:153
Gecode::MeritDegree
Merit class for degree.
Definition merit.hpp:93
Gecode::MeritFunction
Merit class for user-defined merit function.
Definition merit.hpp:68
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::VarBranch::tbl
BranchTbl tbl(void) const
Return tie-break limit function.
Definition var.hpp:168
Gecode::ViewSelMaxTbl
Select view with largest merit taking tie-break limit into account.
Definition view-sel.hpp:355
Gecode::ViewSelMax
Select view with largest merit.
Definition view-sel.hpp:335
Gecode::ViewSelMinTbl
Select view with least merit taking tie-break limit into account.
Definition view-sel.hpp:315
Gecode::ViewSelMin
Select view with least merit.
Definition view-sel.hpp:295
Gecode::ViewSelNone
Select the first unassigned view.
Definition view-sel.hpp:109
Gecode::ViewSelRnd
Select a view randomly.
Definition view-sel.hpp:149
Gecode::ViewSel
Abstract class for view selection.
Definition view-sel.hpp:44
branch.hh
Gecode::Int::Branch
Integer branchers.
Gecode::Int::Branch::viewsel
ViewSel< IntView > * viewsel(Space &home, const IntVarBranch &ivb)
Return view selectors for integer views.
Definition view-sel.cpp:39
Gecode::Int
Finite domain integers.
Gecode
Gecode toplevel namespace
GECODE_NEVER
#define GECODE_NEVER
Assert that this command is never executed.
Definition macros.hpp:56