:mod:`multiobjective` --- Multiobjective Test Problems ====================================================== .. automodule:: optproblems.multiobjective :members: 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. .. code:: python 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)