this repo has no description
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) &&
41 (ivb.select() != IntValBranch::SEL_VALUES_MAX));
42 switch (ivb.select()) {
43 case IntValBranch::SEL_MIN:
44 return new (home)
45 ValSelCommit<ValSelMin<IntView>,ValCommitEq<IntView> >(home,ivb);
46 case IntValBranch::SEL_MED:
47 return new (home)
48 ValSelCommit<ValSelMed<IntView>,ValCommitEq<IntView> >(home,ivb);
49 case IntValBranch::SEL_MAX:
50 return new (home)
51 ValSelCommit<ValSelMax<IntView>,ValCommitEq<IntView> >(home,ivb);
52 case IntValBranch::SEL_RND:
53 return new (home)
54 ValSelCommit<ValSelRnd<IntView>,ValCommitEq<IntView> >(home,ivb);
55 case IntValBranch::SEL_SPLIT_MIN:
56 return new (home)
57 ValSelCommit<ValSelAvg<IntView>,ValCommitLq<IntView> >(home,ivb);
58 case IntValBranch::SEL_SPLIT_MAX:
59 return new (home)
60 ValSelCommit<ValSelAvg<IntView>,ValCommitGr<IntView> >(home,ivb);
61 case IntValBranch::SEL_RANGE_MIN:
62 return new (home)
63 ValSelCommit<ValSelRangeMin,ValCommitLq<IntView> >(home,ivb);
64 case IntValBranch::SEL_RANGE_MAX:
65 return new (home)
66 ValSelCommit<ValSelRangeMax,ValCommitGq<IntView> >(home,ivb);
67 case IntValBranch::SEL_VAL_COMMIT:
68 if (!ivb.commit()) {
69 return new (home)
70 ValSelCommit<ValSelFunction<IntView>,ValCommitEq<IntView> >(home,ivb);
71 } else {
72 return new (home)
73 ValSelCommit<ValSelFunction<IntView>,ValCommitFunction<IntView> >(home,ivb);
74 }
75 default:
76 throw UnknownBranching("Int::branch");
77 }
78 }
79
80 ValSelCommitBase<IntView,int>*
81 valselcommit(Space& home, const IntAssign& ia) {
82 switch (ia.select()) {
83 case IntAssign::SEL_MIN:
84 return new (home)
85 ValSelCommit<ValSelMin<IntView>,ValCommitEq<IntView> >(home,ia);
86 case IntAssign::SEL_MED:
87 return new (home)
88 ValSelCommit<ValSelMed<IntView>,ValCommitEq<IntView> >(home,ia);
89 case IntAssign::SEL_MAX:
90 return new (home)
91 ValSelCommit<ValSelMax<IntView>,ValCommitEq<IntView> >(home,ia);
92 case IntAssign::SEL_RND:
93 return new (home)
94 ValSelCommit<ValSelRnd<IntView>,ValCommitEq<IntView> >(home,ia);
95 case IntAssign::SEL_VAL_COMMIT:
96 if (!ia.commit()) {
97 return new (home)
98 ValSelCommit<ValSelFunction<IntView>,ValCommitEq<IntView> >(home,ia);
99 } else {
100 return new (home)
101 ValSelCommit<ValSelFunction<IntView>,ValCommitFunction<IntView> >(home,ia);
102 }
103 default:
104 throw UnknownBranching("Int::assign");
105 }
106 }
107
108 ValSelCommitBase<BoolView,int>*
109 valselcommit(Space& home, const BoolValBranch& bvb) {
110 switch (bvb.select()) {
111 case BoolValBranch::SEL_MIN:
112 return new (home)
113 ValSelCommit<ValSelMin<BoolView>,ValCommitEq<BoolView> >(home,bvb);
114 case BoolValBranch::SEL_MAX:
115 return new (home)
116 ValSelCommit<ValSelMax<BoolView>,ValCommitEq<BoolView> >(home,bvb);
117 case BoolValBranch::SEL_RND:
118 return new (home)
119 ValSelCommit<ValSelRnd<BoolView>,ValCommitEq<BoolView> >(home,bvb);
120 case BoolValBranch::SEL_VAL_COMMIT:
121 if (!bvb.commit()) {
122 return new (home)
123 ValSelCommit<ValSelFunction<BoolView>,ValCommitEq<BoolView> >(home,bvb);
124 } else {
125 return new (home)
126 ValSelCommit<ValSelFunction<BoolView>,ValCommitFunction<BoolView> >(home,bvb);
127 }
128 default:
129 throw UnknownBranching("Int::branch");
130 }
131 }
132
133 ValSelCommitBase<BoolView,int>*
134 valselcommit(Space& home, const BoolAssign& ba) {
135 switch (ba.select()) {
136 case BoolAssign::SEL_MIN:
137 return new (home)
138 ValSelCommit<ValSelMin<BoolView>,ValCommitEq<BoolView> >(home,ba);
139 case BoolAssign::SEL_MAX:
140 return new (home)
141 ValSelCommit<ValSelMax<BoolView>,ValCommitEq<BoolView> >(home,ba);
142 case BoolAssign::SEL_RND:
143 return new (home)
144 ValSelCommit<ValSelRnd<BoolView>,ValCommitEq<BoolView> >(home,ba);
145 case BoolAssign::SEL_VAL_COMMIT:
146 if (!ba.commit()) {
147 return new (home)
148 ValSelCommit<ValSelFunction<BoolView>,ValCommitEq<BoolView> >(home,ba);
149 } else {
150 return new (home)
151 ValSelCommit<ValSelFunction<BoolView>,ValCommitFunction<BoolView> >(home,ba);
152 }
153 default:
154 throw UnknownBranching("Int::assign");
155 }
156 }
157
158}}}
159
160
161// STATISTICS: int-branch
162