val-sel-commit.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 {
ValSelCommitBase<IntView,int>*
valselcommit(Space& home, const IntValBranch& ivb) {
assert((ivb.select() != IntValBranch::SEL_VALUES_MIN) &&
(ivb.select() != IntValBranch::SEL_VALUES_MAX));
switch (ivb.select()) {
case IntValBranch::SEL_MIN:
return new (home)
ValSelCommit<ValSelMin<IntView>,ValCommitEq<IntView> >(home,ivb);
case IntValBranch::SEL_MED:
return new (home)
ValSelCommit<ValSelMed<IntView>,ValCommitEq<IntView> >(home,ivb);
case IntValBranch::SEL_MAX:
return new (home)
ValSelCommit<ValSelMax<IntView>,ValCommitEq<IntView> >(home,ivb);
case IntValBranch::SEL_RND:
return new (home)
ValSelCommit<ValSelRnd<IntView>,ValCommitEq<IntView> >(home,ivb);
case IntValBranch::SEL_SPLIT_MIN:
return new (home)
ValSelCommit<ValSelAvg<IntView>,ValCommitLq<IntView> >(home,ivb);
case IntValBranch::SEL_SPLIT_MAX:
return new (home)
ValSelCommit<ValSelAvg<IntView>,ValCommitGr<IntView> >(home,ivb);
case IntValBranch::SEL_RANGE_MIN:
return new (home)
ValSelCommit<ValSelRangeMin,ValCommitLq<IntView> >(home,ivb);
case IntValBranch::SEL_RANGE_MAX:
return new (home)
ValSelCommit<ValSelRangeMax,ValCommitGq<IntView> >(home,ivb);
case IntValBranch::SEL_VAL_COMMIT:
if (!ivb.commit()) {
return new (home)
ValSelCommit<ValSelFunction<IntView>,ValCommitEq<IntView> >(home,ivb);
} else {
return new (home)
ValSelCommit<ValSelFunction<IntView>,ValCommitFunction<IntView> >(home,ivb);
}
default:
throw UnknownBranching("Int::branch");
}
}
ValSelCommitBase<IntView,int>*
valselcommit(Space& home, const IntAssign& ia) {
switch (ia.select()) {
case IntAssign::SEL_MIN:
return new (home)
ValSelCommit<ValSelMin<IntView>,ValCommitEq<IntView> >(home,ia);
case IntAssign::SEL_MED:
return new (home)
ValSelCommit<ValSelMed<IntView>,ValCommitEq<IntView> >(home,ia);
case IntAssign::SEL_MAX:
return new (home)
ValSelCommit<ValSelMax<IntView>,ValCommitEq<IntView> >(home,ia);
case IntAssign::SEL_RND:
return new (home)
ValSelCommit<ValSelRnd<IntView>,ValCommitEq<IntView> >(home,ia);
case IntAssign::SEL_VAL_COMMIT:
if (!ia.commit()) {
return new (home)
ValSelCommit<ValSelFunction<IntView>,ValCommitEq<IntView> >(home,ia);
} else {
return new (home)
ValSelCommit<ValSelFunction<IntView>,ValCommitFunction<IntView> >(home,ia);
}
default:
throw UnknownBranching("Int::assign");
}
}
ValSelCommitBase<BoolView,int>*
valselcommit(Space& home, const BoolValBranch& bvb) {
switch (bvb.select()) {
case BoolValBranch::SEL_MIN:
return new (home)
ValSelCommit<ValSelMin<BoolView>,ValCommitEq<BoolView> >(home,bvb);
case BoolValBranch::SEL_MAX:
return new (home)
ValSelCommit<ValSelMax<BoolView>,ValCommitEq<BoolView> >(home,bvb);
case BoolValBranch::SEL_RND:
return new (home)
ValSelCommit<ValSelRnd<BoolView>,ValCommitEq<BoolView> >(home,bvb);
case BoolValBranch::SEL_VAL_COMMIT:
if (!bvb.commit()) {
return new (home)
ValSelCommit<ValSelFunction<BoolView>,ValCommitEq<BoolView> >(home,bvb);
} else {
return new (home)
ValSelCommit<ValSelFunction<BoolView>,ValCommitFunction<BoolView> >(home,bvb);
}
default:
throw UnknownBranching("Int::branch");
}
}
ValSelCommitBase<BoolView,int>*
valselcommit(Space& home, const BoolAssign& ba) {
switch (ba.select()) {
case BoolAssign::SEL_MIN:
return new (home)
ValSelCommit<ValSelMin<BoolView>,ValCommitEq<BoolView> >(home,ba);
case BoolAssign::SEL_MAX:
return new (home)
ValSelCommit<ValSelMax<BoolView>,ValCommitEq<BoolView> >(home,ba);
case BoolAssign::SEL_RND:
return new (home)
ValSelCommit<ValSelRnd<BoolView>,ValCommitEq<BoolView> >(home,ba);
case BoolAssign::SEL_VAL_COMMIT:
if (!ba.commit()) {
return new (home)
ValSelCommit<ValSelFunction<BoolView>,ValCommitEq<BoolView> >(home,ba);
} else {
return new (home)
ValSelCommit<ValSelFunction<BoolView>,ValCommitFunction<BoolView> >(home,ba);
}
default:
throw UnknownBranching("Int::assign");
}
}
}}}
// STATISTICS: int-branch
Gecode::BoolAssign
Which values to select for assignment.
Definition int.hh:5000
Gecode::BoolAssign::SEL_VAL_COMMIT
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition int.hh:5007
Gecode::BoolAssign::SEL_MIN
@ SEL_MIN
Select smallest value.
Definition int.hh:5004
Gecode::BoolAssign::SEL_MAX
@ SEL_MAX
Select largest value.
Definition int.hh:5005
Gecode::BoolAssign::SEL_RND
@ SEL_RND
Select random value.
Definition int.hh:5006
Gecode::BoolValBranch
Which values to select for branching first.
Definition int.hh:4889
Gecode::BoolValBranch::SEL_MIN
@ SEL_MIN
Select smallest value.
Definition int.hh:4893
Gecode::BoolValBranch::SEL_RND
@ SEL_RND
Select random value.
Definition int.hh:4895
Gecode::BoolValBranch::SEL_VAL_COMMIT
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition int.hh:4896
Gecode::BoolValBranch::SEL_MAX
@ SEL_MAX
Select largest value.
Definition int.hh:4894
Gecode::BoolValBranch::select
Select select(void) const
Return selection strategy.
Definition val.hpp:124
Gecode::IntAssign
Which values to select for assignment.
Definition int.hh:4971
Gecode::IntAssign::select
Select select(void) const
Return selection strategy.
Definition assign.hpp:49
Gecode::IntAssign::SEL_VAL_COMMIT
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition int.hh:4979
Gecode::IntAssign::SEL_MIN
@ SEL_MIN
Select smallest value.
Definition int.hh:4975
Gecode::IntAssign::SEL_MED
@ SEL_MED
Select greatest value not greater than the median.
Definition int.hh:4976
Gecode::IntAssign::SEL_RND
@ SEL_RND
Select random value.
Definition int.hh:4978
Gecode::IntAssign::SEL_MAX
@ SEL_MAX
Select largest value.
Definition int.hh:4977
Gecode::IntValBranch
Which values to select for branching first.
Definition int.hh:4854
Gecode::IntValBranch::SEL_VALUES_MIN
@ SEL_VALUES_MIN
Select all values starting from smallest.
Definition int.hh:4867
Gecode::IntValBranch::SEL_RND
@ SEL_RND
Select random value.
Definition int.hh:4861
Gecode::IntValBranch::SEL_SPLIT_MAX
@ SEL_SPLIT_MAX
Select values greater than mean of smallest and largest value.
Definition int.hh:4863
Gecode::IntValBranch::SEL_MIN
@ SEL_MIN
Select smallest value.
Definition int.hh:4858
Gecode::IntValBranch::SEL_MAX
@ SEL_MAX
Select largest value.
Definition int.hh:4860
Gecode::IntValBranch::SEL_RANGE_MAX
@ SEL_RANGE_MAX
Select the largest range of the variable domain if it has several ranges, otherwise select values gre...
Definition int.hh:4865
Gecode::IntValBranch::SEL_RANGE_MIN
@ SEL_RANGE_MIN
Select the smallest range of the variable domain if it has several ranges, otherwise select values no...
Definition int.hh:4864
Gecode::IntValBranch::SEL_VALUES_MAX
@ SEL_VALUES_MAX
Select all values starting from largest.
Definition int.hh:4868
Gecode::IntValBranch::SEL_VAL_COMMIT
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition int.hh:4866
Gecode::IntValBranch::SEL_MED
@ SEL_MED
Select greatest value not greater than the median.
Definition int.hh:4859
Gecode::IntValBranch::SEL_SPLIT_MIN
@ SEL_SPLIT_MIN
Select values not greater than mean of smallest and largest value.
Definition int.hh:4862
Gecode::IntValBranch::select
Select select(void) const
Return selection strategy.
Definition val.hpp:49
Gecode::Int::Branch::ValCommitEq
Value commit class for equality.
Definition branch.hh:506
Gecode::Int::Branch::ValCommitGq
Value commit class for greater or equal.
Definition branch.hh:552
Gecode::Int::Branch::ValCommitGr
Value commit class for greater.
Definition branch.hh:575
Gecode::Int::Branch::ValCommitLq
Value commit class for less or equal.
Definition branch.hh:529
Gecode::Int::Branch::ValSelAvg
Value selection class for average of view.
Definition branch.hh:335
Gecode::Int::Branch::ValSelMax
Value selection class for maximum of view.
Definition branch.hh:299
Gecode::Int::Branch::ValSelMed
Value selection class for median of view.
Definition branch.hh:317
Gecode::Int::Branch::ValSelMin
Value selection class for mimimum of view.
Definition branch.hh:281
Gecode::Int::Branch::ValSelRangeMax
Value selection class for maximum range of integer view.
Definition branch.hh:393
Gecode::Int::Branch::ValSelRangeMin
Value selection class for minimum range of integer view.
Definition branch.hh:377
Gecode::Int::Branch::ValSelRnd
Value selection class for random value of view.
Definition branch.hh:353
Gecode::Int::UnknownBranching
Exception: Unknown value or variable selection passed as argument
Definition exception.hpp:108
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::ValBranch::commit
BranchCommit commit(void) const
Return commit function.
Definition val.hpp:102
Gecode::ValCommitFunction
Class for user-defined value commit.
Definition val-commit.hpp:67
Gecode::ValSelCommitBase
Base class for value selection and commit.
Definition val-sel-commit.hpp:44
Gecode::ValSelCommit
Class for value selection and commit.
Definition val-sel-commit.hpp:91
Gecode::ValSelFunction
User-defined value selection.
Definition val-sel.hpp:67
branch.hh
Gecode::Int::Branch
Integer branchers.
Gecode::Int::Branch::valselcommit
ValSelCommitBase< IntView, int > * valselcommit(Space &home, const IntValBranch &ivb)
Return value and commit for integer views.
Definition val-sel-commit.cpp:39
Gecode::Int
Finite domain integers.
Gecode
Gecode toplevel namespace
Gecode::ba
IntPropLevel ba(IntPropLevel ipl)
Extract basic or advanced from propagation level.
Definition ipl.hpp:43