# Pareto front on Binh and Korn problem¶

In this example, we illustrate the use of the ParetoFront plot on the Binh and Korn multi-objective problem.

from __future__ import annotations

from gemseo.algos.doe.doe_factory import DOEFactory
from gemseo.api import configure_logger
from gemseo.post.post_factory import PostFactory
from gemseo.problems.analytical.binh_korn import BinhKorn


## Import¶

The first step is to import some functions from the API and a method to get the design space.

configure_logger()

<RootLogger root (INFO)>


## Import the optimization problem¶

Then, we instantiate the BinkKorn optimization problem.

problem = BinhKorn()


## Create and execute scenario¶

Then, we create a Design of Experiment factory, and we request the execution a a full-factorial DOE using 100 samples

doe_factory = DOEFactory()
doe_factory.execute(problem, algo_name="OT_OPT_LHS", n_samples=100)

    INFO - 16:31:27: Optimization problem:
INFO - 16:31:27:    minimize compute_binhkorn(x, y) = (4*x**2+ 4*y**2, (x-5.)**2 + (y-5.)**2)
INFO - 16:31:27:    with respect to x, y
INFO - 16:31:27:    subject to constraints:
INFO - 16:31:27:       ineq1(x, y): (x-5.)**2 + y**2 <= 25. <= 0.0
INFO - 16:31:27:       ineq2(x, y): (x-8.)**2 + (y+3)**2 >= 7.7 <= 0.0
INFO - 16:31:27:    over the design space:
INFO - 16:31:27:    +------+-------------+-------+-------------+-------+
INFO - 16:31:27:    | name | lower_bound | value | upper_bound | type  |
INFO - 16:31:27:    +------+-------------+-------+-------------+-------+
INFO - 16:31:27:    | x    |      0      |   1   |      5      | float |
INFO - 16:31:27:    | y    |      0      |   1   |      3      | float |
INFO - 16:31:27:    +------+-------------+-------+-------------+-------+
INFO - 16:31:27: Solving optimization problem with algorithm OT_OPT_LHS:
INFO - 16:31:27: ...   0%|          | 0/100 [00:00<?, ?it]
INFO - 16:31:27: ... 100%|██████████| 100/100 [00:00<00:00, 3030.59 it/sec, obj=[52.02690192 12.02601654]]
INFO - 16:31:27: Optimization result:
INFO - 16:31:27:    Optimizer info:
INFO - 16:31:27:       Status: None
INFO - 16:31:27:       Message: None
INFO - 16:31:27:       Number of calls to the objective function by the optimizer: 100
INFO - 16:31:27:    Solution:
INFO - 16:31:27:       The solution is feasible.
INFO - 16:31:27:       Objective: 30.39964825035985
INFO - 16:31:27:       Standardized constraints:
INFO - 16:31:27:          ineq1 = [-11.77907222]
INFO - 16:31:27:          ineq2 = [-38.26307397]
INFO - 16:31:27:       Design space:
INFO - 16:31:27:       +------+-------------+-------------------+-------------+-------+
INFO - 16:31:27:       | name | lower_bound |       value       | upper_bound | type  |
INFO - 16:31:27:       +------+-------------+-------------------+-------------+-------+
INFO - 16:31:27:       | x    |      0      | 1.542975634014225 |      5      | float |
INFO - 16:31:27:       | y    |      0      | 1.269910308585573 |      3      | float |
INFO - 16:31:27:       +------+-------------+-------------------+-------------+-------+

Optimization result:
Design variables: [1.54297563 1.26991031]
Objective function: 30.39964825035985
Feasible solution: True


## Post-process scenario¶

Lastly, we post-process the scenario by means of the ParetoFront plot which generates a plot or a matrix of plots if there are more than 2 objectives, plots in blue the locally non dominated points for the current two objectives, plots in green the globally (all objectives) Pareto optimal points. The plots in green denotes non-feasible points. Note that the user can avoid the display of the non-feasible points.

PostFactory().execute(
problem,
"ParetoFront",
show_non_feasible=False,
objectives=["compute_binhkorn"],
objectives_labels=["f1", "f2"],
save=False,
show=True,
)

PostFactory().execute(
problem,
"ParetoFront",
show_non_feasible=True,
objectives=["compute_binhkorn"],
objectives_labels=["f1", "f2"],
save=False,
show=True,
)

<gemseo.post.pareto_front.ParetoFront object at 0x7f8e3caf03d0>


Total running time of the script: ( 0 minutes 0.455 seconds)

Gallery generated by Sphinx-Gallery