main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Oct 22 2013 00:49:00 for Gecode by
doxygen
1.8.4
gecode
float
branch.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: 2013-05-29 13:53:43 +0200 (Wed, 29 May 2013) $ by $Author: schulte $
11
* $Revision: 13672 $
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/float/branch.hh
>
39
40
namespace
Gecode {
41
42
BrancherHandle
43
branch
(
Home
home,
const
FloatVarArgs
&
x
,
44
FloatVarBranch
vars,
FloatValBranch
vals,
45
FloatBranchFilter
bf,
FloatVarValPrint
vvp) {
46
using namespace
Float;
47
if
(home.
failed
())
return
BrancherHandle
();
48
vars.
expand
(home,x);
49
ViewArray<FloatView>
xv(home,x);
50
ViewSel<FloatView>
* vs[1] = {
51
Branch::viewsel
(home,vars)
52
};
53
return
ViewValBrancher<FloatView,1,FloatNumBranch,2>::post
54
(home,xv,vs,
Branch::valselcommit
(home,vals),bf,vvp);
55
}
56
57
BrancherHandle
58
branch
(
Home
home,
const
FloatVarArgs
&
x
,
59
TieBreak<FloatVarBranch>
vars,
FloatValBranch
vals,
60
FloatBranchFilter
bf,
FloatVarValPrint
vvp) {
61
using namespace
Float;
62
if
(home.
failed
())
return
BrancherHandle
();
63
vars.
a
.expand(home,x);
64
if
((vars.
a
.select() ==
FloatVarBranch::SEL_NONE
) ||
65
(vars.
a
.select() ==
FloatVarBranch::SEL_RND
))
66
vars.
b
=
FLOAT_VAR_NONE
();
67
vars.
b
.expand(home,x);
68
if
((vars.
b
.select() ==
FloatVarBranch::SEL_NONE
) ||
69
(vars.
b
.select() ==
FloatVarBranch::SEL_RND
))
70
vars.
c
=
FLOAT_VAR_NONE
();
71
vars.
c
.expand(home,x);
72
if
((vars.
c
.select() ==
FloatVarBranch::SEL_NONE
) ||
73
(vars.
c
.select() ==
FloatVarBranch::SEL_RND
))
74
vars.
d
=
FLOAT_VAR_NONE
();
75
vars.
d
.expand(home,x);
76
if
(vars.
b
.select() ==
FloatVarBranch::SEL_NONE
) {
77
return
branch
(home,x,vars.
a
,vals,bf,vvp);
78
}
else
{
79
ViewArray<FloatView>
xv(home,x);
80
ValSelCommitBase<FloatView,FloatNumBranch>
*
81
vsc =
Branch::valselcommit
(home,vals);
82
if
(vars.
c
.select() ==
FloatVarBranch::SEL_NONE
) {
83
ViewSel<FloatView>
* vs[2] = {
84
Branch::viewsel
(home,vars.
a
),
Branch::viewsel
(home,vars.
b
)
85
};
86
return
ViewValBrancher<FloatView,2,FloatNumBranch,2>
87
::post
(home,xv,vs,vsc,bf,vvp);
88
}
else
if
(vars.
d
.select() ==
FloatVarBranch::SEL_NONE
) {
89
ViewSel<FloatView>
* vs[3] = {
90
Branch::viewsel
(home,vars.
a
),
Branch::viewsel
(home,vars.
b
),
91
Branch::viewsel
(home,vars.
c
)
92
};
93
return
ViewValBrancher<FloatView,3,FloatNumBranch,2>
94
::post
(home,xv,vs,vsc,bf,vvp);
95
}
else
{
96
ViewSel<FloatView>
* vs[4] = {
97
Branch::viewsel
(home,vars.
a
),
Branch::viewsel
(home,vars.
b
),
98
Branch::viewsel
(home,vars.
c
),
Branch::viewsel
(home,vars.
d
)
99
};
100
return
ViewValBrancher<FloatView,4,FloatNumBranch,2>
101
::post
(home,xv,vs,vsc,bf,vvp);
102
}
103
}
104
}
105
106
BrancherHandle
107
branch
(
Home
home,
FloatVar
x
,
FloatValBranch
vals,
FloatVarValPrint
vvp) {
108
FloatVarArgs
xv(1); xv[0]=
x
;
109
return
branch
(home, xv,
FLOAT_VAR_NONE
(), vals, NULL, vvp);
110
}
111
112
BrancherHandle
113
assign
(
Home
home,
const
FloatVarArgs
&
x
,
FloatAssign
fa,
114
FloatBranchFilter
bf,
FloatVarValPrint
vvp) {
115
using namespace
Float;
116
if
(home.
failed
())
return
BrancherHandle
();
117
ViewArray<FloatView>
xv(home,x);
118
ViewSel<FloatView>
* vs[1] = {
119
new
(home)
ViewSelNone<FloatView>
(home,
FLOAT_VAR_NONE
())
120
};
121
return
ViewValBrancher<FloatView,1,FloatNumBranch,1>::post
122
(home,xv,vs,
Branch::valselcommit
(home,fa),bf,vvp);
123
}
124
125
BrancherHandle
126
assign
(
Home
home,
FloatVar
x,
FloatAssign
fa,
FloatVarValPrint
vvp) {
127
FloatVarArgs
xv(1); xv[0]=
x
;
128
return
assign
(home, xv, fa, NULL, vvp);
129
}
130
131
}
132
133
// STATISTICS: float-post