gemseo / post

# opt_history_view module¶

Basic display of optimization history: functions and x.

class gemseo.post.opt_history_view.OptHistoryView(opt_problem)[source]

The OptHistoryView post processing performs separated plots: the design variables history, the objective function history, the history of hessian approximation of the objective, the inequality constraint history, the equality constraint history, and constraints histories.

By default, all design variables are considered. A sublist of design variables can be passed as options. Minimum and maximum values for the plot can be passed as options. The objective function can also be represented in terms of difference w.r.t. the initial value. It is possible either to save the plot, to show the plot or both.

Parameters

opt_problem (gemseo.algos.opt_problem.OptimizationProblem) – The optimization problem to be post-processed.

Raises

ValueError – If the JSON grammar file for the options of the post-processor does not exist.

Return type

None

check_options(**options)

Check the options of the post-processor.

Parameters

**options (Union[int, float, str, bool, Sequence[str]]) – The options of the post-processor.

Raises

InvalidDataException – If an option is invalid according to the grammar.

Return type

None

execute(save=True, show=False, file_path=None, directory_path=None, file_name=None, file_extension=None, fig_size=None, **options)

Post-process the optimization problem.

Parameters
• save (bool) –

If True, save the figure.

By default it is set to True.

• show (bool) –

If True, display the figure.

By default it is set to False.

• file_path (str | Path | None) –

The path of the file to save the figures. If the extension is missing, use file_extension. If None, create a file path from directory_path, file_name and file_extension.

By default it is set to None.

• directory_path (str | Path | None) –

The path of the directory to save the figures. If None, use the current working directory.

By default it is set to None.

• file_name (str | None) –

The name of the file to save the figures. If None, use a default one generated by the post-processing.

By default it is set to None.

• file_extension (str | None) –

A file extension, e.g. ‘png’, ‘pdf’, ‘svg’, … If None, use a default file extension.

By default it is set to None.

• fig_size (tuple[float, float] | None) –

The width and height of the figure in inches, e.g. (w, h). If None, use the OptPostProcessor.DEFAULT_FIG_SIZE of the post-processor.

By default it is set to None.

• **options (OptPostProcessorOptionType) – The options of the post-processor.

Returns

The figures, to be customized if not closed.

Raises

ValueError – If the opt_problem.database is empty.

DEFAULT_FIG_SIZE = (11.0, 6.0)

The default width and height of the figure, in inches.

Type
database: Database

The database generated by the optimization problem.

property figures: dict[str, matplotlib.figure.Figure]

The Matplotlib figures indexed by a name, or the nameless figure counter.

materials_for_plotting: dict[Any, Any]

The materials to eventually rebuild the plot in another framework.

opt_problem: OptimizationProblem

The optimization problem.

property output_files: list[str]

The paths to the output files.