watch_progress#
- nextnano_optimizers.plotting.watch_progress(json_path, interval=1.0, **plotter_kwargs)#
Display the progress of an optimization in a live-updating window.
Reads an optimization JSON log and updates the figures as new evaluations are recorded. The function waits if the log does not yet exist and blocks until the plotting window is closed.
- Parameters:
- json_pathstr or pathlib.Path
Path to the optimization JSON log. The file does not need to exist when the function is called.
- intervalfloat, default=1.0
Time interval, in seconds, between checks for updated results.
- **plotter_kwargs
Additional plotting configuration passed to
OptimizationPlotter.- param_nameslist of str, optional
Labels for the optimization variables. Defaults to
param1,param2, etc.- fitness_nameslist of str, optional
Labels for the objectives. Defaults to
fitness1,fitness2, etc.- exclude_failedbool, optional
If
True, exclude evaluations assigned thenon_execution_penaltyfrom the plots (i.e. failed evaluations).- fitness_limitslist or dict, optional
Plotting limits for each objective, specified as
(min, max)pairs. If dictionary is used, the keys should match the fitness names.- progress_seriessequence of str or str, optional
Curves to display in the optimization progress plot. Use
"all"to display all available curves. The series applicable to all optimizations: (“best”, “candidates”). The series also applicable to evolution: (“min-max”, “min”, “max”, “median”, “mean”).- series_labelsdict, optional
Custom legend labels for progress_series curves, keyed by curve tag from the
progress_series.- series_specsdict, optional
Custom plotting properties for individual curves, keyed by curve name. Each entry can specify
kindand/orstyle. See examples below.- iteration_labelstr, optional
Label used for optimization iterations.
- progress_titlestr, optional
Title of the optimization progress plot.
- population_labelstr, optional
Label used for candidates in the final iteration.
See also
OptimizationPlotterGenerate figures from optimization results.
Notes
The optimizers open the progress window automatically when
run(live_progress=True)is used.Calling
watch_progress()directly is useful for monitoring an optimization running in another process or on a remote machine, provided its JSON log is accessible.The function only reads the log and does not affect the optimization.
Examples
Monitor the progress of an optimization running in another process:
from nextnano_optimizers.plotting import watch_progress watch_progress( "Simulation_00001.json", interval=2.0, param_names=["Well width (nm)", "Barrier width (nm)"], fitness_names=["Energy error (eV)"], progress_title="Quantum well optimization", )