main page
modules
namespaces
classes
files
Gecode home
Generated on Wed Jan 1 2020 10:37:59 for Gecode by
doxygen
1.8.16
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
* 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
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
Gecode::IntValBranch::SEL_RANGE_MAX
Select the largest range of the variable domain if it has several ranges, otherwise select values gre...
Definition:
int.hh:4865
Gecode::IntValBranch::SEL_SPLIT_MIN
Select values not greater than mean of smallest and largest value.
Definition:
int.hh:4862
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:4854
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::IntValBranch::SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition:
int.hh:4866
Gecode::Int::Branch::ValCommitEq
Value commit class for equality.
Definition:
branch.hh:506
Gecode::ValBranch::commit
BranchCommit commit(void) const
Return commit function.
Definition:
val.hpp:102
Gecode::BoolAssign::SEL_MAX
Select largest value.
Definition:
int.hh:5005
Gecode::Int::UnknownBranching
Exception: Unknown value or variable selection passed as argument
Definition:
exception.hpp:108
Gecode
Gecode toplevel namespace
Gecode::ValSelFunction
User-defined value selection.
Definition:
val-sel.hpp:65
Gecode::BoolAssign::SEL_MIN
Select smallest value.
Definition:
int.hh:5004
Gecode::BoolValBranch::SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition:
int.hh:4896
Gecode::BoolValBranch::SEL_MIN
Select smallest value.
Definition:
int.hh:4893
Gecode::ValSelCommit
Class for value selection and commit.
Definition:
val-sel-commit.hpp:90
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:43
Gecode::BoolAssign::SEL_RND
Select random value.
Definition:
int.hh:5006
Gecode::IntAssign::SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition:
int.hh:4979
Gecode::IntAssign
Which values to select for assignment.
Definition:
int.hh:4971
Gecode::Int::Branch::ValSelMed
Value selection class for median of view.
Definition:
branch.hh:317
Gecode::BoolValBranch::SEL_RND
Select random value.
Definition:
int.hh:4895
Gecode::IntValBranch::SEL_SPLIT_MAX
Select values greater than mean of smallest and largest value.
Definition:
int.hh:4863
Gecode::IntValBranch::SEL_MAX
Select largest value.
Definition:
int.hh:4860
Gecode::IntValBranch::select
Select select(void) const
Return selection strategy.
Definition:
val.hpp:49
Gecode::IntAssign::SEL_MAX
Select largest value.
Definition:
int.hh:4977
Gecode::IntValBranch::SEL_RND
Select random value.
Definition:
int.hh:4861
branch.hh
Gecode::IntValBranch::SEL_VALUES_MIN
Select all values starting from smallest.
Definition:
int.hh:4867
Gecode::ValSelCommitBase
Base class for value selection and commit.
Definition:
val-sel-commit.hpp:44
Gecode::Int::Branch::ValCommitLq
Value commit class for less or equal.
Definition:
branch.hh:529
Gecode::IntValBranch::SEL_RANGE_MIN
Select the smallest range of the variable domain if it has several ranges, otherwise select values no...
Definition:
int.hh:4864
Gecode::Int::Branch::ValSelAvg
Value selection class for average of view.
Definition:
branch.hh:335
Gecode::IntValBranch::SEL_MED
Select greatest value not greater than the median.
Definition:
int.hh:4859
Gecode::IntAssign::select
Select select(void) const
Return selection strategy.
Definition:
assign.hpp:49
Gecode::BoolValBranch::SEL_MAX
Select largest value.
Definition:
int.hh:4894
Gecode::IntValBranch::SEL_VALUES_MAX
Select all values starting from largest.
Definition:
int.hh:4868
Gecode::BoolAssign::SEL_VAL_COMMIT
Select value according to user-defined functions.
Definition:
int.hh:5007
Gecode::BoolAssign
Which values to select for assignment.
Definition:
int.hh:5000
Gecode::ValCommitFunction
Class for user-defined value commit.
Definition:
val-commit.hpp:65
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:39
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:124
Gecode::IntValBranch::SEL_MIN
Select smallest value.
Definition:
int.hh:4858
Gecode::Int::Branch::ValSelMin
Value selection class for mimimum of view.
Definition:
branch.hh:281
Gecode::IntAssign::SEL_RND
Select random value.
Definition:
int.hh:4978
Gecode::IntAssign::SEL_MIN
Select smallest value.
Definition:
int.hh:4975
Gecode::IntAssign::SEL_MED
Select greatest value not greater than the median.
Definition:
int.hh:4976
Gecode::BoolValBranch
Which values to select for branching first.
Definition:
int.hh:4889