gemseo / post

quad_approx module

Quadratic approximations of functions from the optimization history.

Classes:

QuadApprox(opt_problem)

Quadratic approximation of a function.

class gemseo.post.quad_approx.QuadApprox(opt_problem)[source]

Bases: gemseo.post.opt_post_processor.OptPostProcessor

Quadratic approximation of a function.

And cuts of the approximation.

The function index can be passed as option.

Parameters

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

Attributes:

DEFAULT_FIG_SIZE

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

SR1_APPROX

figures

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

output_files

The paths to the output files.

Methods:

check_options(**options)

Check the options of the post-processor.

execute([save, show, file_path, ...])

Post-process the optimization problem.

unnormalize_vector(xn_array, ivar, ...)

Unormalize a variable with respect to bounds.

DEFAULT_FIG_SIZE = (9.0, 6.0)

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

Type

tuple(float, float)

SR1_APPROX = 'SR1'
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 (Optional[Union[str, pathlib.Path]]) –

    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 (Optional[Union[str, pathlib.Path]]) –

    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 (Optional[str]) –

    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 (Optional[str]) –

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

    By default it is set to None.

  • fig_size (Optional[Tuple[float, float]]) –

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

    By default it is set to None.

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

Returns

The figures, to be customized if not closed.

Raises

ValueError – If the opt_problem.database is empty.

Return type

Dict[str, matplotlib.figure.Figure]

property figures

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

property output_files

The paths to the output files.

static unnormalize_vector(xn_array, ivar, lower_bounds, upper_bounds)[source]

Unormalize a variable with respect to bounds.

Parameters
  • xn_array (numpy.ndarray) – The normalized variable.

  • ivar (int) – The index of the variable bound.

  • lower_bounds (numpy.ndarray) – The lower bounds of the variable.

  • upper_bounds (numpy.ndarray) – The upper bounds of the variable.

Returns

The unnormalized variable.

Return type

numpy.ndarray