Note
Click here to download the full example code
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 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
from matplotlib import pyplot as plt
Import¶
The first step is to import some functions from the API and a method to get the design space.
configure_logger()
Out:
<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)
Out:
INFO - 07:14:57: Optimization problem:
INFO - 07:14:57: minimize compute_binhkorn(x, y) = (4*x**2+ 4*y**2, (x-5.)**2 + (y-5.)**2)
INFO - 07:14:57: with respect to x, y
INFO - 07:14:57: subject to constraints:
INFO - 07:14:57: ineq1(x, y): (x-5.)**2 + y**2 <= 25. <= 0.0
INFO - 07:14:57: ineq2(x, y): (x-8.)**2 + (y+3)**2 >= 7.7 <= 0.0
INFO - 07:14:57: over the design space:
INFO - 07:14:57: +------+-------------+-------+-------------+-------+
INFO - 07:14:57: | name | lower_bound | value | upper_bound | type |
INFO - 07:14:57: +------+-------------+-------+-------------+-------+
INFO - 07:14:57: | x | 0 | 1 | 5 | float |
INFO - 07:14:57: | y | 0 | 1 | 3 | float |
INFO - 07:14:57: +------+-------------+-------+-------------+-------+
INFO - 07:14:57: Solving optimization problem with algorithm OT_OPT_LHS:
INFO - 07:14:57: Generation of OT_OPT_LHS DOE with OpenTURNS
INFO - 07:14:57: ... 0%| | 0/100 [00:00<?, ?it]
INFO - 07:14:57: ... 100%|██████████| 100/100 [00:00<00:00, 4895.08 it/sec]
INFO - 07:14:57: Optimization result:
INFO - 07:14:57: Optimizer info:
INFO - 07:14:57: Status: None
INFO - 07:14:57: Message: None
INFO - 07:14:57: Number of calls to the objective function by the optimizer: 100
INFO - 07:14:57: Solution:
INFO - 07:14:57: The solution is feasible.
INFO - 07:14:57: Objective: 30.39964825035985
INFO - 07:14:57: Standardized constraints:
INFO - 07:14:57: ineq1 = [-11.77907222]
INFO - 07:14:57: ineq2 = [-38.26307397]
INFO - 07:14:57: Design space:
INFO - 07:14:57: +------+-------------+-------------------+-------------+-------+
INFO - 07:14:57: | name | lower_bound | value | upper_bound | type |
INFO - 07:14:57: +------+-------------+-------------------+-------------+-------+
INFO - 07:14:57: | x | 0 | 1.542975634014225 | 5 | float |
INFO - 07:14:57: | y | 0 | 1.269910308585573 | 3 | float |
INFO - 07:14:57: +------+-------------+-------------------+-------------+-------+
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",
save=False,
show=False,
show_non_feasible=False,
objectives=["compute_binhkorn"],
objectives_labels=["f1", "f2"],
)
PostFactory().execute(
problem,
"ParetoFront",
save=False,
show=False,
show_non_feasible=True,
objectives=["compute_binhkorn"],
objectives_labels=["f1", "f2"],
)
# Workaround for HTML rendering, instead of ``show=True``
plt.show()
Total running time of the script: ( 0 minutes 0.432 seconds)