Generated on Fri Jan 28 2022 04:43:06 for Gecode by doxygen 1.8.13
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 
Select select(void) const
Return selection strategy.
Definition: assign.hpp:94
Select value according to user-defined functions.
Definition: int.hh:4833
Class for value selection and commit.
User-defined value selection.
Definition: val-sel.hpp:65
Select random value.
Definition: int.hh:4832
Which values to select for branching first.
Definition: int.hh:4826
Select smallest value.
Definition: int.hh:4830
Which values to select for branching first.
Definition: int.hh:4791
Select smallest value.
Definition: int.hh:4795
Which values to select for assignment.
Definition: int.hh:4937
Select the smallest range of the variable domain if it has several ranges, otherwise select values no...
Definition: int.hh:4801
Select largest value.
Definition: int.hh:4942
Value commit class for less or equal.
Definition: branch.hh:529
Computation spaces.
Definition: core.hpp:1701
Base class for value selection and commit.
Select smallest value.
Definition: int.hh:4912
Value commit class for greater.
Definition: branch.hh:575
Value selection class for mimimum of view.
Definition: branch.hh:281
Value selection class for average of view.
Definition: branch.hh:335
Value selection class for random value of view.
Definition: branch.hh:353
Exception: Unknown value or variable selection passed as argument
Definition: exception.hpp:108
Value selection class for minimum range of integer view.
Definition: branch.hh:377
Select random value.
Definition: int.hh:4915
Select all values starting from largest.
Definition: int.hh:4805
Select greatest value not greater than the median.
Definition: int.hh:4796
Select random value.
Definition: int.hh:4943
Select select(void) const
Return selection strategy.
Definition: val.hpp:49
Value selection class for maximum of view.
Definition: branch.hh:299
Select smallest value.
Definition: int.hh:4941
Value commit class for greater or equal.
Definition: branch.hh:552
ValSelCommitBase< IntView, int > * valselcommit(Space &home, const IntValBranch &ivb)
Return value and commit for integer views.
Select value according to user-defined functions.
Definition: int.hh:4916
Select values greater than mean of smallest and largest value.
Definition: int.hh:4800
Value commit class for equality.
Definition: branch.hh:506
IntPropLevel ba(IntPropLevel ipl)
Extract basic or advanced from propagation level.
Definition: ipl.hpp:43
Select the largest range of the variable domain if it has several ranges, otherwise select values gre...
Definition: int.hh:4802
Select values not greater than mean of smallest and largest value.
Definition: int.hh:4799
Value selection class for median of view.
Definition: branch.hh:317
Select random value.
Definition: int.hh:4798
Which values to select for assignment.
Definition: int.hh:4908
Select value according to user-defined functions.
Definition: int.hh:4944
BranchCommit commit(void) const
Return commit function.
Definition: val.hpp:102
Select greatest value not greater than the median.
Definition: int.hh:4913
Select select(void) const
Return selection strategy.
Definition: assign.hpp:49
Class for user-defined value commit.
Definition: val-commit.hpp:65
Gecode toplevel namespace
Select largest value.
Definition: int.hh:4797
Value selection class for maximum range of integer view.
Definition: branch.hh:393
Select value according to user-defined functions.
Definition: int.hh:4803
Select largest value.
Definition: int.hh:4831
Select largest value.
Definition: int.hh:4914
Select select(void) const
Return selection strategy.
Definition: val.hpp:124
Select all values starting from smallest.
Definition: int.hh:4804