Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

qLogNEHVI: Multiobjective Bayesian Optimization

Synopsis

#include <boost/math/optimization/qlognehvi.hpp>

namespace boost::math::optimization {

template <typename ArgumentContainer> struct qlognehvi_parameters {
    ArgumentContainer lower_bounds;
    ArgumentContainer upper_bounds;
    size_t initial_samples = 0;
    size_t batch_size = 1;
    size_t max_evaluations = 100;
    size_t mc_samples = 64;
    size_t restarts = 4;
    size_t raw_samples = 128;
    std::vector<double> reference_point;
    std::vector<ArgumentContainer> const * initial_population = nullptr;
    unsigned threads = std::thread::hardware_concurrency();
};

template <typename ArgumentContainer>
void validate_qlognehvi_parameters(qlognehvi_parameters<ArgumentContainer> const &params);

template <typename ArgumentContainer, typename ObjectiveContainer, class URBG = std::mt19937_64>
class qlognehvi_optimizer {
public:
    qlognehvi_optimizer(qlognehvi_parameters<ArgumentContainer> const &params, URBG gen);
    std::vector<ArgumentContainer> const &ask();
    std::vector<ArgumentContainer> const &ask(size_t count);
    void tell(std::vector<ObjectiveContainer> values);
    std::vector<std::pair<ArgumentContainer, ObjectiveContainer>> front() const;
    std::vector<ArgumentContainer> const &points() const;
    std::vector<ObjectiveContainer> const &objectives() const;
    std::vector<double> const &reference_point() const;
};

template <typename ArgumentContainer, class Func, class URBG>
std::vector<std::pair<ArgumentContainer, std::invoke_result_t<Func, ArgumentContainer>>>
qlognehvi(const Func objectives,
          qlognehvi_parameters<ArgumentContainer> const &params,
          URBG &gen,
          std::atomic<bool> *cancellation = nullptr,
          std::vector<std::pair<ArgumentContainer, std::invoke_result_t<Func, ArgumentContainer>>> *queries = nullptr);

} // namespaces

The function qlognehvi, and the class qlognehvi_optimizer, minimize several expensive objectives at once over a box, in tens to hundreds of evaluations, by Bayesian optimization with the parallel noisy expected hypervolume improvement of Daulton, Balandat and Bakshy, in the logarithmic form of Ament et al.

As for NSGA-II, the result is a set of points none of which dominates another, which approximates the Pareto front. The hypervolume of such a set is the volume of the region that its points dominate, below a reference point which bounds the objectives of interest from above; the larger it is, the closer the set is to the front and the better it covers it.

After an initial design, each iteration fits a Gaussian process to each objective, on the points evaluated so far. The next point is the one which is expected to add the most to the hypervolume: the maximizer of the acquisition function, the logarithm of the average, over joint samples of the Gaussian processes, of the hypervolume that the point's sampled objectives add to that of the front of the same sample. The front itself is sampled, not taken from the data, which is what makes the method sound for noisy objectives; the region which each sampled front does not dominate is cut into boxes once, so that an evaluation of the acquisition function is a sum over boxes. A batch of batch_size points is chosen one point after the other, each sample being extended by its values at the points already chosen, so that the points of a batch do not crowd together. The logarithm, and the smooth approximations inside it, keep the gradient useful where no improvement is expected, which is nearly everywhere; the acquisition function is maximized by a quasi-Newton method from several starting points.

The models, defaults and details follow BoTorch (qLogNoisyExpectedHypervolumeImprovement with SingleTaskGP). On the problems of the ZDT and DTLZ families, and those of Kursawe and of Fonseca and Fleming, the hypervolume after 200 evaluations is comparable to that which BoTorch reaches.

Parameters

The function

Parameters:

Returns:

Of all the points evaluated, those whose objectives are finite and which no other dominates, as pairs of the argument and its objectives, in lexicographic order of the objectives. Points whose objectives are equal are returned once.

An objective may be NaN or infinite at some points. For the models, it then has the largest finite value seen so far of that objective, so that the neighbourhood is avoided; such a point is never returned. While an objective has had no finite value, the points proposed are uniformly distributed in the box.

All random numbers are drawn from gen on the calling thread, so for a given state of gen the result does not depend on the number of threads.

Ask and tell

The class qlognehvi_optimizer is the algorithm without the evaluation of the objectives, which is left to the caller.

qlognehvi_optimizer<ArgType, std::array<double, 2>> optimizer(params, std::mt19937_64(12345));
while (optimizer.points().size() < 100) {
    auto const &points = optimizer.ask();
    std::vector<std::array<double, 2>> values = evaluate_all(points);
    optimizer.tell(std::move(values));
}
auto front = optimizer.front();

The optimizer keeps its own copy of the generator, unless URBG is a reference type, such as std::mt19937_64&, in which case it uses the caller's, which must outlive it. The caller's loop decides when to stop, so max_evaluations is not used.

Examples
using ArgType = std::vector<double>;
auto objectives = [](ArgType const &x) { return simulate(x); };  // minutes per call
qlognehvi_parameters<ArgType> params;
params.lower_bounds.assign(6, 0.0);
params.upper_bounds.assign(6, 1.0);
params.batch_size = 4;
params.max_evaluations = 120;
std::mt19937_64 gen(12345);
auto front = qlognehvi(objectives, params, gen);

More examples and API use cases can be studied in test_qlognehvi.cpp.

When to use it rather than NSGA-II

Use it when the objectives are expensive, so that there can only be a few hundred evaluations. The cost of proposing a batch grows with the cube of the number of evaluations, through the fits of the models, and steeply with the number of objectives, through the number of boxes; with thousands of cheap evaluations, NSGA-II is the better choice.

Caveats

The models are smooth and have one lengthscale for each variable. An objective with many local minima at a scale which the evaluations cannot resolve is seen as noise.

If the objectives of interest are known, give the reference point.

The fit of the models has local optima, and which of them is found matters to the points proposed. This implementation follows the path of the optimizer that BoTorch uses for as long as it can, and usually ends where it does, but not always. To save time, four fits in five start from the hyperparameters of the fit before, unless that ends with a greater loss than it had; fits which always start there are much faster still, but the points proposed were clearly worse on some of our test problems.

The objectives are modelled independently of one another, and constraints other than the bounds are not supported. Like nsga2, qlognehvi compares objectives with == and iterates over them, so their container needs operator==, begin() and end().

References

PrevUpHomeNext