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
fef47431
Commit
fef47431
authored
May 27, 2016
by
Konstantinos Chatzilygeroudis
Browse files
Fix for time issues
parent
6d4a69df
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/benchmarks/limbo/hp_opt.cpp
View file @
fef47431
...
...
@@ -66,7 +66,7 @@ void benchmark(const std::string& name)
DirectParams
::
opt_nloptnograd
::
set_iterations
(
static_cast
<
int
>
(
iters_base
*
Function
::
dim_in
*
0.9
));
BobyqaParams
::
opt_nloptnograd
::
set_iterations
(
iters_base
*
Function
::
dim_in
-
DirectParams
::
opt_nloptnograd
::
iterations
());
BobyqaParams_HP
::
opt_nloptnograd
::
set_iterations
(
10
*
Function
::
dim_in
);
BobyqaParams_HP
::
opt_nloptnograd
::
set_iterations
(
10
*
Function
::
dim_in
*
Function
::
dim_in
);
auto
t1
=
std
::
chrono
::
steady_clock
::
now
();
Optimizer
opt
;
...
...
src/benchmarks/limbo/testfunctions.hpp
View file @
fef47431
...
...
@@ -268,7 +268,7 @@ public:
double
diff
=
std
::
abs
(
x
+
f
(
sols
.
row
(
0
)));
double
min_diff
=
diff
;
for
(
size_
t
i
=
1
;
i
<
sols
.
rows
();
i
++
)
{
for
(
in
t
i
=
1
;
i
<
sols
.
rows
();
i
++
)
{
diff
=
std
::
abs
(
x
+
f
(
sols
.
row
(
i
)));
if
(
diff
<
min_diff
)
min_diff
=
diff
;
...
...
src/limbo/kernel/squared_exp_ard.hpp
View file @
fef47431
...
...
@@ -71,9 +71,15 @@ namespace limbo {
double
operator
()(
const
Eigen
::
VectorXd
&
x1
,
const
Eigen
::
VectorXd
&
x2
)
const
{
assert
(
x1
.
size
()
==
_ell
.
size
());
Eigen
::
MatrixXd
K
=
(
_A
*
_A
.
transpose
());
K
.
diagonal
()
+=
(
Eigen
::
MatrixXd
)(
_ell
.
array
().
inverse
().
square
());
double
z
=
((
x1
-
x2
).
transpose
()
*
K
*
(
x1
-
x2
)).
norm
();
double
z
;
if
(
Params
::
kernel_squared_exp_ard
::
k
()
>
0
)
{
Eigen
::
MatrixXd
K
=
(
_A
*
_A
.
transpose
());
K
.
diagonal
()
+=
(
Eigen
::
MatrixXd
)(
_ell
.
array
().
inverse
().
square
());
z
=
((
x1
-
x2
).
transpose
()
*
K
*
(
x1
-
x2
)).
norm
();
}
else
{
z
=
(
x1
-
x2
).
cwiseQuotient
(
_ell
).
squaredNorm
();
}
return
_sf2
*
std
::
exp
(
-
0.5
*
z
);
}
...
...
src/limbo/model/gp.hpp
View file @
fef47431
...
...
@@ -349,8 +349,9 @@ namespace limbo {
void
_compute_alpha
()
{
// alpha = K^{-1} * this->_obs_mean;
_alpha
=
_matrixL
.
template
triangularView
<
Eigen
::
Lower
>().
solve
(
_obs_mean
);
_matrixL
.
template
triangularView
<
Eigen
::
Lower
>().
adjoint
().
solveInPlace
(
_alpha
);
//can probably be improved by avoiding to generate the view twice
auto
triang
=
_matrixL
.
template
triangularView
<
Eigen
::
Lower
>();
_alpha
=
triang
.
solve
(
_obs_mean
);
triang
.
adjoint
().
solveInPlace
(
_alpha
);
}
void
_compute_bl_kernel
()
...
...
src/limbo/model/gp/kernel_lf_opt.hpp
View file @
fef47431
...
...
@@ -59,7 +59,7 @@ namespace limbo {
// K^{-1} using Cholesky decomposition
Eigen
::
MatrixXd
w
=
Eigen
::
MatrixXd
::
Identity
(
n
,
n
);
gp
.
matrixL
().
template
triangularView
<
Eigen
::
Lower
>().
solveInPlace
(
w
);
//
gp.matrixL().template triangularView<Eigen::Lower>().solveInPlace(w);
gp
.
matrixL
().
template
triangularView
<
Eigen
::
Lower
>().
transpose
().
solveInPlace
(
w
);
// alpha * alpha.transpose() - K^{-1}
...
...
src/limbo/opt/chained.hpp
View file @
fef47431
...
...
@@ -11,7 +11,9 @@ namespace limbo {
namespace
opt
{
// Needed for the variadic data structure
template
<
typename
Params
,
typename
...
Optimizers
>
struct
Chained
{};
template
<
typename
Params
,
typename
...
Optimizers
>
struct
Chained
{
};
// Base case: just 1 optimizer to call
template
<
typename
Params
,
typename
Optimizer
>
...
...
@@ -29,7 +31,7 @@ namespace limbo {
template
<
typename
F
>
Eigen
::
VectorXd
operator
()(
const
F
&
f
,
const
Eigen
::
VectorXd
&
init
,
bool
bounded
)
const
{
return
Chained
<
Params
,
Optimizers
...
>::
operator
()(
f
,
Optimizer
()(
f
,
init
,
bounded
),
bounded
);
return
Chained
<
Params
,
Optimizers
...
>::
operator
()(
f
,
Optimizer
()(
f
,
init
,
bounded
),
bounded
);
};
};
}
...
...
src/limbo/opt/nlopt_grad.hpp
View file @
fef47431
...
...
@@ -74,12 +74,10 @@ namespace limbo {
double
max
;
try
{
try
{
opt
.
optimize
(
x
,
max
);
}
catch
(
nlopt
::
roundoff_limited
&
e
)
{
catch
(
nlopt
::
roundoff_limited
&
e
)
{
// In theory it's ok to ignore this error
}
...
...
src/limbo/opt/nlopt_no_grad.hpp
View file @
fef47431
...
...
@@ -91,12 +91,10 @@ namespace limbo {
double
max
;
try
{
try
{
opt
.
optimize
(
x
,
max
);
}
catch
(
nlopt
::
roundoff_limited
&
e
)
{
catch
(
nlopt
::
roundoff_limited
&
e
)
{
// In theory it's ok to ignore this error
}
...
...
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