Generated on Thu Apr 5 2018 19:44:19 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  * Last modified:
10  * $Date$ by $Author$
11  * $Revision$
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #include <gecode/int/branch.hh>
39 
40 namespace Gecode { namespace Int { namespace Branch {
41 
42  ValSelCommitBase<IntView,int>*
43  valselcommit(Space& home, const IntValBranch& ivb) {
44  assert((ivb.select() != IntValBranch::SEL_VALUES_MIN) &&
46  switch (ivb.select()) {
48  return new (home)
51  return new (home)
54  return new (home)
57  return new (home)
60  return new (home)
63  return new (home)
66  return new (home)
69  return new (home)
72  if (!ivb.commit()) {
73  return new (home)
75  } else {
76  return new (home)
78  }
79  default:
80  throw UnknownBranching("Int::branch");
81  }
82  }
83 
85  valselcommit(Space& home, const IntAssign& ia) {
86  switch (ia.select()) {
87  case IntAssign::SEL_MIN:
88  return new (home)
90  case IntAssign::SEL_MED:
91  return new (home)
93  case IntAssign::SEL_MAX:
94  return new (home)
96  case IntAssign::SEL_RND:
97  return new (home)
100  if (!ia.commit()) {
101  return new (home)
103  } else {
104  return new (home)
106  }
107  default:
108  throw UnknownBranching("Int::assign");
109  }
110  }
111 
113  valselcommit(Space& home, const BoolValBranch& bvb) {
114  switch (bvb.select()) {
116  return new (home)
119  return new (home)
122  return new (home)
125  if (!bvb.commit()) {
126  return new (home)
128  } else {
129  return new (home)
131  }
132  default:
133  throw UnknownBranching("Int::branch");
134  }
135  }
136 
138  valselcommit(Space& home, const BoolAssign& ba) {
139  switch (ba.select()) {
140  case BoolAssign::SEL_MIN:
141  return new (home)
143  case BoolAssign::SEL_MAX:
144  return new (home)
146  case BoolAssign::SEL_RND:
147  return new (home)
150  if (!ba.commit()) {
151  return new (home)
153  } else {
154  return new (home)
156  }
157  default:
158  throw UnknownBranching("Int::assign");
159  }
160  }
161 
162 }}}
163 
164 
165 // STATISTICS: int-branch
166 
Select select(void) const
Return selection strategy.
Definition: assign.hpp:98
Select value according to user-defined functions.
Definition: int.hh:4693
Class for value selection and commit.
User-defined value selection.
Definition: val-sel.hpp:69
Select random value.
Definition: int.hh:4692
Which values to select for branching first.
Definition: int.hh:4686
Select smallest value.
Definition: int.hh:4690
Which values to select for branching first.
Definition: int.hh:4651
Select smallest value.
Definition: int.hh:4655
Which values to select for assignment.
Definition: int.hh:4797
Select the smallest range of the variable domain if it has several ranges, otherwise select values no...
Definition: int.hh:4661
Select largest value.
Definition: int.hh:4802
Value commit class for less or equal.
Definition: branch.hh:529
Computation spaces.
Definition: core.hpp:1668
Base class for value selection and commit.
Select smallest value.
Definition: int.hh:4772
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:112
Value selection class for minimum range of integer view.
Definition: branch.hh:377
Select random value.
Definition: int.hh:4775
Select all values starting from largest.
Definition: int.hh:4665
Select greatest value not greater than the median.
Definition: int.hh:4656
Select random value.
Definition: int.hh:4803
Select select(void) const
Return selection strategy.
Definition: val.hpp:53
Value selection class for maximum of view.
Definition: branch.hh:299
Select smallest value.
Definition: int.hh:4801
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:4776
Select values greater than mean of smallest and largest value.
Definition: int.hh:4660
Value commit class for equality.
Definition: branch.hh:506
IntPropLevel ba(IntPropLevel ipl)
Extract basic or advanced from propagation level.
Definition: ipl.hpp:47
Select the largest range of the variable domain if it has several ranges, otherwise select values gre...
Definition: int.hh:4662
Select values not greater than mean of smallest and largest value.
Definition: int.hh:4659
Value selection class for median of view.
Definition: branch.hh:317
Select random value.
Definition: int.hh:4658
Which values to select for assignment.
Definition: int.hh:4768
Select value according to user-defined functions.
Definition: int.hh:4804
BranchCommit commit(void) const
Return commit function.
Definition: val.hpp:106
Select greatest value not greater than the median.
Definition: int.hh:4773
Select select(void) const
Return selection strategy.
Definition: assign.hpp:53
Class for user-defined value commit.
Definition: val-commit.hpp:69
Gecode toplevel namespace
Select largest value.
Definition: int.hh:4657
Value selection class for maximum range of integer view.
Definition: branch.hh:393
Select value according to user-defined functions.
Definition: int.hh:4663
Select largest value.
Definition: int.hh:4691
Select largest value.
Definition: int.hh:4774
Select select(void) const
Return selection strategy.
Definition: val.hpp:128
Select all values starting from smallest.
Definition: int.hh:4664