main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Jan 28 2020 00:00:00 for Gecode by
doxygen
1.8.17
gecode
int
branch
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
) &&
45
(ivb.
select
() !=
IntValBranch::SEL_VALUES_MAX
));
46
switch
(ivb.
select
()) {
47
case
IntValBranch::SEL_MIN
:
48
return
new
(home)
49
ValSelCommit
<
ValSelMin<IntView>
,
ValCommitEq<IntView>
>(home,ivb);
50
case
IntValBranch::SEL_MED
:
51
return
new
(home)
52
ValSelCommit
<
ValSelMed<IntView>
,
ValCommitEq<IntView>
>(home,ivb);
53
case
IntValBranch::SEL_MAX
:
54
return
new
(home)
55
ValSelCommit
<
ValSelMax<IntView>
,
ValCommitEq<IntView>
>(home,ivb);
56
case
IntValBranch::SEL_RND
:
57
return
new
(home)
58
ValSelCommit
<
ValSelRnd<IntView>
,
ValCommitEq<IntView>
>(home,ivb);
59
case
IntValBranch::SEL_SPLIT_MIN
:
60
return
new
(home)
61
ValSelCommit
<
ValSelAvg<IntView>
,
ValCommitLq<IntView>
>(home,ivb);
62
case
IntValBranch::SEL_SPLIT_MAX
:
63
return
new
(home)
64
ValSelCommit
<
ValSelAvg<IntView>
,
ValCommitGr<IntView>
>(home,ivb);
65
case
IntValBranch::SEL_RANGE_MIN
:
66
return
new
(home)
67
ValSelCommit
<
ValSelRangeMin
,
ValCommitLq<IntView>
>(home,ivb);
68
case
IntValBranch::SEL_RANGE_MAX
:
69
return
new
(home)
70
ValSelCommit
<
ValSelRangeMax
,
ValCommitGq<IntView>
>(home,ivb);
71
case
IntValBranch::SEL_VAL_COMMIT
:
72
if
(!ivb.
commit
()) {
73
return
new
(home)
74
ValSelCommit
<
ValSelFunction<IntView>
,
ValCommitEq<IntView>
>(home,ivb);
75
}
else
{
76
return
new
(home)
77
ValSelCommit
<
ValSelFunction<IntView>
,
ValCommitFunction<IntView>
>(home,ivb);
78
}
79
default
:
80
throw
UnknownBranching
(
"Int::branch"
);
81
}
82
}
83
84
ValSelCommitBase<IntView,int>
*
85
valselcommit
(
Space
& home,
const
IntAssign
& ia) {
86
switch
(ia.
select
()) {
87
case
IntAssign::SEL_MIN
:
88
return
new
(home)
89
ValSelCommit
<
ValSelMin<IntView>
,
ValCommitEq<IntView>
>(home,ia);
90
case
IntAssign::SEL_MED
:
91
return
new
(home)
92
ValSelCommit
<
ValSelMed<IntView>
,
ValCommitEq<IntView>
>(home,ia);
93
case
IntAssign::SEL_MAX
:
94
return
new
(home)
95
ValSelCommit
<
ValSelMax<IntView>
,
ValCommitEq<IntView>
>(home,ia);
96
case
IntAssign::SEL_RND
:
97
return
new
(home)
98
ValSelCommit
<
ValSelRnd<IntView>
,
ValCommitEq<IntView>
>(home,ia);
99
case
IntAssign::SEL_VAL_COMMIT
:
100
if
(!ia.
commit
()) {
101
return
new
(home)
102
ValSelCommit
<
ValSelFunction<IntView>
,
ValCommitEq<IntView>
>(home,ia);
103
}
else
{
104
return
new
(home)
105
ValSelCommit
<
ValSelFunction<IntView>
,
ValCommitFunction<IntView>
>(home,ia);
106
}
107
default
:
108
throw
UnknownBranching
(
"Int::assign"
);
109
}
110
}
111
112
ValSelCommitBase<BoolView,int>
*
113
valselcommit
(
Space
& home,
const
BoolValBranch
& bvb) {
114
switch
(bvb.
select
()) {
115
case
BoolValBranch::SEL_MIN
:
116
return
new
(home)
117
ValSelCommit
<
ValSelMin<BoolView>
,
ValCommitEq<BoolView>
>(home,bvb);
118
case
BoolValBranch::SEL_MAX
:
119
return
new
(home)
120
ValSelCommit
<
ValSelMax<BoolView>
,
ValCommitEq<BoolView>
>(home,bvb);
121
case
BoolValBranch::SEL_RND
:
122
return
new
(home)
123
ValSelCommit
<
ValSelRnd<BoolView>
,
ValCommitEq<BoolView>
>(home,bvb);
124
case
BoolValBranch::SEL_VAL_COMMIT
:
125
if
(!bvb.
commit
()) {
126
return
new
(home)
127
ValSelCommit
<
ValSelFunction<BoolView>
,
ValCommitEq<BoolView>
>(home,bvb);
128
}
else
{
129
return
new
(home)
130
ValSelCommit
<
ValSelFunction<BoolView>
,
ValCommitFunction<BoolView>
>(home,bvb);
131
}
132
default
:
133
throw
UnknownBranching
(
"Int::branch"
);
134
}
135
}
136
137
ValSelCommitBase<BoolView,int>
*
138
valselcommit
(
Space
& home,
const
BoolAssign
&
ba
) {
139
switch
(
ba
.select()) {
140
case
BoolAssign::SEL_MIN
:
141
return
new
(home)
142
ValSelCommit
<
ValSelMin<BoolView>
,
ValCommitEq<BoolView>
>(home,
ba
);
143
case
BoolAssign::SEL_MAX
:
144
return
new
(home)
145
ValSelCommit
<
ValSelMax<BoolView>
,
ValCommitEq<BoolView>
>(home,
ba
);
146
case
BoolAssign::SEL_RND
:
147
return
new
(home)
148
ValSelCommit
<
ValSelRnd<BoolView>
,
ValCommitEq<BoolView>
>(home,
ba
);
149
case
BoolAssign::SEL_VAL_COMMIT
:
150
if
(!
ba
.commit()) {
151
return
new
(home)
152
ValSelCommit
<
ValSelFunction<BoolView>
,
ValCommitEq<BoolView>
>(home,
ba
);
153
}
else
{
154
return
new
(home)
155
ValSelCommit
<
ValSelFunction<BoolView>
,
ValCommitFunction<BoolView>
>(home,
ba
);
156
}
157
default
:
158
throw
UnknownBranching
(
"Int::assign"
);
159
}
160
}
161
162
}}}
163
164
165
// STATISTICS: int-branch
166
Gecode::IntValBranch::SEL_RANGE_MAX
@ SEL_RANGE_MAX
Select the largest range of the variable domain if it has several ranges, otherwise select values gre...
Definition:
int.hh:4514
Gecode::IntValBranch::SEL_SPLIT_MIN
@ SEL_SPLIT_MIN
Select values not greater than mean of smallest and largest value.
Definition:
int.hh:4511
Gecode::Int::Branch::ValSelRnd
Value selection class for random value of view.
Definition:
branch.hh:353
Gecode::Int::Branch::ValCommitGr
Value commit class for greater.
Definition:
branch.hh:575
Gecode::Int::Branch::ValSelMax
Value selection class for maximum of view.
Definition:
branch.hh:299
Gecode::IntValBranch
Which values to select for branching first.
Definition:
int.hh:4503
Gecode::Space
Computation spaces.
Definition:
core.hpp:1748
Gecode::IntValBranch::SEL_VAL_COMMIT
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition:
int.hh:4515
Gecode::Int::Branch::ValCommitEq
Value commit class for equality.
Definition:
branch.hh:506
Gecode::ValBranch::commit
BranchCommit commit(void) const
Return commit function.
Definition:
branch-val.hpp:106
Gecode::BoolAssign::SEL_MAX
@ SEL_MAX
Select largest value.
Definition:
int.hh:4654
Gecode::Int::UnknownBranching
Exception: Unknown value or variable selection passed as argument
Definition:
exception.hpp:112
Gecode
Gecode toplevel namespace
Gecode::ValSelFunction
User-defined value selection.
Definition:
brancher-val-sel.hpp:69
Gecode::BoolAssign::SEL_MIN
@ SEL_MIN
Select smallest value.
Definition:
int.hh:4653
Gecode::BoolValBranch::SEL_VAL_COMMIT
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition:
int.hh:4545
Gecode::BoolValBranch::SEL_MIN
@ SEL_MIN
Select smallest value.
Definition:
int.hh:4542
Gecode::ValSelCommit
Class for value selection and commit.
Definition:
brancher-val-sel-commit.hpp:95
Gecode::Int::Branch::ValCommitGq
Value commit class for greater or equal.
Definition:
branch.hh:552
Gecode::Int::Branch::ValSelRangeMax
Value selection class for maximum range of integer view.
Definition:
branch.hh:393
Gecode::ba
IntPropLevel ba(IntPropLevel ipl)
Extract basic or advanced from propagation level.
Definition:
ipl.hpp:53
Gecode::BoolAssign::SEL_RND
@ SEL_RND
Select random value.
Definition:
int.hh:4655
Gecode::IntAssign::SEL_VAL_COMMIT
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition:
int.hh:4628
Gecode::IntAssign
Which values to select for assignment.
Definition:
int.hh:4620
Gecode::Int::Branch::ValSelMed
Value selection class for median of view.
Definition:
branch.hh:317
Gecode::BoolValBranch::SEL_RND
@ SEL_RND
Select random value.
Definition:
int.hh:4544
Gecode::IntValBranch::SEL_SPLIT_MAX
@ SEL_SPLIT_MAX
Select values greater than mean of smallest and largest value.
Definition:
int.hh:4512
Gecode::IntValBranch::SEL_MAX
@ SEL_MAX
Select largest value.
Definition:
int.hh:4509
Gecode::IntValBranch::select
Select select(void) const
Return selection strategy.
Definition:
val.hpp:53
Gecode::IntAssign::SEL_MAX
@ SEL_MAX
Select largest value.
Definition:
int.hh:4626
Gecode::IntValBranch::SEL_RND
@ SEL_RND
Select random value.
Definition:
int.hh:4510
branch.hh
Gecode::IntValBranch::SEL_VALUES_MIN
@ SEL_VALUES_MIN
Select all values starting from smallest.
Definition:
int.hh:4516
Gecode::ValSelCommitBase
Base class for value selection and commit.
Definition:
brancher-val-sel-commit.hpp:48
Gecode::Int::Branch::ValCommitLq
Value commit class for less or equal.
Definition:
branch.hh:529
Gecode::IntValBranch::SEL_RANGE_MIN
@ SEL_RANGE_MIN
Select the smallest range of the variable domain if it has several ranges, otherwise select values no...
Definition:
int.hh:4513
Gecode::Int::Branch::ValSelAvg
Value selection class for average of view.
Definition:
branch.hh:335
Gecode::IntValBranch::SEL_MED
@ SEL_MED
Select greatest value not greater than the median.
Definition:
int.hh:4508
Gecode::IntAssign::select
Select select(void) const
Return selection strategy.
Definition:
assign.hpp:53
Gecode::BoolValBranch::SEL_MAX
@ SEL_MAX
Select largest value.
Definition:
int.hh:4543
Gecode::IntValBranch::SEL_VALUES_MAX
@ SEL_VALUES_MAX
Select all values starting from largest.
Definition:
int.hh:4517
Gecode::BoolAssign::SEL_VAL_COMMIT
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition:
int.hh:4656
Gecode::BoolAssign
Which values to select for assignment.
Definition:
int.hh:4649
Gecode::ValCommitFunction
Class for user-defined value commit.
Definition:
brancher-val-commit.hpp:69
Gecode::Int::Branch::valselcommit
ValSelCommitBase< IntView, int > * valselcommit(Space &home, const IntValBranch &ivb)
Return value and commit for integer views.
Definition:
val-sel-commit.cpp:43
Gecode::Int::Branch::ValSelRangeMin
Value selection class for minimum range of integer view.
Definition:
branch.hh:377
Gecode::BoolValBranch::select
Select select(void) const
Return selection strategy.
Definition:
val.hpp:128
Gecode::IntValBranch::SEL_MIN
@ SEL_MIN
Select smallest value.
Definition:
int.hh:4507
Gecode::Int::Branch::ValSelMin
Value selection class for mimimum of view.
Definition:
branch.hh:281
Gecode::IntAssign::SEL_RND
@ SEL_RND
Select random value.
Definition:
int.hh:4627
Gecode::IntAssign::SEL_MIN
@ SEL_MIN
Select smallest value.
Definition:
int.hh:4624
Gecode::IntAssign::SEL_MED
@ SEL_MED
Select greatest value not greater than the median.
Definition:
int.hh:4625
Gecode::BoolValBranch
Which values to select for branching first.
Definition:
int.hh:4538