GloMPO Scope¶
GloMPO provides a dynamic plotting object to track optimizer progress. This can be viewed in real-time, or saved into a movie file. This is useful for debugging and finding the right manager configurations. It provides insight into how the optimization behaved, and how the manager managed it.
The class details below are for reference only. The user need not initialise or control the scope directly; this is all done by GloMPO internals. To dynamically plot an optimization, see GloMPOManager.visualisation.
Please see Checkpointing & Visualisation if you are planning to make use of both simultaneously.
-
class
glompo.core.scope.GloMPOScope(x_range: Union[Tuple[float, float], int, None] = 300, y_range: Optional[Tuple[float, float]] = None, log_scale: bool = False, record_movie: bool = False, interactive_mode: bool = False, events_per_flush: int = 10, elitism: bool = False, writer_kwargs: Optional[Dict[str, Any]] = None, movie_kwargs: Optional[Dict[str, Any]] = None)[source]¶ Constructs and records the dynamic plotting of optimizers run in parallel.
Parameters: - x_range – If
Noneis provided the x-axis will automatically and continuously rescale from zero as the number of function evaluations increases. If a tuple of the form (min, max) is provided then the x-axis will be fixed to this range. If an integer is provided then the plot will only show the last x_range evaluations and discard earlier points. This is useful to make differences between optimizers visible in the late stage and also keep the scope operating at an adequate speed. - y_range – Sets the y-axis limits of the plot, by default the plot to automatically and constantly rescales the axis.
- log_scale – See
log_scale. This can be used in conjunction with the y_range option which will be interpreted in the log-scale. - record_movie – If
Truethen aFFMpegWriterinstance is created to record the plot. - interactive_mode – If
Truethe plot is visible on screen during the optimization. - events_per_flush – See
events_per_flush. - elitism – See
elitism. - writer_kwargs – Optional dictionary of arguments to be sent
matplotlib.animation.FFMpegWriter. - movie_kwargs – Optional dictionary of arguments to be sent to
matplotlib.animation.FFMpegWriter.setup ().
-
ax¶ Axesobject onto which the data is plotted.Type: matplotlib.axes.Axes
-
color_map¶ List which represents the GloMPO color sequence.
Type: matplotlib.colors.ListedColormap
-
elitism¶ If
Truean optimizer’s best function value over time will be plotted instead of its current function value. This greatly simplifies the plot, making it easier to see certain behaviour but also masks a lot of detail.Type: bool
-
events_per_flush¶ The number of ‘events’ or updates and changes to the scope before the changes are flushed and the plot is redrawn. A lower number provides a smoother visualisation but is expensive and, if recorded, takes a larger amount of space.
Type: int
-
fig¶ Figureobject into which theaxis embedded.Type: matplotlib.figure.Figure
-
gen_streams¶ Collection of ‘annotation’ plots used to indicate optimizer terminations, convergences, checkpoints etc.
Type: Dict[str, matplotlib.lines.Line2D]
-
interactive_mode¶ If
Truethe plot will be displayed in real-time with the optimization. Otherwise it will be constructed in memory only;record_moviewould need to beTrueto see the results.Type: bool
-
leg_elements¶ Holds the plot legend.
Type: List[matplotlib.lines.Line2D]
-
logger¶ logging.Loggerinstance into which status messages may be added.Type: logging.Logger
-
opt_streams¶ Collection of data plots representing the actual optimizer trajectories.
Type: Dict[str, matplotlib.lines.Line2D]
-
truncated¶ If a value is given, the plot will only retain data for the last truncated function evaluations.
Type: Optional[int]
-
is_setup¶ If
True,setup_moviemaker()has been properly called and the movie can be recorded.
-
add_stream(opt_id: int, opt_type: Optional[str] = None)[source]¶ Registers and sets up a new optimizer in the scope.
Parameters: - opt_id – Unique, GloMPO assigned, optimizer identification key.
- opt_type – String name of the optimizer type/configuration. Used only in the plot legend.
-
update_optimizer(opt_id: int, pt: tuple)[source]¶ Given pt is used to update the opt_id optimizer plot.
-
update_kill(opt_id: int)[source]¶ The opt_id optimizer plot is updated to show a manager termination at its final point.
-
update_norm_terminate(opt_id: int)[source]¶ The opt_id optimizer plot is updated to show normal convergence at its final point.
-
update_crash_terminate(opt_id: int)[source]¶ The opt_id optimizer plot is updated to show a crash termination at its final point.
-
update_pause(opt_id: int)[source]¶ The opt_id optimizer plot is updated to show a pause event at its final point.
-
update_checkpoint(opt_id: int)[source]¶ The opt_id optimizer plot is updated to show a checkpoint at its final point.
-
setup_moviemaker(path: Union[pathlib.Path, str, None] = None)[source]¶ Setups up the movie recording framework. Must be called before the scope begins to be filled in order to begin generating movies correctly.
Parameters: path – An optional directory into which the movie file will be directed. Will overwrite any ‘outfile’ argument sent during scope initialisation.
-
get_farthest_pt(opt_id: int) → Optional[Tuple[float, float]][source]¶ Returns the furthest evaluated point of the opt_id optimizer.
-
close_fig()[source]¶ Closes the
matplotlib.figure.Figurewhen the scope is closed. Matplotlib will keep a figure alive in its memory for the duration a process is alive. This can lead to many figures being open if GloMPO is looped in some way. The manager will explicitly call this method to close the matplotlib figure at the end of the optimization routine to stop figures building up in this way.
- x_range – If