Generated on Wed Jul 21 2021 00:00:00 for Gecode by doxygen 1.9.1
view-sel.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  ViewSel<IntView>*
39  viewsel(Space& home, const IntVarBranch& ivb) {
40  switch (ivb.select()) {
42  return new (home) ViewSelNone<IntView>(home,ivb);
44  return new (home) ViewSelRnd<IntView>(home,ivb);
45  default: break;
46  }
47  if (ivb.tbl() != NULL) {
48  switch (ivb.select()) {
50  return new (home) ViewSelMinTbl<MeritFunction<IntView>>(home,ivb);
52  return new (home) ViewSelMaxTbl<MeritFunction<IntView>>(home,ivb);
54  return new (home) ViewSelMinTbl<MeritMin<IntView>>(home,ivb);
56  return new (home) ViewSelMaxTbl<MeritMin<IntView>>(home,ivb);
58  return new (home) ViewSelMinTbl<MeritMax<IntView>>(home,ivb);
60  return new (home) ViewSelMaxTbl<MeritMax<IntView>>(home,ivb);
62  return new (home) ViewSelMinTbl<MeritSize<IntView>>(home,ivb);
64  return new (home) ViewSelMaxTbl<MeritSize<IntView>>(home,ivb);
66  return new (home) ViewSelMinTbl<MeritDegree<IntView>>(home,ivb);
68  return new (home) ViewSelMaxTbl<MeritDegree<IntView>>(home,ivb);
70  return new (home) ViewSelMinTbl<MeritAFC<IntView>>(home,ivb);
72  return new (home) ViewSelMaxTbl<MeritAFC<IntView>>(home,ivb);
74  return new (home) ViewSelMinTbl<MeritAction<IntView>>(home,ivb);
76  return new (home) ViewSelMaxTbl<MeritAction<IntView>>(home,ivb);
78  return new (home) ViewSelMinTbl<MeritCHB<IntView>>(home,ivb);
80  return new (home) ViewSelMaxTbl<MeritCHB<IntView>>(home,ivb);
82  return new (home) ViewSelMinTbl<MeritDegreeSize<IntView>>(home,ivb);
84  return new (home) ViewSelMaxTbl<MeritDegreeSize<IntView>>(home,ivb);
86  return new (home) ViewSelMinTbl<MeritAFCSize<IntView>>(home,ivb);
88  return new (home) ViewSelMaxTbl<MeritAFCSize<IntView>>(home,ivb);
90  return new (home) ViewSelMinTbl<MeritActionSize<IntView>>(home,ivb);
92  return new (home) ViewSelMaxTbl<MeritActionSize<IntView>>(home,ivb);
94  return new (home) ViewSelMinTbl<MeritCHBSize<IntView>>(home,ivb);
96  return new (home) ViewSelMaxTbl<MeritCHBSize<IntView>>(home,ivb);
98  return new (home) ViewSelMinTbl<MeritRegretMin<IntView>>(home,ivb);
100  return new (home) ViewSelMaxTbl<MeritRegretMin<IntView>>(home,ivb);
102  return new (home) ViewSelMinTbl<MeritRegretMax<IntView>>(home,ivb);
104  return new (home) ViewSelMaxTbl<MeritRegretMax<IntView>>(home,ivb);
105  default:
106  throw UnknownBranching("Int::branch");
107  }
108  } else {
109  switch (ivb.select()) {
111  return new (home) ViewSelMin<MeritFunction<IntView>>(home,ivb);
113  return new (home) ViewSelMax<MeritFunction<IntView>>(home,ivb);
115  return new (home) ViewSelMin<MeritMin<IntView>>(home,ivb);
117  return new (home) ViewSelMax<MeritMin<IntView>>(home,ivb);
119  return new (home) ViewSelMin<MeritMax<IntView>>(home,ivb);
121  return new (home) ViewSelMax<MeritMax<IntView>>(home,ivb);
123  return new (home) ViewSelMin<MeritSize<IntView>>(home,ivb);
125  return new (home) ViewSelMax<MeritSize<IntView>>(home,ivb);
127  return new (home) ViewSelMin<MeritDegree<IntView>>(home,ivb);
129  return new (home) ViewSelMax<MeritDegree<IntView>>(home,ivb);
131  return new (home) ViewSelMin<MeritAFC<IntView>>(home,ivb);
133  return new (home) ViewSelMax<MeritAFC<IntView>>(home,ivb);
135  return new (home) ViewSelMin<MeritAction<IntView>>(home,ivb);
137  return new (home) ViewSelMax<MeritAction<IntView>>(home,ivb);
139  return new (home) ViewSelMin<MeritCHB<IntView>>(home,ivb);
141  return new (home) ViewSelMax<MeritCHB<IntView>>(home,ivb);
143  return new (home) ViewSelMin<MeritDegreeSize<IntView>>(home,ivb);
145  return new (home) ViewSelMax<MeritDegreeSize<IntView>>(home,ivb);
147  return new (home) ViewSelMin<MeritAFCSize<IntView>>(home,ivb);
149  return new (home) ViewSelMax<MeritAFCSize<IntView>>(home,ivb);
151  return new (home) ViewSelMin<MeritActionSize<IntView>>(home,ivb);
153  return new (home) ViewSelMax<MeritActionSize<IntView>>(home,ivb);
155  return new (home) ViewSelMin<MeritCHBSize<IntView>>(home,ivb);
157  return new (home) ViewSelMax<MeritCHBSize<IntView>>(home,ivb);
159  return new (home) ViewSelMin<MeritRegretMin<IntView>>(home,ivb);
161  return new (home) ViewSelMax<MeritRegretMin<IntView>>(home,ivb);
163  return new (home) ViewSelMin<MeritRegretMax<IntView>>(home,ivb);
165  return new (home) ViewSelMax<MeritRegretMax<IntView>>(home,ivb);
166  default:
167  throw UnknownBranching("Int::branch");
168  }
169  }
170  GECODE_NEVER;
171  return NULL;
172  }
173 
175  viewsel(Space& home, const BoolVarBranch& bvb) {
176  switch (bvb.select()) {
178  return new (home) ViewSelNone<BoolView>(home,bvb);
180  return new (home) ViewSelRnd<BoolView>(home,bvb);
181  default: break;
182  }
183  if (bvb.tbl() != NULL) {
184  switch (bvb.select()) {
186  return new (home) ViewSelMinTbl<MeritFunction<BoolView>>(home,bvb);
188  return new (home) ViewSelMaxTbl<MeritFunction<BoolView>>(home,bvb);
190  return new (home) ViewSelMinTbl<MeritDegree<BoolView>>(home,bvb);
192  return new (home) ViewSelMaxTbl<MeritDegree<BoolView>>(home,bvb);
194  return new (home) ViewSelMinTbl<MeritAFC<BoolView>>(home,bvb);
196  return new (home) ViewSelMaxTbl<MeritAFC<BoolView>>(home,bvb);
198  return new (home) ViewSelMinTbl<MeritAction<BoolView>>(home,bvb);
200  return new (home) ViewSelMaxTbl<MeritAction<BoolView>>(home,bvb);
202  return new (home) ViewSelMinTbl<MeritCHB<BoolView>>(home,bvb);
204  return new (home) ViewSelMaxTbl<MeritCHB<BoolView>>(home,bvb);
205  default:
206  throw UnknownBranching("Int::branch");
207  }
208  } else {
209  switch (bvb.select()) {
211  return new (home) ViewSelMin<MeritFunction<BoolView>>(home,bvb);
213  return new (home) ViewSelMax<MeritFunction<BoolView>>(home,bvb);
215  return new (home) ViewSelMin<MeritDegree<BoolView>>(home,bvb);
217  return new (home) ViewSelMax<MeritDegree<BoolView>>(home,bvb);
219  return new (home) ViewSelMin<MeritAFC<BoolView>>(home,bvb);
221  return new (home) ViewSelMax<MeritAFC<BoolView>>(home,bvb);
223  return new (home) ViewSelMin<MeritAction<BoolView>>(home,bvb);
225  return new (home) ViewSelMax<MeritAction<BoolView>>(home,bvb);
227  return new (home) ViewSelMin<MeritCHB<BoolView>>(home,bvb);
229  return new (home) ViewSelMax<MeritCHB<BoolView>>(home,bvb);
230  default:
231  throw UnknownBranching("Int::branch");
232  }
233  }
234  GECODE_NEVER;
235  return NULL;
236  }
237 
238 }}}
239 
240 
241 // STATISTICS: int-branch
242 
Which Boolean variable to select for branching.
Definition: int.hh:4656
Select select(void) const
Return selection strategy.
Definition: var.hpp:340
@ SEL_DEGREE_MIN
With smallest degree.
Definition: int.hh:4664
@ SEL_AFC_MAX
With largest accumulated failure count.
Definition: int.hh:4667
@ SEL_CHB_MIN
With lowest CHB.
Definition: int.hh:4670
@ SEL_MERIT_MIN
With least merit.
Definition: int.hh:4662
@ SEL_ACTION_MIN
With lowest action.
Definition: int.hh:4668
@ SEL_AFC_MIN
With smallest accumulated failure count.
Definition: int.hh:4666
@ SEL_RND
Random (uniform, for tie breaking)
Definition: int.hh:4661
@ SEL_NONE
First unassigned.
Definition: int.hh:4660
@ SEL_ACTION_MAX
With highest action.
Definition: int.hh:4669
@ SEL_CHB_MAX
With highest CHB.
Definition: int.hh:4671
@ SEL_MERIT_MAX
With highest merit.
Definition: int.hh:4663
@ SEL_DEGREE_MAX
With largest degree.
Definition: int.hh:4665
Which integer variable to select for branching.
Definition: int.hh:4570
@ SEL_MAX_MIN
With smallest max.
Definition: int.hh:4588
@ SEL_CHB_MAX
With highest CHB Q-score.
Definition: int.hh:4585
@ SEL_AFC_SIZE_MAX
With largest accumulated failure count divided by domain size.
Definition: int.hh:4595
@ SEL_MIN_MIN
With smallest min.
Definition: int.hh:4586
@ SEL_ACTION_SIZE_MAX
With largest action divided by domain size.
Definition: int.hh:4597
@ SEL_AFC_SIZE_MIN
With smallest accumulated failure count divided by domain size.
Definition: int.hh:4594
@ SEL_REGRET_MIN_MIN
With smallest min-regret.
Definition: int.hh:4605
@ SEL_DEGREE_SIZE_MIN
With smallest degree divided by domain size.
Definition: int.hh:4592
@ SEL_MIN_MAX
With largest min.
Definition: int.hh:4587
@ SEL_REGRET_MIN_MAX
With largest min-regret.
Definition: int.hh:4611
@ SEL_CHB_SIZE_MAX
With largest CHB Q-score divided by domain size.
Definition: int.hh:4599
@ SEL_MAX_MAX
With largest max.
Definition: int.hh:4589
@ SEL_AFC_MIN
With smallest accumulated failure count.
Definition: int.hh:4580
@ SEL_SIZE_MIN
With smallest domain size.
Definition: int.hh:4590
@ SEL_AFC_MAX
With largest accumulated failure count.
Definition: int.hh:4581
@ SEL_MERIT_MAX
With highest merit.
Definition: int.hh:4577
@ SEL_DEGREE_MAX
With largest degree.
Definition: int.hh:4579
@ SEL_SIZE_MAX
With largest domain size.
Definition: int.hh:4591
@ SEL_ACTION_MIN
With lowest action.
Definition: int.hh:4582
@ SEL_ACTION_MAX
With highest action.
Definition: int.hh:4583
@ SEL_CHB_MIN
With lowest CHB Q-score.
Definition: int.hh:4584
@ SEL_RND
Random (uniform, for tie breaking)
Definition: int.hh:4575
@ SEL_NONE
First unassigned.
Definition: int.hh:4574
@ SEL_MERIT_MIN
With least merit.
Definition: int.hh:4576
@ SEL_REGRET_MAX_MIN
With smallest max-regret.
Definition: int.hh:4617
@ SEL_CHB_SIZE_MIN
With smallest CHB Q-score divided by domain size.
Definition: int.hh:4598
@ SEL_DEGREE_MIN
With smallest degree.
Definition: int.hh:4578
@ SEL_REGRET_MAX_MAX
With largest max-regret.
Definition: int.hh:4623
@ SEL_ACTION_SIZE_MIN
With smallest action divided by domain size.
Definition: int.hh:4596
@ SEL_DEGREE_SIZE_MAX
With largest degree divided by domain size.
Definition: int.hh:4593
Select select(void) const
Return selection strategy.
Definition: var.hpp:69
Merit class for AFC over size.
Definition: branch.hh:141
Merit class for action over size.
Definition: branch.hh:166
Merit class for CHB over size.
Definition: branch.hh:191
Merit class for degree over size.
Definition: branch.hh:123
Merit class for maximum.
Definition: branch.hh:87
Merit class for mimimum of integer views.
Definition: branch.hh:69
Merit class for maximum regret.
Definition: branch.hh:234
Merit class for minimum regret.
Definition: branch.hh:216
Merit class for size.
Definition: branch.hh:105
Exception: Unknown value or variable selection passed as argument
Definition: exception.hpp:108
Merit class for AFC.
Definition: merit.hpp:108
Merit class for action.
Definition: merit.hpp:130
Merit class for CHB.
Definition: merit.hpp:153
Merit class for degree.
Definition: merit.hpp:93
Merit class for user-defined merit function.
Definition: merit.hpp:68
Computation spaces.
Definition: core.hpp:1742
BranchTbl tbl(void) const
Return tie-break limit function.
Definition: var.hpp:168
Select view with largest merit taking tie-break limit into account.
Definition: view-sel.hpp:355
Select view with largest merit.
Definition: view-sel.hpp:335
Select view with least merit taking tie-break limit into account.
Definition: view-sel.hpp:315
Select view with least merit.
Definition: view-sel.hpp:295
Select the first unassigned view.
Definition: view-sel.hpp:109
Select a view randomly.
Definition: view-sel.hpp:149
Abstract class for view selection.
Definition: view-sel.hpp:44
ViewSel< IntView > * viewsel(Space &home, const IntVarBranch &ivb)
Return view selectors for integer views.
Definition: view-sel.cpp:39
#define GECODE_NEVER
Assert that this command is never executed.
Definition: macros.hpp:56