.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/post_process/post_process_scenario.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_post_process_post_process_scenario.py: Post-process a scenario ======================= .. GENERATED FROM PYTHON SOURCE LINES 25-33 .. code-block:: Python from __future__ import annotations from gemseo import create_design_space from gemseo import create_discipline from gemseo import create_scenario from gemseo import execute_post .. GENERATED FROM PYTHON SOURCE LINES 34-36 We consider a minimization problem over the interval :math:`[0,1]` of the :math:`f(x)=x^2` objective function: .. GENERATED FROM PYTHON SOURCE LINES 36-45 .. code-block:: Python discipline = create_discipline("AnalyticDiscipline", expressions={"y": "x**2"}) design_space = create_design_space() design_space.add_variable("x", lower_bound=0.0, upper_bound=1.0) scenario = create_scenario( [discipline], "y", design_space, formulation_name="DisciplinaryOpt" ) .. GENERATED FROM PYTHON SOURCE LINES 46-47 We solve this optimization problem with the gradient-free algorithm COBYLA: .. GENERATED FROM PYTHON SOURCE LINES 47-49 .. code-block:: Python scenario.execute(algo_name="NLOPT_COBYLA", max_iter=10) .. GENERATED FROM PYTHON SOURCE LINES 50-53 Then, we can post-process this :class:`.MDOScenario` either with its method :meth:`~.MDOScenario.post_process`: .. GENERATED FROM PYTHON SOURCE LINES 53-55 .. code-block:: Python scenario.post_process(post_name="BasicHistory", variable_names=["y"]) .. GENERATED FROM PYTHON SOURCE LINES 56-57 or with the function :func:`.execute_post`: .. GENERATED FROM PYTHON SOURCE LINES 57-59 .. code-block:: Python execute_post(scenario, post_name="BasicHistory", variable_names=["y"]) .. GENERATED FROM PYTHON SOURCE LINES 60-65 .. note:: By default, |g| saves the images on the disk. Use ``save=False`` to not save figures and ``show=True`` to display them on the screen. .. seealso:: `Post-processing algorithms `_. .. _sphx_glr_download_examples_post_process_post_process_scenario.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: post_process_scenario.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: post_process_scenario.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: post_process_scenario.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_