Generated on Tue Jan 28 2020 00:00:00 for Gecode by doxygen 1.8.17
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: 2017-04-01 20:27:10 +0200 (Sat, 01 Apr 2017) $ by $Author: schulte $
11  * $Revision: 15623 $
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 
@ SEL_RANGE_MAX
Select the largest range of the variable domain if it has several ranges, otherwise select values gre...
Definition: int.hh:4514
@ SEL_SPLIT_MIN
Select values not greater than mean of smallest and largest value.
Definition: int.hh:4511
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:4503
Computation spaces.
Definition: core.hpp:1748
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition: int.hh:4515
Value commit class for equality.
Definition: branch.hh:506
BranchCommit commit(void) const
Return commit function.
Definition: branch-val.hpp:106
@ SEL_MAX
Select largest value.
Definition: int.hh:4654
Exception: Unknown value or variable selection passed as argument
Definition: exception.hpp:112
Gecode toplevel namespace
User-defined value selection.
@ SEL_MIN
Select smallest value.
Definition: int.hh:4653
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition: int.hh:4545
@ SEL_MIN
Select smallest value.
Definition: int.hh:4542
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:53
@ SEL_RND
Select random value.
Definition: int.hh:4655
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition: int.hh:4628
Which values to select for assignment.
Definition: int.hh:4620
Value selection class for median of view.
Definition: branch.hh:317
@ SEL_RND
Select random value.
Definition: int.hh:4544
@ SEL_SPLIT_MAX
Select values greater than mean of smallest and largest value.
Definition: int.hh:4512
@ SEL_MAX
Select largest value.
Definition: int.hh:4509
Select select(void) const
Return selection strategy.
Definition: val.hpp:53
@ SEL_MAX
Select largest value.
Definition: int.hh:4626
@ SEL_RND
Select random value.
Definition: int.hh:4510
@ SEL_VALUES_MIN
Select all values starting from smallest.
Definition: int.hh:4516
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:4513
Value selection class for average of view.
Definition: branch.hh:335
@ SEL_MED
Select greatest value not greater than the median.
Definition: int.hh:4508
Select select(void) const
Return selection strategy.
Definition: assign.hpp:53
@ SEL_MAX
Select largest value.
Definition: int.hh:4543
@ SEL_VALUES_MAX
Select all values starting from largest.
Definition: int.hh:4517
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition: int.hh:4656
Which values to select for assignment.
Definition: int.hh:4649
Class for user-defined value commit.
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:128
@ SEL_MIN
Select smallest value.
Definition: int.hh:4507
Value selection class for mimimum of view.
Definition: branch.hh:281
@ SEL_RND
Select random value.
Definition: int.hh:4627
@ SEL_MIN
Select smallest value.
Definition: int.hh:4624
@ SEL_MED
Select greatest value not greater than the median.
Definition: int.hh:4625
Which values to select for branching first.
Definition: int.hh:4538