.. 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 Click :ref:`here ` 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 31-49 .. code-block:: default from __future__ import absolute_import, division, print_function, unicode_literals from future import standard_library from gemseo.api import ( configure_logger, create_discipline, create_scenario, execute_post, get_available_post_processings, get_post_processing_options_schema, ) from gemseo.problems.sellar.sellar_design_space import SellarDesignSpace configure_logger() standard_library.install_aliases() .. GENERATED FROM PYTHON SOURCE LINES 50-55 Get available DOE algorithms ---------------------------- The :meth:`~gemseo.api.get_available_post_processings` function returns the list of post-processing algorithms available in |g| or in external modules .. GENERATED FROM PYTHON SOURCE LINES 55-57 .. code-block:: default print(get_available_post_processings()) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ['BasicHistory', 'ConstraintsHistory', 'Correlations', 'GradientSensitivity', 'KMeans', 'ObjConstrHist', 'OptHistoryView', 'ParallelCoordinates', 'ParetoFront', 'QuadApprox', 'RadarChart', 'Robustness', 'SOM', 'ScatterPlotMatrix', 'VariableInfluence'] .. GENERATED FROM PYTHON SOURCE LINES 58-62 Get options schema ------------------ For a given post-processing algorithm, e.g. :code:`"RadarChart"`, we can get the options; e.g. .. GENERATED FROM PYTHON SOURCE LINES 62-64 .. code-block:: default print(get_post_processing_options_schema("RadarChart")) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none {'name': 'RadarChart_options', '$schema': 'http://json-schema.org/draft-04/schema', 'type': 'object', 'properties': {'save': {'type': 'boolean', 'description': 'if True, exports plot to pdf\n:type save: bool\n'}, 'show': {'type': 'boolean', 'description': 'if True, displays the plot windows\n:type show: bool\n'}, 'file_path': {'type': 'string', 'description': 'the base paths of the files to export\n:type file_path: str\n'}, 'extension': {'type': 'string', 'description': 'file extension\n:type extension: str'}, 'iteration': {'type': 'integer', 'description': 'number of iteration to post process\n:type iteration: int\n'}, 'figsize_x': {'minimum': 2.0, 'type': 'number'}, 'figsize_y': {'minimum': 2.0, 'type': 'number'}, 'constraints_list': {'type': 'array', 'description': 'list of constraints names\n:type constraints_list: list(str)\n', 'items': {'minItems': 1, 'type': 'string'}}}, 'required': ['constraints_list', 'save']} .. GENERATED FROM PYTHON SOURCE LINES 65-71 Post-process a scenario ----------------------- The API function :meth:`~gemseo.api.execute_post` can generate visualizations of the optimization or DOE results. For that, it consider the object to post-process :code:`to_post_proc`, the post processing :code:`post_name` with its :code:`**options`. E.g. .. GENERATED FROM PYTHON SOURCE LINES 71-78 .. code-block:: default disciplines = create_discipline(["Sellar1", "Sellar2", "SellarSystem"]) design_space = SellarDesignSpace() scenario = create_scenario( disciplines, "MDF", "obj", design_space, "SellarMDFScenario", "MDO" ) scenario.execute({"algo": "NLOPT_SLSQP", "max_iter": 100}) execute_post(scenario, "OptHistoryView", show=True, save=False) .. rst-class:: sphx-glr-horizontal * .. image:: /examples/api/images/sphx_glr_plot_post_001.png :alt: Evolution of the optimization variables :class: sphx-glr-multi-img * .. image:: /examples/api/images/sphx_glr_plot_post_002.png :alt: Evolution of the objective value :class: sphx-glr-multi-img * .. image:: /examples/api/images/sphx_glr_plot_post_003.png :alt: Distance to the optimum :class: sphx-glr-multi-img * .. image:: /examples/api/images/sphx_glr_plot_post_004.png :alt: Hessian diagonal approximation :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/gemseo/conda/3.0.3/lib/python3.8/site-packages/gemseo/post/opt_history_view.py:312: UserWarning: FixedFormatter should only be used together with FixedLocator ax1.set_yticklabels(y_labels) /home/docs/checkouts/readthedocs.org/user_builds/gemseo/conda/3.0.3/lib/python3.8/site-packages/gemseo/post/opt_history_view.py:716: MatplotlibDeprecationWarning: default base will change from np.e to 10 in 3.4. To suppress this warning specify the base keyword argument. norm=SymLogNorm(linthresh=linthresh, vmin=-vmax, vmax=vmax), .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.778 seconds) .. _sphx_glr_download_examples_api_plot_post.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_post.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_post.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_