Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthias Mayr
limbo
Commits
c56afe28
Commit
c56afe28
authored
Sep 14, 2016
by
Konstantinos Chatzilygeroudis
Browse files
Fixes EI
parent
d4447703
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/limbo/acqui/ei.hpp
View file @
c56afe28
...
...
@@ -88,16 +88,17 @@ namespace limbo {
double
sigma
=
std
::
sqrt
(
sigma_sq
);
// If \sigma(x) = 0 or we do not have any observation yet we return 0
if
(
sigma
<
1e-10
||
_model
.
observation
s
().
size
()
<
1
)
if
(
sigma
<
1e-10
||
_model
.
sample
s
().
size
()
<
1
)
return
0.0
;
// Compute EI(x)
// First find the best so far observation
std
::
vector
<
Eigen
::
VectorXd
>
obs
=
_model
.
observations
();
auto
rewards
=
std
::
vector
<
double
>
(
obs
.
size
());
std
::
transform
(
obs
.
begin
(),
obs
.
end
(),
rewards
.
begin
(),
afun
);
auto
max_e
=
std
::
max_element
(
rewards
.
begin
(),
rewards
.
end
());
double
f_max
=
afun
(
obs
[
std
::
distance
(
rewards
.
begin
(),
max_e
)]);
// First find the best so far (predicted) observation
std
::
vector
<
Eigen
::
VectorXd
>
samples
=
_model
.
samples
();
std
::
vector
<
double
>
rewards
;
for
(
auto
s
:
samples
)
{
rewards
.
push_back
(
afun
(
_model
.
mu
(
s
)));
}
double
f_max
=
*
std
::
max_element
(
rewards
.
begin
(),
rewards
.
end
());
// Calculate Z and \Phi(Z) and \phi(Z)
double
Z
=
(
afun
(
mu
)
-
f_max
-
Params
::
acqui_ei
::
jitter
())
/
sigma
;
double
phi
=
std
::
exp
(
-
0.5
*
std
::
pow
(
Z
,
2.0
))
/
std
::
sqrt
(
2.0
*
M_PI
);
...
...
src/limbo/model/gp.hpp
View file @
c56afe28
...
...
@@ -305,16 +305,6 @@ namespace limbo {
/// return the list of samples that have been tested so far
const
std
::
vector
<
Eigen
::
VectorXd
>&
samples
()
const
{
return
_samples
;
}
// return the list of observations that have been recorded so far
std
::
vector
<
Eigen
::
VectorXd
>
observations
()
const
{
std
::
vector
<
Eigen
::
VectorXd
>
res
;
for
(
int
i
=
0
;
i
<
_observations
.
rows
();
i
++
)
{
res
.
push_back
(
_observations
.
row
(
i
));
}
return
res
;
}
protected:
int
_dim_in
;
int
_dim_out
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment