Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
val-sel-commit.cpp
Go to the documentation of this file.
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Christian Schulte <schulte@gecode.org>
5 *
6 * Copyright:
7 * Christian Schulte, 2012
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#include <gecode/int/branch.hh>
35
36namespace Gecode { namespace Int { namespace Branch {
37
38 ValSelCommitBase<IntView,int>*
39 valselcommit(Space& home, const IntValBranch& ivb) {
40 assert((ivb.select() != IntValBranch::SEL_VALUES_MIN) &&
42 switch (ivb.select()) {
44 return new (home)
47 return new (home)
50 return new (home)
53 return new (home)
56 return new (home)
59 return new (home)
62 return new (home)
65 return new (home)
68 if (!ivb.commit()) {
69 return new (home)
71 } else {
72 return new (home)
74 }
75 default:
76 throw UnknownBranching("Int::branch");
77 }
78 }
79
81 valselcommit(Space& home, const IntAssign& ia) {
82 switch (ia.select()) {
84 return new (home)
87 return new (home)
90 return new (home)
93 return new (home)
96 if (!ia.commit()) {
97 return new (home)
99 } else {
100 return new (home)
102 }
103 default:
104 throw UnknownBranching("Int::assign");
105 }
106 }
107
109 valselcommit(Space& home, const BoolValBranch& bvb) {
110 switch (bvb.select()) {
112 return new (home)
115 return new (home)
118 return new (home)
121 if (!bvb.commit()) {
122 return new (home)
124 } else {
125 return new (home)
127 }
128 default:
129 throw UnknownBranching("Int::branch");
130 }
131 }
132
135 switch (ba.select()) {
137 return new (home)
140 return new (home)
143 return new (home)
146 if (!ba.commit()) {
147 return new (home)
149 } else {
150 return new (home)
152 }
153 default:
154 throw UnknownBranching("Int::assign");
155 }
156 }
157
158}}}
159
160
161// STATISTICS: int-branch
162
Which values to select for assignment.
Definition int.hh:5015
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition int.hh:5022
@ SEL_MIN
Select smallest value.
Definition int.hh:5019
@ SEL_MAX
Select largest value.
Definition int.hh:5020
@ SEL_RND
Select random value.
Definition int.hh:5021
Which values to select for branching first.
Definition int.hh:4904
@ SEL_MIN
Select smallest value.
Definition int.hh:4908
@ SEL_RND
Select random value.
Definition int.hh:4910
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition int.hh:4911
@ SEL_MAX
Select largest value.
Definition int.hh:4909
Select select(void) const
Return selection strategy.
Definition val.hpp:124
Which values to select for assignment.
Definition int.hh:4986
Select select(void) const
Return selection strategy.
Definition assign.hpp:49
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition int.hh:4994
@ SEL_MIN
Select smallest value.
Definition int.hh:4990
@ SEL_MED
Select greatest value not greater than the median.
Definition int.hh:4991
@ SEL_RND
Select random value.
Definition int.hh:4993
@ SEL_MAX
Select largest value.
Definition int.hh:4992
Which values to select for branching first.
Definition int.hh:4869
@ SEL_VALUES_MIN
Select all values starting from smallest.
Definition int.hh:4882
@ SEL_RND
Select random value.
Definition int.hh:4876
@ SEL_SPLIT_MAX
Select values greater than mean of smallest and largest value.
Definition int.hh:4878
@ SEL_MIN
Select smallest value.
Definition int.hh:4873
@ SEL_MAX
Select largest value.
Definition int.hh:4875
@ SEL_RANGE_MAX
Select the largest range of the variable domain if it has several ranges, otherwise select values gre...
Definition int.hh:4880
@ SEL_RANGE_MIN
Select the smallest range of the variable domain if it has several ranges, otherwise select values no...
Definition int.hh:4879
@ SEL_VALUES_MAX
Select all values starting from largest.
Definition int.hh:4883
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition int.hh:4881
@ SEL_MED
Select greatest value not greater than the median.
Definition int.hh:4874
@ SEL_SPLIT_MIN
Select values not greater than mean of smallest and largest value.
Definition int.hh:4877
Select select(void) const
Return selection strategy.
Definition val.hpp:49
Value commit class for equality.
Definition branch.hh:506
Value commit class for greater or equal.
Definition branch.hh:552
Value commit class for greater.
Definition branch.hh:575
Value commit class for less or equal.
Definition branch.hh:529
Value selection class for average of view.
Definition branch.hh:335
Value selection class for maximum of view.
Definition branch.hh:299
Value selection class for median of view.
Definition branch.hh:317
Value selection class for mimimum of view.
Definition branch.hh:281
Value selection class for maximum range of integer view.
Definition branch.hh:393
Value selection class for minimum range of integer view.
Definition branch.hh:377
Value selection class for random value of view.
Definition branch.hh:353
Exception: Unknown value or variable selection passed as argument
Computation spaces.
Definition core.hpp:1744
BranchCommit commit(void) const
Return commit function.
Definition val.hpp:102
Class for user-defined value commit.
Base class for value selection and commit.
Class for value selection and commit.
User-defined value selection.
Definition val-sel.hpp:67
Integer branchers.
ValSelCommitBase< IntView, int > * valselcommit(Space &home, const IntValBranch &ivb)
Return value and commit for integer views.
Finite domain integers.
Gecode toplevel namespace
IntPropLevel ba(IntPropLevel ipl)
Extract basic or advanced from propagation level.
Definition ipl.hpp:43