Post-processing

In this example, we will discover the different functions of the API related to graphical post-processing of scenarios.

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()

Get available DOE algorithms

The get_available_post_processings() function returns the list of post-processing algorithms available in GEMSEO or in external modules

print(get_available_post_processings())

Out:

['BasicHistory', 'ConstraintsHistory', 'Correlations', 'GradientSensitivity', 'KMeans', 'ObjConstrHist', 'OptHistoryView', 'ParallelCoordinates', 'ParetoFront', 'QuadApprox', 'RadarChart', 'Robustness', 'SOM', 'ScatterPlotMatrix', 'VariableInfluence']

Get options schema

For a given post-processing algorithm, e.g. "RadarChart", we can get the options; e.g.

print(get_post_processing_options_schema("RadarChart"))

Out:

{'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']}

Post-process a scenario

The API function execute_post() can generate visualizations of the optimization or DOE results. For that, it consider the object to post-process to_post_proc, the post processing post_name with its **options. E.g.

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)
  • Evolution of the optimization variables
  • Evolution of the objective value
  • Distance to the optimum
  • Hessian diagonal approximation

Out:

/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),

<gemseo.post.opt_history_view.OptHistoryView object at 0x7fc2990f3490>

Total running time of the script: ( 0 minutes 0.778 seconds)

Gallery generated by Sphinx-Gallery