.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/post_process/save_from_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_save_from_scenario.py: Save a scenario for post-processing =================================== .. GENERATED FROM PYTHON SOURCE LINES 26-32 .. code-block:: default from __future__ import annotations from gemseo import create_design_space from gemseo import create_discipline from gemseo import create_scenario .. GENERATED FROM PYTHON SOURCE LINES 33-35 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 35-42 .. code-block:: default discipline = create_discipline("AnalyticDiscipline", expressions={"y": "x**2"}) design_space = create_design_space() design_space.add_variable("x", l_b=0.0, u_b=1.0) scenario = create_scenario([discipline], "DisciplinaryOpt", "y", design_space) .. GENERATED FROM PYTHON SOURCE LINES 43-44 We solve this optimization problem with the gradient-free algorithm COBYLA: .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: default scenario.execute({"algo": "NLOPT_COBYLA", "max_iter": 10}) .. GENERATED FROM PYTHON SOURCE LINES 47-49 Then, we save the results to an HDF5 file for future post-processing: .. GENERATED FROM PYTHON SOURCE LINES 49-51 .. code-block:: default scenario.save_optimization_history("my_results.hdf") .. GENERATED FROM PYTHON SOURCE LINES 52-53 .. seealso:: :ref:`sphx_glr_examples_post_process_post_process_file.py`. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_examples_post_process_save_from_scenario.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: save_from_scenario.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: save_from_scenario.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_