.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/api/plot_post.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_api_plot_post.py: Post-processing =============== In this example, we will discover the different functions of the API related to graphical post-processing of scenarios. .. GENERATED FROM PYTHON SOURCE LINES 29-38 .. code-block:: Python from __future__ import annotations 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 .. GENERATED FROM PYTHON SOURCE LINES 39-44 Get available post-processors ----------------------------- The :func:`.get_available_post_processings` function returns the list of post-processing algorithms available in |g| or in external modules .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: Python get_available_post_processings() .. rst-class:: sphx-glr-script-out .. code-block:: none ['Animation', 'BasicHistory', 'ConstraintsHistory', 'Correlations', 'DataVersusModel', 'GradientSensitivity', 'HessianHistory', 'ObjConstrHist', 'OptHistoryView', 'ParallelCoordinates', 'ParetoFront', 'QuadApprox', 'RadarChart', 'Robustness', 'SOM', 'ScatterPlotMatrix', 'TopologyView', 'VariableInfluence'] .. GENERATED FROM PYTHON SOURCE LINES 47-53 Post-process a scenario ----------------------- The API function :func:`.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. .. GENERATED FROM PYTHON SOURCE LINES 53-63 .. code-block:: Python 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) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/api/images/sphx_glr_plot_post_001.png :alt: Evolution of the optimization variables :srcset: /examples/api/images/sphx_glr_plot_post_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/api/images/sphx_glr_plot_post_002.png :alt: Evolution of the objective value :srcset: /examples/api/images/sphx_glr_plot_post_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/api/images/sphx_glr_plot_post_003.png :alt: Evolution of the distance to the optimum :srcset: /examples/api/images/sphx_glr_plot_post_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/api/images/sphx_glr_plot_post_004.png :alt: Evolution of the inequality constraints :srcset: /examples/api/images/sphx_glr_plot_post_004.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 16:24:57: *** Start SellarMDFScenario execution *** INFO - 16:24:57: SellarMDFScenario INFO - 16:24:57: Disciplines: Sellar1 Sellar2 SellarSystem INFO - 16:24:57: MDO formulation: MDF INFO - 16:24:57: Optimization problem: INFO - 16:24:57: minimize obj(x_1, x_2, x_shared) INFO - 16:24:57: with respect to x_1, x_2, x_shared INFO - 16:24:57: under the inequality constraints INFO - 16:24:57: c_1(x_1, x_2, x_shared) <= 0 INFO - 16:24:57: c_2(x_1, x_2, x_shared) <= 0 INFO - 16:24:57: over the design space: INFO - 16:24:57: +-------------+-------------+-------+-------------+-------+ INFO - 16:24:57: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:24:57: +-------------+-------------+-------+-------------+-------+ INFO - 16:24:57: | x_1 | 0 | 1 | 10 | float | INFO - 16:24:57: | x_2 | 0 | 1 | 10 | float | INFO - 16:24:57: | x_shared[0] | -10 | 4 | 10 | float | INFO - 16:24:57: | x_shared[1] | 0 | 3 | 10 | float | INFO - 16:24:57: +-------------+-------------+-------+-------------+-------+ INFO - 16:24:57: Solving optimization problem with algorithm NLOPT_SLSQP: INFO - 16:24:57: 1%| | 1/100 [00:00<00:01, 51.98 it/sec, feas=True, obj=23] INFO - 16:24:57: 2%|▏ | 2/100 [00:00<00:01, 68.08 it/sec, feas=True, obj=5.39] INFO - 16:24:57: 3%|▎ | 3/100 [00:00<00:01, 77.17 it/sec, feas=True, obj=3.41] INFO - 16:24:57: 4%|▍ | 4/100 [00:00<00:01, 82.27 it/sec, feas=True, obj=3.19] INFO - 16:24:57: 5%|▌ | 5/100 [00:00<00:01, 85.56 it/sec, feas=True, obj=3.18] INFO - 16:24:57: 6%|▌ | 6/100 [00:00<00:01, 87.80 it/sec, feas=True, obj=3.18] ERROR - 16:24:57: NLopt run failed: NLopt roundoff-limited, RoundoffLimited nlopt.RoundoffLimited: NLopt roundoff-limited INFO - 16:24:57: Optimization result: INFO - 16:24:57: Optimizer info: INFO - 16:24:57: Status: None INFO - 16:24:57: Message: GEMSEO stopped the driver. INFO - 16:24:57: Solution: INFO - 16:24:57: The solution is feasible. INFO - 16:24:57: Objective: 3.1833939621753298 INFO - 16:24:57: Standardized constraints: INFO - 16:24:57: c_1 = 1.6424639426304566e-11 INFO - 16:24:57: c_2 = -20.244722684036216 INFO - 16:24:57: Design space: INFO - 16:24:57: +-------------+-------------+-----------------------+-------------+-------+ INFO - 16:24:57: | Name | Lower bound | Value | Upper bound | Type | INFO - 16:24:57: +-------------+-------------+-----------------------+-------------+-------+ INFO - 16:24:57: | x_1 | 0 | 5.024971568646571e-12 | 10 | float | INFO - 16:24:57: | x_2 | 0 | 0 | 10 | float | INFO - 16:24:57: | x_shared[0] | -10 | 1.977638860654281 | 10 | float | INFO - 16:24:57: | x_shared[1] | 0 | 1.344468165645798e-12 | 10 | float | INFO - 16:24:57: +-------------+-------------+-----------------------+-------------+-------+ INFO - 16:24:57: *** End SellarMDFScenario execution *** .. GENERATED FROM PYTHON SOURCE LINES 64-67 It is also possible to pass a settings model to :func:`.execute_post` with the keyword ``settings_model``, as shown below. See :ref:`post_processor_settings` for more information. .. GENERATED FROM PYTHON SOURCE LINES 67-77 .. code-block:: Python 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, ), ) .. image-sg:: /examples/api/images/sphx_glr_plot_post_005.png :alt: Evolution of the constraints w.r.t. iterations, c_1 (inequality), c_2 (inequality) :srcset: /examples/api/images/sphx_glr_plot_post_005.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.684 seconds) .. _sphx_glr_download_examples_api_plot_post.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_post.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_post.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_post.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_