main page
modules
namespaces
classes
files
Gecode home
Generated on Sun Aug 9 2020 05:34:08 for Gecode by
doxygen
1.8.18
gecode
float
trigonometric
asinacos.hpp
Go to the documentation of this file.
1
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
/*
3
* Main authors:
4
* Vincent Barichard <Vincent.Barichard@univ-angers.fr>
5
*
6
* Copyright:
7
* Vincent Barichard, 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
namespace
Gecode
{
namespace
Float {
namespace
Trigonometric {
35
36
/*
37
* Bounds consistent arc sinus operator
38
*
39
*/
40
41
template
<
class
A,
class
B>
42
forceinline
43
ASin<A,B>::ASin
(
Home
home, A x0, B x1)
44
:
MixBinaryPropagator
<A,
PC_FLOAT_BND
,B,
PC_FLOAT_BND
>(home,x0,x1) {}
45
46
template
<
class
A,
class
B>
47
ExecStatus
48
ASin<A,B>::post
(
Home
home, A x0, B x1) {
49
if
(x0 == x1) {
50
GECODE_ME_CHECK
(x0.eq(home,0.0));
51
}
else
{
52
GECODE_ME_CHECK
(x0.gq(home,-1.0));
53
GECODE_ME_CHECK
(x0.lq(home,1.0));
54
GECODE_ME_CHECK
(x1.eq(home,
asin
(x0.domain())));
55
GECODE_ME_CHECK
(x0.eq(home,
sin
(x1.domain())));
56
(void)
new
(home)
ASin<A,B>
(home,x0,x1);
57
}
58
return
ES_OK
;
59
}
60
61
62
template
<
class
A,
class
B>
63
forceinline
64
ASin<A,B>::ASin
(
Space
& home,
ASin<A,B>
&
p
)
65
:
MixBinaryPropagator
<A,
PC_FLOAT_BND
,B,
PC_FLOAT_BND
>(home,
p
) {}
66
67
template
<
class
A,
class
B>
68
Actor
*
69
ASin<A,B>::copy
(
Space
& home) {
70
return
new
(home)
ASin<A,B>
(home,*
this
);
71
}
72
73
template
<
class
A,
class
B>
74
ExecStatus
75
ASin<A,B>::propagate
(
Space
& home,
const
ModEventDelta
&) {
76
if
((x0.max() < -1) || (x0.min() > 1))
return
ES_FAILED
;
77
GECODE_ME_CHECK
(x1.eq(home,
asin
(x0.domain())));
78
GECODE_ME_CHECK
(x0.eq(home,
sin
(x1.domain())));
79
return
(x0.assigned() || x1.assigned()) ? home.
ES_SUBSUMED
(*
this
) :
ES_FIX
;
80
}
81
82
83
/*
84
* Bounds consistent arc cosinus operator
85
*
86
*/
87
88
template
<
class
A,
class
B>
89
forceinline
90
ACos<A,B>::ACos
(
Home
home, A x0, B x1)
91
:
MixBinaryPropagator
<A,
PC_FLOAT_BND
,B,
PC_FLOAT_BND
>(home,x0,x1) {}
92
93
template
<
class
A,
class
B>
94
ExecStatus
95
ACos<A,B>::post
(
Home
home, A x0, B x1) {
96
if
(x0 == x1) {
97
GECODE_ME_CHECK
(x0.gq(home,0.7390851332151));
98
GECODE_ME_CHECK
(x0.lq(home,0.7390851332152));
99
bool
mod
;
100
do
{
101
mod
=
false
;
102
GECODE_ME_CHECK_MODIFIED
(
mod
,x0.eq(home,
acos
(x0.val())));
103
}
while
(
mod
);
104
}
else
{
105
GECODE_ME_CHECK
(x0.gq(home,-1.0));
106
GECODE_ME_CHECK
(x0.lq(home,1.0));
107
GECODE_ME_CHECK
(x1.eq(home,
acos
(x0.domain())));
108
GECODE_ME_CHECK
(x0.eq(home,
cos
(x1.domain())));
109
(void)
new
(home)
ACos<A,B>
(home,x0,x1);
110
}
111
return
ES_OK
;
112
}
113
114
115
template
<
class
A,
class
B>
116
forceinline
117
ACos<A,B>::ACos
(
Space
& home,
ACos<A,B>
&
p
)
118
:
MixBinaryPropagator
<A,
PC_FLOAT_BND
,B,
PC_FLOAT_BND
>(home,
p
) {}
119
120
template
<
class
A,
class
B>
121
Actor
*
122
ACos<A,B>::copy
(
Space
& home) {
123
return
new
(home)
ACos<A,B>
(home,*
this
);
124
}
125
126
template
<
class
A,
class
B>
127
ExecStatus
128
ACos<A,B>::propagate
(
Space
& home,
const
ModEventDelta
&) {
129
if
((x0.max() < -1) || (x0.min() > 1))
return
ES_FAILED
;
130
GECODE_ME_CHECK
(x1.eq(home,
acos
(x0.domain())));
131
GECODE_ME_CHECK
(x0.eq(home,
cos
(x1.domain())));
132
return
(x0.assigned() || x1.assigned()) ? home.
ES_SUBSUMED
(*
this
) :
ES_FIX
;
133
}
134
135
}}}
136
137
// STATISTICS: float-prop
138
Gecode::Float::Trigonometric::ACos::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
asinacos.hpp:128
GECODE_ME_CHECK_MODIFIED
#define GECODE_ME_CHECK_MODIFIED(modified, me)
Check whether me is failed or modified, and forward failure.
Definition:
macros.hpp:64
Gecode::Space::ES_SUBSUMED
ExecStatus ES_SUBSUMED(Propagator &p)
Definition:
core.hpp:3563
Gecode::Float::PC_FLOAT_BND
const Gecode::PropCond PC_FLOAT_BND
Propagate when minimum or maximum of a view changes.
Definition:
var-type.hpp:292
Gecode::Float::Trigonometric::ASin::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition:
asinacos.hpp:69
Gecode::sin
void sin(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition:
trigonometric.cpp:52
Gecode::Float::Trigonometric::ACos
Propagator for bounds consistent arc cosinus operator
Definition:
trigonometric.hh:139
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Actor
Base-class for both propagators and branchers.
Definition:
core.hpp:628
Gecode::acos
void acos(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition:
trigonometric.cpp:59
Gecode
Gecode toplevel namespace
Gecode::MixBinaryPropagator
Mixed binary propagator.
Definition:
pattern.hpp:204
Gecode::Float::Trigonometric::ASin::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
asinacos.hpp:75
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
Gecode::Float::Trigonometric::ACos::post
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Definition:
asinacos.hpp:95
Gecode::Float::Trigonometric::ACos::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition:
asinacos.hpp:122
Gecode::mod
void mod(Home home, IntVar x0, IntVar x1, IntVar x2, IntPropLevel ipl)
Post propagator for .
Definition:
arithmetic.cpp:360
Gecode::ES_FIX
@ ES_FIX
Propagation has computed fixpoint.
Definition:
core.hpp:477
Gecode::asin
void asin(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition:
trigonometric.cpp:45
forceinline
#define forceinline
Definition:
config.hpp:185
GECODE_ME_CHECK
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition:
macros.hpp:52
Gecode::Float::Trigonometric::ACos::ACos
ACos(Space &home, ACos &p)
Constructor for cloning p.
Definition:
asinacos.hpp:117
Gecode::Float::Trigonometric::ASin::post
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Definition:
asinacos.hpp:48
Gecode::Float::Trigonometric::ASin
Propagator for bounds consistent arc sinus operator
Definition:
trigonometric.hh:111
Gecode::Float::Trigonometric::ASin::ASin
ASin(Space &home, ASin &p)
Constructor for cloning p.
Definition:
asinacos.hpp:64
Gecode::ES_FAILED
@ ES_FAILED
Execution has resulted in failure.
Definition:
core.hpp:474
Gecode::ModEventDelta
int ModEventDelta
Modification event deltas.
Definition:
core.hpp:89
Gecode::cos
void cos(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition:
trigonometric.cpp:66
Gecode::ES_OK
@ ES_OK
Execution is okay.
Definition:
core.hpp:476
p
int p
Number of positive literals for node type.
Definition:
bool-expr.cpp:232
Gecode::ExecStatus
ExecStatus
Definition:
core.hpp:472