multiobjective — Multiobjective Test Problems

Multiobjective test problems.

So far, this module only contains a base class for multiobjective test problems.

class optproblems.multiobjective.MultiObjectiveTestProblem(objective_functions, num_objectives=None, max_evaluations=inf, worker_pool=None, mp_module=None, phenome_preprocessor=None, name=None)

Base class for multiobjective test problems.

This class only adds functionality to sample the Pareto-front relatively uniformly.

sample_pareto_front(num_points, oversampling_factor=100)

Sample the whole Pareto-front.

This method works by obtaining num_points * oversampling_factor Pareto-optimal points in the search space from get_optimal_solutions, evaluating them, and then selecting num_points of them with a uniform distribution in objective space by the algorithm in diversipy.subset.psa_partition().

Parameters:
  • num_points (int) – The number of points to sample on the Pareto-front.
  • oversampling_factor (int or float, optional) – A parameter controlling the uniformity of the points’ distribution on the Pareto-front. The higher this value, the higher is the chance of obtaining a uniform distribution.
Returns:

selected_solutions

Return type:

list of Individual

Example

This example shows how to define a multiobjective problem by either returning several objective values from one function, or supplying a list of objective functions.

import random
from optproblems import *

# possible objective functions
def function1(phenome):
    return sum(x ** 2 for x in phenome)

def function2(phenome):
    return min(phenome), max(phenome)

# either a single function or a list of objective functions
# may be supplied as argument to Problem
# they may return a scalar or a sequence of objective values

# if the number of returned values of any function is > 1,
# `num_objectives` must be given explicitly
problem = Problem(function2, num_objectives=2)
# generate random solutions
solutions = [Individual([random.random() * 5 for _ in range(5)]) for _ in range(10)]
# evaluate solutions
problem.batch_evaluate(solutions)
# objective values were stored together with decision variables
for solution in solutions:
    print(solution.phenome, solution.objective_values)

problem = Problem([function1, function2], num_objectives=3)
# generate random solutions
solutions = [Individual([random.random() * 5 for _ in range(5)]) for _ in range(10)]
# evaluate solutions
problem.batch_evaluate(solutions)
# objective values were stored together with decision variables
for solution in solutions:
    print(solution.phenome, solution.objective_values)