Generated on Mon Feb 8 2021 00:00:00 for Gecode by doxygen 1.8.20
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 
36 namespace 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()) {
83  case IntAssign::SEL_MIN:
84  return new (home)
86  case IntAssign::SEL_MED:
87  return new (home)
89  case IntAssign::SEL_MAX:
90  return new (home)
92  case IntAssign::SEL_RND:
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 
134  valselcommit(Space& home, const BoolAssign& ba) {
135  switch (ba.select()) {
136  case BoolAssign::SEL_MIN:
137  return new (home)
139  case BoolAssign::SEL_MAX:
140  return new (home)
142  case BoolAssign::SEL_RND:
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 
@ SEL_RANGE_MAX
Select the largest range of the variable domain if it has several ranges, otherwise select values gre...
Definition: int.hh:4865
@ SEL_SPLIT_MIN
Select values not greater than mean of smallest and largest value.
Definition: int.hh:4862
Value selection class for random value of view.
Definition: branch.hh:353
Value commit class for greater.
Definition: branch.hh:575
Value selection class for maximum of view.
Definition: branch.hh:299
Which values to select for branching first.
Definition: int.hh:4854
Computation spaces.
Definition: core.hpp:1742
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition: int.hh:4866
Value commit class for equality.
Definition: branch.hh:506
BranchCommit commit(void) const
Return commit function.
Definition: val.hpp:102
@ SEL_MAX
Select largest value.
Definition: int.hh:5005
Exception: Unknown value or variable selection passed as argument
Definition: exception.hpp:108
Gecode toplevel namespace
User-defined value selection.
Definition: val-sel.hpp:67
@ SEL_MIN
Select smallest value.
Definition: int.hh:5004
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition: int.hh:4896
@ SEL_MIN
Select smallest value.
Definition: int.hh:4893
Class for value selection and commit.
Value commit class for greater or equal.
Definition: branch.hh:552
Value selection class for maximum range of integer view.
Definition: branch.hh:393
IntPropLevel ba(IntPropLevel ipl)
Extract basic or advanced from propagation level.
Definition: ipl.hpp:43
@ SEL_RND
Select random value.
Definition: int.hh:5006
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition: int.hh:4979
Which values to select for assignment.
Definition: int.hh:4971
Value selection class for median of view.
Definition: branch.hh:317
@ SEL_RND
Select random value.
Definition: int.hh:4895
@ SEL_SPLIT_MAX
Select values greater than mean of smallest and largest value.
Definition: int.hh:4863
@ SEL_MAX
Select largest value.
Definition: int.hh:4860
Select select(void) const
Return selection strategy.
Definition: val.hpp:49
@ SEL_MAX
Select largest value.
Definition: int.hh:4977
@ SEL_RND
Select random value.
Definition: int.hh:4861
@ SEL_VALUES_MIN
Select all values starting from smallest.
Definition: int.hh:4867
Base class for value selection and commit.
Value commit class for less or equal.
Definition: branch.hh:529
@ SEL_RANGE_MIN
Select the smallest range of the variable domain if it has several ranges, otherwise select values no...
Definition: int.hh:4864
Value selection class for average of view.
Definition: branch.hh:335
@ SEL_MED
Select greatest value not greater than the median.
Definition: int.hh:4859
Select select(void) const
Return selection strategy.
Definition: assign.hpp:49
@ SEL_MAX
Select largest value.
Definition: int.hh:4894
@ SEL_VALUES_MAX
Select all values starting from largest.
Definition: int.hh:4868
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition: int.hh:5007
Which values to select for assignment.
Definition: int.hh:5000
Class for user-defined value commit.
Definition: val-commit.hpp:67
ValSelCommitBase< IntView, int > * valselcommit(Space &home, const IntValBranch &ivb)
Return value and commit for integer views.
Value selection class for minimum range of integer view.
Definition: branch.hh:377
Select select(void) const
Return selection strategy.
Definition: val.hpp:124
@ SEL_MIN
Select smallest value.
Definition: int.hh:4858
Value selection class for mimimum of view.
Definition: branch.hh:281
@ SEL_RND
Select random value.
Definition: int.hh:4978
@ SEL_MIN
Select smallest value.
Definition: int.hh:4975
@ SEL_MED
Select greatest value not greater than the median.
Definition: int.hh:4976
Which values to select for branching first.
Definition: int.hh:4889