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

make Parego compile

parent 85586f0e
......@@ -21,31 +21,53 @@ namespace limbo {
}
namespace model {
// this is the model used in Parego
// reference: Knowles, J. (2006). ParEGO: A hybrid algorithm
// with on-line landscape approximation for expensive multiobjective
// optimization problems.
// IEEE Transactions On Evolutionary Computation, 10(1), 50-66.
// Main idea:
// - this models aggregates all the objective values with the Tchebycheff distance
// - objectives are weighted using a random vector
// - a single model is built
/// this is the model used in Parego
/// reference: Knowles, J. (2006). ParEGO: A hybrid algorithm
/// with on-line landscape approximation for expensive multiobjective
/// optimization problems.
/// IEEE Transactions On Evolutionary Computation, 10(1), 50-66.
/// Main idea:
/// - this models aggregates all the objective values with the Tchebycheff distance
/// - objectives are weighted using a random vector
/// - a single model is built
template <typename Params, typename Model>
class GPParego : public Model {
public:
GPParego() {}
GPParego(int dim_in, int dim_out) : Model(dim_in, 1), _nb_objs(dim_out) {}
void compute(const std::vector<Eigen::VectorXd>& samples,
const std::vector<Eigen::VectorXd>& observations, double noise,
const std::vector<Eigen::VectorXd>& observations, const Eigen::VectorXd& noises,
const std::vector<Eigen::VectorXd>& bl_samples = std::vector<Eigen::VectorXd>())
{
auto new_observations = _scalarize_obs(observations);
Model::compute(samples, new_observations, noise, bl_samples);
Model::compute(samples, new_observations, noises, bl_samples);
}
/// add sample will NOT be incremental (we call compute each time)
void add_sample(const Eigen::VectorXd& sample, const Eigen::VectorXd& observation, double noise)
{
Model::add_sample(sample, observation, noise);
this->compute(this->_samples,
_convert_observations(this->_observations), this->_noises,
this->_bl_samples);
}
void add_bl_sample(const Eigen::VectorXd& bl_sample, double noise)
{
Model::add_bl_sample(bl_sample, noise);
this->compute(this->_samples,
_convert_observations(this->_observations), this->_noises,
this->_bl_samples);
}
protected:
size_t _nb_objs;
/// we need to do this because the GP does not store the vector of observations, but convert it to a matrix...
std::vector<Eigen::VectorXd> _convert_observations(const Eigen::MatrixXd& m){
std::vector<Eigen::VectorXd> res;
for (int i = 0; i < m.rows(); ++i)
res.push_back(m.row(i));
return res;
}
std::vector<Eigen::VectorXd> _scalarize_obs(const std::vector<Eigen::VectorXd>& observations)
{
Eigen::VectorXd lambda = tools::random_vector(_nb_objs);
......
......@@ -232,7 +232,7 @@ namespace limbo {
int nb_bl_samples() const { return _bl_samples.size(); }
/// recomputes the GP
void recompute(bool update_obs_mean)
void recompute(bool update_obs_mean = true)
{
assert(!_samples.empty());
......
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