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
f98cbc04
Commit
f98cbc04
authored
Dec 11, 2015
by
Federico Allocati
Browse files
Merge pull request #49 from resibots/parameters_fix
Parameters Improvements
parents
0eb40efc
84dc0fbd
Changes
32
Hide whitespace changes
Inline
Side-by-side
src/examples/mono_dim.cpp
View file @
f98cbc04
...
...
@@ -9,32 +9,35 @@ using namespace limbo;
BO_PARAMS
(
std
::
cout
,
struct
Params
{
struct
gp
_
ucb
:
public
defaults
::
gp
_
ucb
{
struct
acqui_
gpucb
:
public
defaults
::
acqui_
gpucb
{
};
struct
cmaes
:
public
defaults
::
cmaes
{
struct
opt_
cmaes
:
public
defaults
::
opt_
cmaes
{
};
struct
ucb
{
BO_PARAM
(
float
,
alpha
,
0.1
);
struct
acqui_
ucb
{
BO_PARAM
(
double
,
alpha
,
0.1
);
};
struct
k
f
_maternfivehalfs
{
BO_PARAM
(
float
,
sigma
,
1
);
BO_PARAM
(
float
,
l
,
0.2
);
struct
k
ernel
_maternfivehalfs
{
BO_PARAM
(
double
,
sigma
,
1
);
BO_PARAM
(
double
,
l
,
0.2
);
};
struct
boptimizer
{
BO_PARAM
(
double
,
noise
,
0.001
);
BO_PARAM
(
bool
,
stats_enabled
,
true
);
struct
bayes_opt_bobase
{
BO_PARAM
(
bool
,
stats_enabled
,
true
);
};
struct
init
{
BO_PARAM
(
int
,
nb_samples
,
5
);
struct
bayes_opt_boptimizer
{
BO_PARAM
(
double
,
noise
,
0.001
);
};
struct
maxiterations
{
BO_PARAM
(
int
,
n_iterations
,
20
);
struct
init_randomsampling
{
BO_PARAM
(
int
,
samples
,
5
);
};
struct
stop_maxiterations
{
BO_PARAM
(
int
,
iterations
,
20
);
};
};)
...
...
src/examples/obs_multi.cpp
View file @
f98cbc04
...
...
@@ -8,28 +8,31 @@
using
namespace
limbo
;
struct
Params
{
struct
gp
_
ucb
:
public
defaults
::
gp
_
ucb
{
struct
acqui_
gpucb
:
public
defaults
::
acqui_
gpucb
{
};
struct
cmaes
:
public
defaults
::
cmaes
{
struct
opt_
cmaes
:
public
defaults
::
opt_
cmaes
{
};
struct
k
f
_maternfivehalfs
{
BO_PARAM
(
float
,
sigma
,
1
);
BO_PARAM
(
float
,
l
,
0.2
);
struct
k
ernel
_maternfivehalfs
{
BO_PARAM
(
double
,
sigma
,
1
);
BO_PARAM
(
double
,
l
,
0.2
);
};
struct
boptimizer
{
BO_PARAM
(
double
,
noise
,
0.001
);
struct
bayes_opt_bobase
{
BO_PARAM
(
bool
,
stats_enabled
,
true
);
};
struct
init
{
BO_PARAM
(
int
,
nb_samples
,
5
);
struct
bayes_opt_boptimizer
{
BO_PARAM
(
double
,
noise
,
0.001
);
};
struct
init_randomsampling
{
BO_PARAM
(
int
,
samples
,
5
);
};
struct
maxiterations
{
BO_PARAM
(
int
,
n_
iterations
,
20
);
struct
stop_
maxiterations
{
BO_PARAM
(
int
,
iterations
,
20
);
};
};
...
...
src/examples/obs_multi_auto_mean.cpp
View file @
f98cbc04
...
...
@@ -8,36 +8,35 @@
using
namespace
limbo
;
struct
Params
{
struct
gp_auto_mean
{
BO_PARAM
(
int
,
n_rprop
,
100
);
BO_PARAM
(
int
,
rprop_restart
,
10
);
struct
opt_cmaes
:
public
defaults
::
opt_cmaes
{
};
struct
cmaes
:
public
defaults
::
cmaes
{
struct
opt_rprop
:
public
defaults
::
opt_rprop
{
};
struct
rprop
:
public
defaults
::
rprop
{
struct
kernel_maternfivehalfs
{
BO_PARAM
(
double
,
sigma
,
1
);
BO_PARAM
(
double
,
l
,
0.2
);
};
struct
kf_maternfivehalfs
{
BO_PARAM
(
float
,
sigma
,
1
);
BO_PARAM
(
float
,
l
,
0.2
);
struct
bayes_opt_bobase
{
BO_PARAM
(
bool
,
stats_enabled
,
true
);
};
struct
boptimizer
{
struct
bayes_opt_
boptimizer
{
BO_PARAM
(
double
,
noise
,
0.001
);
BO_PARAM
(
bool
,
stats_enabled
,
true
);
};
struct
init
{
BO_PARAM
(
int
,
nb_
samples
,
5
);
struct
init
_randomsampling
{
BO_PARAM
(
int
,
samples
,
5
);
};
struct
maxiterations
{
BO_PARAM
(
int
,
n_
iterations
,
100
);
struct
stop_
maxiterations
{
BO_PARAM
(
int
,
iterations
,
100
);
};
struct
parallel
_
repeater
:
defaults
::
parallel
_
repeater
{
struct
opt_
parallelrepeater
:
defaults
::
opt_
parallelrepeater
{
};
};
...
...
src/examples/parego.cpp
View file @
f98cbc04
...
...
@@ -3,37 +3,34 @@
using
namespace
limbo
;
struct
Params
{
struct
boptimizer
{
BO_PARAM
(
double
,
noise
,
0.005
);
BO_PARAM
(
bool
,
stats_enabled
,
true
);
};
struct
init
{
BO_PARAM
(
int
,
nb_samples
,
21
);
struct
init_randomsampling
{
BO_PARAM
(
int
,
samples
,
21
);
// calandra: number of dimensions * 5
// knowles : 11 * dim - 1
};
struct
maxiterations
{
BO_PARAM
(
int
,
n_
iterations
,
30
);
struct
stop_
maxiterations
{
BO_PARAM
(
int
,
iterations
,
30
);
};
struct
ucb
:
public
defaults
::
ucb
{
struct
acqui_
ucb
:
public
defaults
::
acqui_
ucb
{
};
struct
gp
_
ucb
:
public
defaults
::
gp
_
ucb
{
struct
acqui_
gpucb
:
public
defaults
::
acqui_
gpucb
{
};
struct
cmaes
:
public
defaults
::
cmaes
{
struct
opt_
cmaes
:
public
defaults
::
opt_
cmaes
{
};
struct
gp_auto
:
public
defaults
::
gp_auto
{
struct
mean_constant
:
public
defaults
::
mean_constant
{
};
struct
meanconstant
:
public
defaults
::
meanconstant
{
struct
bayes_opt_bobase
{
BO_PARAM
(
bool
,
stats_enabled
,
true
);
};
struct
parego
:
public
defaults
::
parego
{
struct
bayes_opt_parego
:
public
defaults
::
bayes_opt_parego
{
BO_PARAM
(
double
,
noise
,
0.005
);
};
};
...
...
@@ -85,7 +82,7 @@ int main()
// typedef model::GP<Params, kernel_t, mean_t> gp_t;
// typedef acquisition_functions::UCB<Params, gp_t> ucb_t;
// Parego<Params, model_fun<gp_t>, acq_fun<ucb_t> > opt;
Parego
<
Params
>
opt
;
bayes_opt
::
Parego
<
Params
>
opt
;
opt
.
optimize
(
mop2
());
std
::
cout
<<
"optimization done"
<<
std
::
endl
;
...
...
src/limbo/acqui/gp_ucb.hpp
View file @
f98cbc04
...
...
@@ -6,13 +6,11 @@
#include
<limbo/tools/macros.hpp>
namespace
limbo
{
namespace
defaults
{
struct
gp
_
ucb
{
BO_PARAM
(
float
,
delta
,
0.001
);
struct
acqui_
gpucb
{
BO_PARAM
(
double
,
delta
,
0.001
);
};
}
namespace
acqui
{
template
<
typename
Params
,
typename
Model
>
class
GP_UCB
{
...
...
@@ -20,7 +18,7 @@ namespace limbo {
GP_UCB
(
const
Model
&
model
,
int
iteration
)
:
_model
(
model
)
{
double
t3
=
pow
(
iteration
,
3.0
);
static
constexpr
double
delta3
=
Params
::
gp
_
ucb
::
delta
()
*
3
;
static
constexpr
double
delta3
=
Params
::
acqui_
gpucb
::
delta
()
*
3
;
static
constexpr
double
pi2
=
M_PI
*
M_PI
;
_beta
=
sqrtf
(
2.0
*
log
(
t3
*
pi2
/
delta3
));
}
...
...
src/limbo/acqui/ucb.hpp
View file @
f98cbc04
...
...
@@ -6,13 +6,11 @@
#include
<limbo/tools/macros.hpp>
namespace
limbo
{
namespace
defaults
{
struct
ucb
{
BO_PARAM
(
float
,
alpha
,
0.5
);
struct
acqui_
ucb
{
BO_PARAM
(
double
,
alpha
,
0.5
);
};
}
namespace
acqui
{
template
<
typename
Params
,
typename
Model
>
class
UCB
{
...
...
@@ -29,7 +27,7 @@ namespace limbo {
Eigen
::
VectorXd
mu
;
double
sigma
;
std
::
tie
(
mu
,
sigma
)
=
_model
.
query
(
v
);
return
(
afun
(
mu
)
+
Params
::
ucb
::
alpha
()
*
sqrt
(
sigma
));
return
(
afun
(
mu
)
+
Params
::
acqui_
ucb
::
alpha
()
*
sqrt
(
sigma
));
}
protected:
...
...
src/limbo/bayes_opt/bo_base.hpp
View file @
f98cbc04
...
...
@@ -15,6 +15,7 @@
#include
<Eigen/Core>
// we need everything to have the defaults
#include
<limbo/tools/macros.hpp>
#include
<limbo/stop/chain_criteria.hpp>
#include
<limbo/stop/max_iterations.hpp>
#include
<limbo/stat/samples.hpp>
...
...
@@ -29,7 +30,11 @@
#include
<limbo/init/random_sampling.hpp>
namespace
limbo
{
namespace
defaults
{
struct
bayes_opt_bobase
{
BO_PARAM
(
bool
,
stats_enabled
,
true
);
};
}
template
<
typename
BO
,
typename
AggregatorFunction
>
struct
RefreshStat_f
{
RefreshStat_f
(
BO
&
bo
,
const
AggregatorFunction
&
afun
,
bool
blacklisted
)
...
...
@@ -125,7 +130,7 @@ namespace limbo {
BoBase
(
const
BoBase
&
other
)
=
delete
;
BoBase
&
operator
=
(
const
BoBase
&
other
)
=
delete
;
bool
stats_enabled
()
const
{
return
Params
::
b
optimizer
::
stats_enabled
();
}
bool
stats_enabled
()
const
{
return
Params
::
b
ayes_opt_bobase
::
stats_enabled
();
}
const
std
::
string
&
res_dir
()
const
{
return
_res_dir
;
}
...
...
@@ -183,7 +188,7 @@ namespace limbo {
void
_make_res_dir
()
{
if
(
!
Params
::
b
optimizer
::
stats_enabled
())
if
(
!
Params
::
b
ayes_opt_bobase
::
stats_enabled
())
return
;
_res_dir
=
tools
::
hostname
()
+
"_"
+
tools
::
date
()
+
"_"
+
tools
::
getpid
();
boost
::
filesystem
::
path
my_path
(
_res_dir
);
...
...
src/limbo/bayes_opt/boptimizer.hpp
View file @
f98cbc04
...
...
@@ -10,9 +10,15 @@
#include
<Eigen/Core>
#include
<limbo/tools/macros.hpp>
#include
<limbo/bayes_opt/bo_base.hpp>
namespace
limbo
{
namespace
defaults
{
struct
bayes_opt_boptimizer
{
BO_PARAM
(
double
,
noise
,
1e-6
);
};
}
namespace
bayes_opt
{
template
<
class
Params
,
class
A1
=
boost
::
parameter
::
void_
,
...
...
@@ -59,7 +65,7 @@ namespace limbo {
this
->
_init
(
sfun
,
afun
,
reset
);
if
(
!
this
->
_observations
.
empty
())
_model
.
compute
(
this
->
_samples
,
this
->
_observations
,
Params
::
boptimizer
::
noise
(),
this
->
_bl_samples
);
_model
.
compute
(
this
->
_samples
,
this
->
_observations
,
Params
::
bayes_opt_
boptimizer
::
noise
(),
this
->
_bl_samples
);
acqui_optimizer_t
acqui_optimizer
;
...
...
@@ -98,7 +104,7 @@ namespace limbo {
std
::
cout
<<
" best:"
<<
afun
(
this
->
best_observation
(
afun
))
<<
std
::
endl
;
if
(
!
this
->
_observations
.
empty
())
_model
.
compute
(
this
->
_samples
,
this
->
_observations
,
Params
::
boptimizer
::
noise
(),
this
->
_bl_samples
);
_model
.
compute
(
this
->
_samples
,
this
->
_observations
,
Params
::
bayes_opt_
boptimizer
::
noise
(),
this
->
_bl_samples
);
this
->
_current_iteration
++
;
this
->
_total_iterations
++
;
...
...
src/limbo/bayes_opt/ehvi.hpp
View file @
f98cbc04
...
...
@@ -6,10 +6,17 @@
#include
<ehvi/ehvi_calculations.h>
#include
<ehvi/ehvi_sliceupdate.h>
#include
<limbo/tools/macros.hpp>
#include
<limbo/bayes_opt/bo_multi.hpp>
#include
<limbo/acqui/ehvi.hpp>
namespace
limbo
{
namespace
defaults
{
struct
bayes_opt_ehvi
{
BO_PARAM
(
double
,
x_ref
,
-
11
);
BO_PARAM
(
double
,
y_ref
,
-
11
);
};
}
namespace
bayes_opt
{
template
<
class
Params
,
class
A2
=
boost
::
parameter
::
void_
,
class
A3
=
boost
::
parameter
::
void_
,
class
A4
=
boost
::
parameter
::
void_
,
...
...
@@ -49,7 +56,7 @@ namespace limbo {
auto
acqui
=
acqui
::
Ehvi
<
Params
,
model_t
>
(
this
->
_models
,
pop
,
Eigen
::
Vector3d
(
Params
::
ehvi
::
x_ref
(),
Params
::
ehvi
::
y_ref
(),
0
));
Eigen
::
Vector3d
(
Params
::
bayes_opt_
ehvi
::
x_ref
(),
Params
::
bayes_opt_
ehvi
::
y_ref
(),
0
));
// maximize with CMA-ES
typedef
std
::
pair
<
Eigen
::
VectorXd
,
double
>
pair_t
;
...
...
src/limbo/bayes_opt/parego.hpp
View file @
f98cbc04
...
...
@@ -3,16 +3,16 @@
#include
<algorithm>
#include
<limbo/
limbo
.hpp>
#include
<limbo/
tools/macros
.hpp>
#include
<limbo/bayes_opt/bo_multi.hpp>
namespace
limbo
{
namespace
defaults
{
struct
parego
{
struct
bayes_opt_parego
{
BO_PARAM
(
double
,
noise
,
1e-6
);
BO_PARAM
(
double
,
rho
,
0.05
);
};
}
namespace
bayes_opt
{
template
<
class
Params
,
class
A3
=
boost
::
parameter
::
void_
,
...
...
@@ -34,7 +34,7 @@ namespace limbo {
std
::
vector
<
double
>
scalarized
=
_scalarize_obs
();
model_t
model
(
EvalFunction
::
dim
);
model
.
compute
(
this
->
_samples
,
scalarized
,
Params
::
b
optimizer
::
noise
());
model
.
compute
(
this
->
_samples
,
scalarized
,
Params
::
b
ayes_opt_parego
::
noise
());
acqui_optimizer_t
inner_optimization
;
...
...
@@ -47,7 +47,7 @@ namespace limbo {
<<
" | new sample:"
<<
new_sample
.
transpose
()
<<
" => "
<<
feval
(
new_sample
).
transpose
()
<<
std
::
endl
;
scalarized
=
_scalarize_obs
();
model
.
compute
(
this
->
_samples
,
scalarized
,
Params
::
b
optimizer
::
noise
());
model
.
compute
(
this
->
_samples
,
scalarized
,
Params
::
b
ayes_opt_parego
::
noise
());
this
->
_update_stats
(
*
this
,
FirstElem
(),
false
);
this
->
_current_iteration
++
;
this
->
_total_iterations
++
;
...
...
@@ -70,7 +70,7 @@ namespace limbo {
for
(
auto
x
:
this
->
_observations
)
{
double
y
=
(
lambda
.
array
()
*
x
.
array
()).
maxCoeff
();
double
s
=
(
lambda
.
array
()
*
x
.
array
()).
sum
();
scalarized
.
push_back
(
y
+
Params
::
parego
::
rho
()
*
s
);
scalarized
.
push_back
(
y
+
Params
::
bayes_opt_
parego
::
rho
()
*
s
);
}
return
scalarized
;
}
...
...
src/limbo/init/grid_sampling.hpp
View file @
f98cbc04
...
...
@@ -3,10 +3,15 @@
#include
<Eigen/Core>
#include
<limbo/tools/macros.hpp>
namespace
limbo
{
namespace
defaults
{
struct
init_gridsampling
{
BO_PARAM
(
int
,
bins
,
5
);
};
}
namespace
init
{
// params:
// -init::nb_bins
template
<
typename
Params
>
struct
GridSampling
{
template
<
typename
StateFunction
,
typename
AggregatorFunction
,
typename
Opt
>
...
...
@@ -16,12 +21,12 @@ namespace limbo {
}
private:
// recursively explore all the dim
_in
ensions
// recursively explore all the dimensions
template
<
typename
StateFunction
,
typename
Opt
>
void
_explore
(
int
dim_in
,
const
StateFunction
&
seval
,
const
Eigen
::
VectorXd
&
current
,
Opt
&
opt
)
const
{
for
(
double
x
=
0
;
x
<=
1.0
f
;
x
+=
1.0
f
/
(
double
)
Params
::
init
::
nb_
bins
())
{
for
(
double
x
=
0
;
x
<=
1.0
f
;
x
+=
1.0
f
/
(
double
)
Params
::
init
_gridsampling
::
bins
())
{
Eigen
::
VectorXd
point
=
current
;
point
[
dim_in
]
=
x
;
if
(
dim_in
==
current
.
size
()
-
1
)
{
...
...
src/limbo/init/random_sampling.hpp
View file @
f98cbc04
...
...
@@ -3,18 +3,22 @@
#include
<Eigen/Core>
#include
<limbo/tools/macros.hpp>
#include
<limbo/tools/rand.hpp>
namespace
limbo
{
namespace
defaults
{
struct
init_randomsampling
{
BO_PARAM
(
int
,
samples
,
10
);
};
}
namespace
init
{
// initialize in [0,1] !
// params: init::nb_samples
template
<
typename
Params
>
struct
RandomSampling
{
template
<
typename
StateFunction
,
typename
AggregatorFunction
,
typename
Opt
>
void
operator
()(
const
StateFunction
&
seval
,
const
AggregatorFunction
&
,
Opt
&
opt
)
const
{
for
(
int
i
=
0
;
i
<
Params
::
init
::
nb_
samples
();
i
++
)
{
for
(
int
i
=
0
;
i
<
Params
::
init
_randomsampling
::
samples
();
i
++
)
{
Eigen
::
VectorXd
new_sample
(
StateFunction
::
dim_in
);
for
(
int
i
=
0
;
i
<
StateFunction
::
dim_in
;
i
++
)
new_sample
[
i
]
=
tools
::
rand
<
double
>
(
0
,
1
);
...
...
src/limbo/init/random_sampling_grid.hpp
View file @
f98cbc04
...
...
@@ -3,21 +3,25 @@
#include
<Eigen/Core>
#include
<limbo/tools/macros.hpp>
namespace
limbo
{
namespace
defaults
{
struct
init_randomsamplinggrid
{
BO_PARAM
(
int
,
samples
,
10
);
BO_PARAM
(
int
,
bins
,
5
);
};
}
namespace
init
{
// initialize in [0,1] !
// params:
// -init::nb_bins
// - init::nb_samples
template
<
typename
Params
>
struct
RandomSamplingGrid
{
template
<
typename
StateFunction
,
typename
AggregatorFunction
,
typename
Opt
>
void
operator
()(
const
StateFunction
&
seval
,
const
AggregatorFunction
&
,
Opt
&
opt
)
const
{
for
(
int
i
=
0
;
i
<
Params
::
init
::
nb_
samples
();
i
++
)
{
for
(
int
i
=
0
;
i
<
Params
::
init
_randomsamplinggrid
::
samples
();
i
++
)
{
Eigen
::
VectorXd
new_sample
(
StateFunction
::
dim_in
);
for
(
size_t
i
=
0
;
i
<
StateFunction
::
dim_in
;
i
++
)
new_sample
[
i
]
=
int
(((
double
)(
Params
::
init
::
nb_
bins
()
+
1
)
*
rand
())
/
(
RAND_MAX
+
1.0
))
/
double
(
Params
::
init
::
nb_
bins
());
new_sample
[
i
]
=
int
(((
double
)(
Params
::
init
_randomsamplinggrid
::
bins
()
+
1
)
*
rand
())
/
(
RAND_MAX
+
1.0
))
/
double
(
Params
::
init
_randomsamplinggrid
::
bins
());
opt
.
add_new_sample
(
new_sample
,
seval
(
new_sample
));
}
}
...
...
src/limbo/kernel/exp.hpp
View file @
f98cbc04
...
...
@@ -3,14 +3,21 @@
#include
<Eigen/Core>
#include
<limbo/tools/macros.hpp>
namespace
limbo
{
namespace
defaults
{
struct
kernel_exp
{
BO_PARAM
(
double
,
sigma
,
1
);
};
}
namespace
kernel
{
template
<
typename
Params
>
struct
Exp
{
Exp
(
size_t
dim
=
1
)
{}
double
operator
()(
const
Eigen
::
VectorXd
&
v1
,
const
Eigen
::
VectorXd
&
v2
)
const
{
double
_sigma
=
Params
::
k
f
_exp
::
sigma
();
double
_sigma
=
Params
::
k
ernel
_exp
::
sigma
();
return
(
exp
(
-
(
1
/
(
2
*
pow
(
_sigma
,
2
)))
*
pow
((
v1
-
v2
).
norm
(),
2
)));
}
};
...
...
src/limbo/kernel/matern_five_halfs.hpp
View file @
f98cbc04
...
...
@@ -3,7 +3,15 @@
#include
<Eigen/Core>
#include
<limbo/tools/macros.hpp>
namespace
limbo
{
namespace
defaults
{
struct
kernel_maternfivehalfs
{
BO_PARAM
(
double
,
sigma
,
1
);
BO_PARAM
(
double
,
l
,
1
);
};
}
namespace
kernel
{
template
<
typename
Params
>
struct
MaternFiveHalfs
{
...
...
@@ -12,7 +20,7 @@ namespace limbo {
double
operator
()(
const
Eigen
::
VectorXd
&
v1
,
const
Eigen
::
VectorXd
&
v2
)
const
{
double
d
=
(
v1
-
v2
).
norm
();
return
Params
::
k
f
_maternfivehalfs
::
sigma
()
*
(
1
+
sqrt
(
5
)
*
d
/
Params
::
k
f
_maternfivehalfs
::
l
()
+
5
*
d
*
d
/
(
3
*
Params
::
k
f
_maternfivehalfs
::
l
()
*
Params
::
k
f
_maternfivehalfs
::
l
()))
*
exp
(
-
sqrt
(
5
)
*
d
/
Params
::
k
f
_maternfivehalfs
::
l
());
return
Params
::
k
ernel
_maternfivehalfs
::
sigma
()
*
(
1
+
sqrt
(
5
)
*
d
/
Params
::
k
ernel
_maternfivehalfs
::
l
()
+
5
*
d
*
d
/
(
3
*
Params
::
k
ernel
_maternfivehalfs
::
l
()
*
Params
::
k
ernel
_maternfivehalfs
::
l
()))
*
exp
(
-
sqrt
(
5
)
*
d
/
Params
::
k
ernel
_maternfivehalfs
::
l
());
}
};
}
...
...
src/limbo/kernel/matern_three_halfs.hpp
View file @
f98cbc04
...
...
@@ -3,7 +3,15 @@
#include
<Eigen/Core>
#include
<limbo/tools/macros.hpp>
namespace
limbo
{
namespace
defaults
{
struct
kernel_maternthreehalfs
{
BO_PARAM
(
double
,
sigma
,
1
);
BO_PARAM
(
double
,
l
,
1
);
};
}
namespace
kernel
{
template
<
typename
Params
>
struct
MaternThreeHalfs
{
...
...
@@ -12,7 +20,7 @@ namespace limbo {
double
operator
()(
const
Eigen
::
VectorXd
&
v1
,
const
Eigen
::
VectorXd
&
v2
)
const
{
double
d
=
(
v1
-
v2
).
norm
();
return
Params
::
k
f
_maternthreehalfs
::
sigma
()
*
(
1
+
sqrt
(
3
)
*
d
/
Params
::
k
f
_maternthreehalfs
::
l
())
*
exp
(
-
sqrt
(
3
)
*
d
/
Params
::
k
f
_maternthreehalfs
::
l
());
return
Params
::
k
ernel
_maternthreehalfs
::
sigma
()
*
(
1
+
sqrt
(
3
)
*
d
/
Params
::
k
ernel
_maternthreehalfs
::
l
())
*
exp
(
-
sqrt
(
3
)
*
d
/
Params
::
k
ernel
_maternthreehalfs
::
l
());
}
};
}
...
...
src/limbo/mean/constant.hpp
View file @
f98cbc04
...
...
@@ -3,17 +3,27 @@
#include
<Eigen/Core>
#include
<limbo/tools/macros.hpp>
namespace
limbo
{
namespace
defaults
{
struct
mean_constant
{
BO_PARAM
(
double
,
constant
,
1
);
};
}
namespace
mean
{
template
<
typename
Params
>
struct
Constant
{
Constant
(
size_t
dim_out
=
1
)
{}
Constant
(
size_t
dim_out
=
1
)
:
_dim_out
(
dim_out
)
{}
template
<
typename
GP
>
Eigen
::
VectorXd
operator
()(
const
Eigen
::
VectorXd
&
v
,
const
GP
&
)
const
{
return
Params
::
meanconstant
::
constant
();
return
Eigen
::
VectorXd
::
Constant
(
_dim_out
,
Params
::
mean
_
constant
::
constant
()
)
;
}
protected:
size_t
_dim_out
;
};
}
}
...
...
src/limbo/opt/cmaes.hpp
View file @
f98cbc04
...
...
@@ -13,16 +13,16 @@
#include
<cmaes/cmaes_interface.h>
#include
<cmaes/boundary_transformation.h>
#include
<limbo/tools/macros.hpp>
#include
<limbo/tools/parallel.hpp>