main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Mar 24 2020 14:04:04 for Gecode by
doxygen
1.8.17
gecode
float
transcendental
exp-log.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
Transcendental {
35
36
/*
37
* Bounds consistent exponential operator
38
*
39
*/
40
41
template
<
class
A,
class
B>
42
forceinline
43
Exp<A,B>::Exp
(
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
Exp<A,B>::post
(
Home
home, A x0, B x1) {
49
if
(x0 == x1) {
50
return
ES_FAILED
;
51
}
else
{
52
GECODE_ME_CHECK
(x1.gq(home,0.0));
53
}
54
GECODE_ME_CHECK
(x1.eq(home,
exp
(x0.domain())));
55
if
(x1.max() == 0.0)
56
return
ES_FAILED
;
57
GECODE_ME_CHECK
(x0.eq(home,
log
(x1.domain())));
58
(void)
new
(home)
Exp<A,B>
(home,x0,x1);
59
return
ES_OK
;
60
}
61
62
63
template
<
class
A,
class
B>
64
forceinline
65
Exp<A,B>::Exp
(
Space
& home,
Exp<A,B>
&
p
)
66
:
MixBinaryPropagator
<A,
PC_FLOAT_BND
,B,
PC_FLOAT_BND
>(home,
p
) {}
67
68
template
<
class
A,
class
B>
69
Actor
*
70
Exp<A,B>::copy
(
Space
& home) {
71
return
new
(home)
Exp<A,B>
(home,*
this
);
72
}
73
74
template
<
class
A,
class
B>
75
ExecStatus
76
Exp<A,B>::propagate
(
Space
& home,
const
ModEventDelta
&) {
77
GECODE_ME_CHECK
(x1.eq(home,
exp
(x0.domain())));
78
if
(x1.max() == 0.0)
79
return
ES_FAILED
;
80
GECODE_ME_CHECK
(x0.eq(home,
log
(x1.domain())));
81
return
x0.assigned() ? home.
ES_SUBSUMED
(*
this
) :
ES_FIX
;
82
}
83
84
85
/*
86
* Bounds consistent logarithm operator with base
87
*
88
*/
89
90
template
<
class
A,
class
B>
91
forceinline
92
Pow<A,B>::Pow
(
Home
home,
FloatNum
base0, A x0, B x1)
93
:
MixBinaryPropagator
<A,
PC_FLOAT_BND
,B,
PC_FLOAT_BND
>(home,x0,x1),
94
base
(base0) {}
95
96
template
<
class
A,
class
B>
97
ExecStatus
98
Pow<A,B>::post
(
Home
home,
FloatNum
base
, A x0, B x1) {
99
if
(
base
<= 0)
return
ES_FAILED
;
100
if
(x0 == x1) {
101
GECODE_ME_CHECK
(x0.eq(home,0.0));
102
}
else
{
103
GECODE_ME_CHECK
(x1.gq(home,0.0));
104
if
(x1.max() == 0.0)
105
return
ES_FAILED
;
106
GECODE_ME_CHECK
(x0.eq(home,
log
(x1.domain())/
log
(
base
)));
107
GECODE_ME_CHECK
(x1.eq(home,
exp
(x0.domain()*
log
(
base
))));
108
(void)
new
(home)
Pow<A,B>
(home,
base
,x0,x1);
109
}
110
return
ES_OK
;
111
}
112
113
template
<
class
A,
class
B>
114
forceinline
115
Pow<A,B>::Pow
(
Space
& home,
Pow<A,B>
&
p
)
116
:
MixBinaryPropagator
<A,
PC_FLOAT_BND
,B,
PC_FLOAT_BND
>(home,
p
),
117
base
(
p
.
base
) {}
118
119
template
<
class
A,
class
B>
120
Actor
*
121
Pow<A,B>::copy
(
Space
& home) {
122
return
new
(home)
Pow<A,B>
(home,*
this
);
123
}
124
125
template
<
class
A,
class
B>
126
ExecStatus
127
Pow<A,B>::propagate
(
Space
& home,
const
ModEventDelta
&) {
128
if
(x1.max() == 0.0)
129
return
ES_FAILED
;
130
GECODE_ME_CHECK
(x0.eq(home,
log
(x1.domain())/
log
(
base
)));
131
GECODE_ME_CHECK
(x1.eq(home,
exp
(x0.domain()*
log
(
base
))));
132
return
x0.assigned() ? home.
ES_SUBSUMED
(*
this
) :
ES_FIX
;
133
}
134
135
}}}
136
137
// STATISTICS: float-prop
138
Gecode::Float::Transcendental::Exp::post
static ExecStatus post(Home home, A x0, B x1)
Post propagator for .
Definition:
exp-log.hpp:48
Gecode::Space::ES_SUBSUMED
ExecStatus ES_SUBSUMED(Propagator &p)
Definition:
core.hpp:3563
Gecode::Float::Transcendental::Pow::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
exp-log.hpp:127
Gecode::Float::Transcendental::Exp::Exp
Exp(Space &home, Exp &p)
Constructor for cloning p.
Definition:
exp-log.hpp:65
Gecode::log
void log(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition:
transcendental.cpp:53
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::Transcendental::Pow::post
static ExecStatus post(Home home, FloatNum base, A x0, B x1)
Post propagator for .
Definition:
exp-log.hpp:98
Gecode::Space
Computation spaces.
Definition:
core.hpp:1742
Gecode::Actor
Base-class for both propagators and branchers.
Definition:
core.hpp:628
Gecode::Float::Transcendental::Pow
Propagator for bounds consistent pow operator
Definition:
transcendental.hh:83
Gecode::Float::Transcendental::Exp::propagate
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Definition:
exp-log.hpp:76
Gecode::Float::Transcendental::Exp::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition:
exp-log.hpp:70
Gecode
Gecode toplevel namespace
Gecode::MixBinaryPropagator
Mixed binary propagator.
Definition:
pattern.hpp:204
Gecode::Home
Home class for posting propagators
Definition:
core.hpp:856
Gecode::Float::Transcendental::Pow::copy
virtual Actor * copy(Space &home)
Create copy during cloning.
Definition:
exp-log.hpp:121
Gecode::FloatNum
double FloatNum
Floating point number base type.
Definition:
float.hh:106
Gecode::Search::Config::base
const double base
Base for geometric restart sequence.
Definition:
search.hh:126
Gecode::ES_FIX
@ ES_FIX
Propagation has computed fixpoint.
Definition:
core.hpp:477
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Float::Transcendental::Exp
Propagator for bounds consistent exp operator
Definition:
transcendental.hh:55
GECODE_ME_CHECK
#define GECODE_ME_CHECK(me)
Check whether modification event me is failed, and forward failure.
Definition:
macros.hpp:52
Gecode::exp
void exp(Home home, FloatVar x0, FloatVar x1)
Post propagator for .
Definition:
transcendental.cpp:45
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::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
Gecode::Float::Transcendental::Pow::Pow
Pow(Space &home, Pow &p)
Constructor for cloning p.
Definition:
exp-log.hpp:115