Note
Go to the end to download the full example code.
Post-processing#
In this example, we will discover the different functions of the API related to graphical post-processing of scenarios.
from __future__ import annotations
from gemseo import configure_logger
from gemseo import create_discipline
from gemseo import create_scenario
from gemseo import execute_post
from gemseo import get_available_post_processings
from gemseo.problems.mdo.sellar.sellar_design_space import SellarDesignSpace
configure_logger()
<RootLogger root (INFO)>
Get available post-processors#
The get_available_post_processings() function returns the list
of post-processing algorithms available in GEMSEO or in external modules
get_available_post_processings()
['Animation', 'BasicHistory', 'Compromise', 'ConstraintsHistory', 'Correlations', 'DataVersusModel', 'GradientSensitivity', 'HessianHistory', 'HighTradeOff', 'MultiObjectiveDiagram', 'ObjConstrHist', 'OptHistoryView', 'ParallelCoordinates', 'ParetoFront', 'Petal', 'QuadApprox', 'Radar', 'RadarChart', 'Robustness', 'SOM', 'ScatterPareto', 'ScatterPlotMatrix', 'TopologyView', 'VariableInfluence']
Post-process a scenario#
The API function execute_post() can generate visualizations
of the optimization or DOE results. For that, it considers the object to
post-process to_post_proc, the post-processor post_name
with its **settings. E.g.
disciplines = create_discipline(["Sellar1", "Sellar2", "SellarSystem"])
design_space = SellarDesignSpace()
scenario = create_scenario(
disciplines, "obj", design_space, name="SellarMDFScenario", formulation_name="MDF"
)
scenario.add_constraint("c_1", constraint_type="ineq")
scenario.add_constraint("c_2", constraint_type="ineq")
scenario.execute(algo_name="NLOPT_SLSQP", max_iter=100)
execute_post(scenario, post_name="OptHistoryView", save=False, show=False)
INFO - 11:43:08: *** Start SellarMDFScenario execution ***
INFO - 11:43:08: SellarMDFScenario
INFO - 11:43:08: Disciplines: Sellar1 Sellar2 SellarSystem
INFO - 11:43:08: MDO formulation: MDF
INFO - 11:43:08: Optimization problem:
INFO - 11:43:08: minimize obj(x_1, x_2, x_shared)
INFO - 11:43:08: with respect to x_1, x_2, x_shared
INFO - 11:43:08: subject to constraints:
INFO - 11:43:08: c_1(x_1, x_2, x_shared) <= 0
INFO - 11:43:08: c_2(x_1, x_2, x_shared) <= 0
INFO - 11:43:08: over the design space:
INFO - 11:43:08: +-------------+-------------+-------+-------------+-------+
INFO - 11:43:08: | Name | Lower bound | Value | Upper bound | Type |
INFO - 11:43:08: +-------------+-------------+-------+-------------+-------+
INFO - 11:43:08: | x_1 | 0 | 1 | 10 | float |
INFO - 11:43:08: | x_2 | 0 | 1 | 10 | float |
INFO - 11:43:08: | x_shared[0] | -10 | 4 | 10 | float |
INFO - 11:43:08: | x_shared[1] | 0 | 3 | 10 | float |
INFO - 11:43:08: +-------------+-------------+-------+-------------+-------+
INFO - 11:43:08: Solving optimization problem with algorithm NLOPT_SLSQP:
INFO - 11:43:08: 1%| | 1/100 [00:00<00:01, 74.59 it/sec, obj=23]
INFO - 11:43:08: 2%|▏ | 2/100 [00:00<00:02, 37.55 it/sec, obj=5.39]
INFO - 11:43:08: 3%|▎ | 3/100 [00:00<00:02, 44.05 it/sec, obj=3.41]
INFO - 11:43:08: 4%|▍ | 4/100 [00:00<00:02, 47.98 it/sec, obj=3.19]
INFO - 11:43:08: 5%|▌ | 5/100 [00:00<00:01, 51.15 it/sec, obj=3.18]
INFO - 11:43:08: 6%|▌ | 6/100 [00:00<00:01, 53.38 it/sec, obj=3.18]
ERROR - 11:43:08: NLopt run failed: NLopt roundoff-limited, RoundoffLimited
nlopt.RoundoffLimited: NLopt roundoff-limited
INFO - 11:43:08: 7%|▋ | 7/100 [00:00<00:01, 61.32 it/sec, obj=3.18]
INFO - 11:43:08: Optimization result:
INFO - 11:43:08: Optimizer info:
INFO - 11:43:08: Status: None
INFO - 11:43:08: Message: GEMSEO stopped the driver.
INFO - 11:43:08: Number of calls to the objective function by the optimizer: 8
INFO - 11:43:08: Solution:
INFO - 11:43:08: The solution is feasible.
INFO - 11:43:08: Objective: 3.1833939621753298
INFO - 11:43:08: Standardized constraints:
INFO - 11:43:08: c_1 = 1.6424639426304566e-11
INFO - 11:43:08: c_2 = -20.244722684036216
INFO - 11:43:08: Design space:
INFO - 11:43:08: +-------------+-------------+-----------------------+-------------+-------+
INFO - 11:43:08: | Name | Lower bound | Value | Upper bound | Type |
INFO - 11:43:08: +-------------+-------------+-----------------------+-------------+-------+
INFO - 11:43:08: | x_1 | 0 | 5.024971568646571e-12 | 10 | float |
INFO - 11:43:08: | x_2 | 0 | 0 | 10 | float |
INFO - 11:43:08: | x_shared[0] | -10 | 1.977638860654281 | 10 | float |
INFO - 11:43:08: | x_shared[1] | 0 | 1.344468165645798e-12 | 10 | float |
INFO - 11:43:08: +-------------+-------------+-----------------------+-------------+-------+
INFO - 11:43:08: *** End SellarMDFScenario execution (time: 0:00:00.117332) ***
<gemseo.post.opt_history_view.OptHistoryView object at 0x704929b93710>
It is also possible to pass a settings model to execute_post() with the keyword
settings_model, as shown below. See Post-processor Settings for more
information.
from gemseo.settings.post import ConstraintsHistory_Settings # noqa: E402
execute_post(
scenario,
settings_model=ConstraintsHistory_Settings(
constraint_names=["c_1", "c_2"],
save=False,
show=True,
),
)

<gemseo.post.constraints_history.ConstraintsHistory object at 0x70492a0414f0>
Total running time of the script: (0 minutes 1.168 seconds)



