# How to deal with post-processing¶

In this section we describe the post processing features of GEMSEO, used to analyze OptimizationResult, called the optimization history.

## What data to post-process?¶

Post-processing features are applicable to any OptimizationProblem that has been solved, which may have been loaded from the disk.

In practice,

## Illustration on the Sobieski use case¶

The post-processing features are illustrated on MDO results obtained on the SSBJ use case, using different types of formulation (MDF formulation, IDF formulation, …)

The following code sets up and executes the problem. It is possible to try different types of MDO strategies by changing the formulation value. For a detailed explanation on how to setup the case, please see sobieski_mdo.

from gemseo.api import create_discipline, create_scenario

formulation = 'MDF'

disciplines = create_discipline(["SobieskiPropulsion", "SobieskiAerodynamics",
"SobieskiMission", "SobieskiStructure"])

scenario = create_scenario(disciplines,
formulation=formulation,
objective_name="y_4",
maximize_objective=True,
design_space="design_space.txt")

scenario.set_differentiation_method("user")

algo_options = {'max_iter': 10, 'algo': "SLSQP"}
for constraint in ["g_1","g_2","g_3"]:

scenario.execute(algo_options)


## How to apply a post-process feature?¶

From this scenario, we can apply any kind of post-processing dedicated to Scenario instances,

• either by means of its post_process() method:

Scenario.post_process(post_name, **options)[source]

Post-process the optimization history.

Parameters:
• post_name (str) – The name of the post-processor, i.e. the name of a class inheriting from OptPostProcessor.

• **options (OptPostProcessorOptionType | Path) – The options for the post-processor.

Return type:

OptPostProcessor

• or by means of the execute_post() API method:

api.execute_post(post_name, **options)

Post-process a result.

Parameters:
• to_post_proc (Scenario | OptimizationProblem | str | Path) – The result to be post-processed, either a DOE scenario, a MDO scenario, an optimization problem or a path to an HDF file containing a saved optimization problem.

• post_name (str) – The name of the post-processing.

• **options (Any) – The post-processing options.

Returns:

The figures, to be customized if not closed.

Return type:

dict[str, Figure]

Examples

>>> from gemseo.api import create_discipline, create_scenario, execute_post
>>> from gemseo.problems.sellar.sellar_design_space import SellarDesignSpace
>>> 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=False, save=True)


Note

Only design variables and functions (objective function, constraints) are stored for post-processing. If you want to be able to plot state variables, you must add them as observables before the problem is executed. Use the add_observable() method.