esa / pagmo2

A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pagmo2/
GNU General Public License v3.0
808 stars 160 forks source link

[BUG] unconstrain doesnt forward batch_fitness property #500

Closed jschueller closed 2 years ago

jschueller commented 2 years ago

Describe the bug unconstrain does not forward the batch_fitness/has_batch_fitness methods to the underlying problem

To Reproduce

struct my_udp {
    vector_double fitness(const vector_double &x) const
    {
        return x;
    }
    vector_double::size_type get_nobj() const
    {
        return 2u;
    }
    vector_double::size_type get_nec() const
    {
        return 2u;
    }
    vector_double::size_type get_nic() const
    {
        return 2u;
    }
    std::pair<vector_double, vector_double> get_bounds() const
    {
        return {{-1, -1, -1, -1, -1, -1}, {1, 1, 1, 1, 1, 1}};
    }
    std::string get_name() const
    {
        return "a simple problem with constraint for testing";
    }
    vector_double batch_fitness(const pagmo::vector_double & xs) const
    {
      return  {0.0};
    }
    bool has_batch_fitness() const 
    {
     return true;
    }

};

problem p0{my_udp};
std::cout << p0.has_batch_fitness() << std::endl;
unconstrain p1{p0{}, "death penalty"};
std::cout << p1.has_batch_fitness() << std::endl;

Expected behavior has_batch_fitness returns 1 for p1