Commit 35beef5b authored by Jean-Baptiste Mouret's avatar Jean-Baptiste Mouret
Browse files

Merge branch 'master' of https://github.com/jbmouret/limbo

parents f8017689 036f681b
......@@ -16,14 +16,16 @@ env:
global:
- CI_HOME=`pwd`
matrix:
- LIBCMAES=ON NLOPT=ON TBB=ON
- LIBCMAES=ON NLOPT=ON TBB=OFF
- LIBCMAES=ON NLOPT=OFF TBB=ON
- LIBCMAES=ON NLOPT=OFF TBB=OFF
- LIBCMAES=OFF NLOPT=ON TBB=ON
- LIBCMAES=OFF NLOPT=ON TBB=OFF
- LIBCMAES=OFF NLOPT=OFF TBB=ON
- LIBCMAES=OFF NLOPT=OFF TBB=OFF
- LIBCMAES=ON NLOPT=ON TBB=ON EXPERIMENTAL=OFF
- LIBCMAES=ON NLOPT=ON TBB=OFF EXPERIMENTAL=OFF
- LIBCMAES=ON NLOPT=OFF TBB=ON EXPERIMENTAL=OFF
- LIBCMAES=ON NLOPT=OFF TBB=OFF EXPERIMENTAL=OFF
- LIBCMAES=OFF NLOPT=ON TBB=ON EXPERIMENTAL=OFF
- LIBCMAES=OFF NLOPT=ON TBB=OFF EXPERIMENTAL=OFF
- LIBCMAES=OFF NLOPT=OFF TBB=ON EXPERIMENTAL=OFF
- LIBCMAES=OFF NLOPT=OFF TBB=OFF EXPERIMENTAL=OFF
- LIBCMAES=OFF NLOPT=OFF TBB=OFF EXPERIMENTAL=ON
- LIBCMAES=OFF NLOPT=OFF TBB=ON EXPERIMENTAL=ON
addons:
apt:
......@@ -40,4 +42,4 @@ install:
# Change this to your needs
script:
- ./waf configure
- ./waf --tests --alltests -v
- if [ "$EXPERIMENTAL" = "OFF" ]; then ./waf --tests --alltests -v ; else ./waf --experimental ; fi
......@@ -8,12 +8,11 @@
#include <Eigen/Core>
#ifdef USE_TBB
#include <map>
#include <tbb/task_scheduler_init.h>
#include <tbb/parallel_for.h>
#include <tbb/concurrent_hash_map.h>
#else
#include <map>
#endif
#include <limbo/tools/macros.hpp>
......@@ -206,22 +205,6 @@ struct Params {
struct acqui_ucb_imgpo : public defaults::acqui_ucb_imgpo {
};
#ifdef USE_LIBCMAES
struct opt_cmaes : public defaults::opt_cmaes {
};
#elif defined(USE_NLOPT)
struct opt_nloptnograd : public defaults::opt_nloptnograd {
};
#else
struct opt_gridsearch : public defaults::opt_gridsearch {
};
#endif
struct opt_rprop : public defaults::opt_rprop {
};
struct opt_parallelrepeater : public defaults::opt_parallelrepeater {
};
struct mean_constant {
BO_PARAM(double, constant, 0);
};
......@@ -271,9 +254,16 @@ bool is_in_argv(int argc, char** argv, const char* needle)
template <typename T1, typename T2>
void add_to_results(const char* key, T1& map, const T2& p)
{
#ifdef USE_TBB
typename T1::accessor a;
if (!map.find(a, key))
map.insert(a, key);
#else
typename T1::iterator a;
a = map.find(key);
if (a == map.end())
map[key] = std::vector<std::pair<double, double>>();
#endif
a->second.push_back(p);
}
......
Downloaded from: ftp://ftp.tik.ee.ethz.ch/pub/people/zitzler/hypervol.c
#ifndef HYPERVOL_H__
#define HYPERVOL_H__
extern "C"{
int FilterNondominatedSet(double *front[], int noPoints, int noObjectives);
double CalculateHypervolume(double *front[], int noPoints, int noObjectives);
}
#endif
......@@ -6,47 +6,48 @@
#include <hv/hypervol.h>
namespace limbo {
namespace experimental {
namespace stat {
namespace defaults {
struct stat_hyper_volume {
BO_PARAM_ARRAY(double, ref, 10, 10);
};
}
template <typename Params>
struct HyperVolume : public limbo::stat::StatBase<Params> {
template <typename BO, typename AggregatorFunction>
void operator()(const BO& bo, const AggregatorFunction&, bool blacklisted)
{
if (bo.observations().empty())
return;
if (!bo.stats_enabled())
return;
// convert the data to C arrays
double **data = new double*[bo.observations().size()];
for (size_t i = 0; i < bo.observations().size(); ++i) {
int dim = bo.observations()[i].size();
data[i] = new double[dim];
for (size_t k = 0; k < dim; ++k)
data[i][k] = bo.observations()[i](k) + Params::stat_hyper_volume::ref(k);
}
// call the hypervolume by Zitzler
int noObjectives = bo.observations()[0].size();
int redSizeFront1 = FilterNondominatedSet(data, bo.observations().size(), noObjectives);
double hv = CalculateHypervolume(data, redSizeFront1, noObjectives);
namespace experimental {
namespace stat {
namespace defaults {
struct stat_hyper_volume {
BO_PARAM_ARRAY(double, ref, 10, 10);
};
}
// write
this->_create_log_file(bo, "hypervolume.dat");
(*this->_log_file) << bo.current_iteration() <<"\t" << hv << std::endl;
template <typename Params>
struct HyperVolume : public limbo::stat::StatBase<Params> {
template <typename BO, typename AggregatorFunction>
void operator()(const BO& bo, const AggregatorFunction&, bool blacklisted)
{
if (bo.observations().empty())
return;
if (!bo.stats_enabled())
return;
// convert the data to C arrays
double** data = new double* [bo.observations().size()];
for (size_t i = 0; i < bo.observations().size(); ++i) {
size_t dim = bo.observations()[i].size();
data[i] = new double[dim];
for (size_t k = 0; k < dim; ++k)
data[i][k] = bo.observations()[i](k) + Params::stat_hyper_volume::ref(k);
}
// call the hypervolume by Zitzler
int noObjectives = bo.observations()[0].size();
int redSizeFront1 = FilterNondominatedSet(data, bo.observations().size(), noObjectives);
double hv = CalculateHypervolume(data, redSizeFront1, noObjectives);
// free data
for (size_t i = 0; i < bo.observations().size(); ++i)
delete[] data[i];
delete[] data;
}
};
// write
this->_create_log_file(bo, "hypervolume.dat");
(*this->_log_file) << bo.current_iteration() << "\t" << hv << std::endl;
// free data
for (size_t i = 0; i < bo.observations().size(); ++i)
delete[] data[i];
delete[] data;
}
};
}
}
}
}
#endif
......@@ -52,7 +52,7 @@ namespace limbo {
#endif
template <typename V>
V& convert_vector(const V& v)
V convert_vector(const V& v)
{
return v;
}
......@@ -130,7 +130,7 @@ namespace limbo {
body, joint);
#else
T current_max = init;
for (size_t i = 0; i < num_steps; ++i) {
for (int i = 0; i < num_steps; ++i) {
T v = f(i);
if (comp(v, current_max))
current_max = v;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment