pysolver_view.reporting.plots module#

Passive live/static plots of detached public observations.

class pysolver_view.reporting.plots.PlotView[source]#

Bases: SimpleNamespace

Figure handles and recorded data supplied by a frontend.

pysolver_view.reporting.plots.plot_optimization_history(self, savefile=False, filename=None, output_dir='output', showfig=True)[source]#

Plot the convergence history of the problem.

This method plots progress against the selected evaluation or native-iteration count:
  • Objective function value (left y-axis)

  • Maximum constraint violation (right y-axis)

Constraint violation is displayed for nonlinear constraints or finite variable bounds.

This method should be called only after the optimization problem has been solved, as it relies on data generated by the solving process.

Parameters:
savefilebool, optional

If True, the plot is saved to a file instead of being displayed. Default is False.

filenamestr, optional

The name of the file to save the plot to. If not specified, the filename is automatically generated using the problem name and the start datetime. The file extension is not required.

output_dirstr, optional

The directory where the plot file will be saved if savefile is True. Default is “output”.

Returns:
matplotlib.figure.Figure

The Matplotlib figure object for the plot. This can be used for further customization or display.

Raises:
ValueError

If this method is called before the problem has been solved.

pysolver_view.reporting.plots.plot_root_history(self, savefile=False, filename=None, output_dir='output', *, showfig=True)[source]#

Plot the residual two-norm against function or Jacobian evaluations.

Numerical derivative probes are excluded from the function-observation axis and remain included in total model-call counters. Native accepted iteration counts are not available from SciPy’s LM/hybrid interface.

This method should be called only after the optimization problem has been solved, as it relies on data generated by the solving process.

Parameters:
savefilebool, optional

If True, the plot is saved to a file instead of being displayed. Default is False.

filenamestr, optional

The name of the file to save the plot to. If not specified, the filename is automatically generated using the problem name and the start datetime. The file extension is not required.

output_dirstr, optional

The directory where the plot file will be saved if savefile is True. Default is “output”.

Returns:
matplotlib.figure.Figure

The Matplotlib figure object for the plot. This can be used for further customization or display.

Raises:
ValueError

If this method is called before the problem has been solved.

pysolver_view.reporting.plots.update_optimization_plot(self, x, iter, initialize=False, showfig=True)[source]#

Callback function to dynamically update the convergence progress plot.

This method initializes a matplotlib plot on the first iteration and updates the data for each subsequent iteration. The plot showcases the evolution of the objective function and the constraint violation with respect to the number of iterations.

The left y-axis depicts the objective function values, while the right y-axis showcases the constraint violation values. The x-axis represents the number of iterations. Both lines are updated and redrawn dynamically as iterations progress.

Note:

This is an internal method, meant to be called within the optimization process.

pysolver_view.reporting.plots.update_root_plot(self, initialize=False, showfig=True)[source]#

Callback function to dynamically update the convergence progress plot.

Initialize or update a plot of residual observations against their function/Jacobian evaluation counts. Rendering never evaluates the model or modifies the recorded data.

Note:

This is an internal method, meant to be called within the optimization process.