qdesignoptimizer.sim_plot_progress module
Visualization utilities for tracking optimization progress of quantum circuit designs.
- class qdesignoptimizer.sim_plot_progress.UnitEnum(value)[source]
-
Supported frequency units for plotting.
- HZ = 'Hz'
- KHZ = 'kHz'
- MHZ = 'MHz'
- GHZ = 'GHz'
- FF = 'fF'
- S = 's'
- MS = 'ms'
- US = 'us'
- NS = 'ns'
- class qdesignoptimizer.sim_plot_progress.OptPltSet(x: str, y: str | List[str], x_label: str | None = None, y_label: str | None = None, x_scale: Literal['linear', 'log'] = 'linear', y_scale: Literal['linear', 'log'] = 'linear', unit: UnitEnum = UnitEnum.HZ)[source]
Bases:
object
Configuration for optimization progress plots.
- class qdesignoptimizer.sim_plot_progress.DataExtractor(opt_results: List[List[Dict[str, Any]]], system_target_params: Dict[str, Any], opt_target_list: List[OptTarget] | None = None)[source]
Bases:
object
Extracts data from optimization results for plotting.
- get_parameter_value(param_name: str, result: Dict[str, Any], iteration: int) float | None [source]
Extract parameter value from a result entry.
- Parameters:
param_name – Name of the parameter to extract
result – Optimization result entry
iteration – Iteration number (for ITERATION parameter)
- Returns:
Parameter value or None if not found
- get_design_var_name_for_param(target_parameter: str) str [source]
Find the design variable name associated with a target parameter.
- Parameters:
target_parameter – Target parameter name
- Returns:
Name of the associated design variable
- Raises:
AssertionError – If the parameter is not found in optimization targets
- get_design_var_for_param(target_parameter: str, result: Dict[str, Any]) Tuple[float, str] [source]
Get design variable value and unit for a target parameter.
- Parameters:
target_parameter – Target parameter name
result – Optimization result entry
- Returns:
Tuple of (value, unit)
- extract_xy_data(x_param: str, y_param: str, run_index: int, use_design_var_as_x: bool = False, sort_by_x: bool = False) Tuple[List[float], List[float]] [source]
Extract x and y data series for plotting.
- Parameters:
x_param – X-axis parameter name
y_param – Y-axis parameter name
run_index – Index of the optimization run to use
use_design_var_as_x – If True, use design variable for x instead of parameter
sort_by_x – If True, sort the data by x values
- Returns:
Tuple of (x_values, y_values)
- get_y_data_with_statistics(x_param: str, y_param: str, use_design_var_as_x: bool = False, sort_by_x: bool = False) Tuple[List[float], ndarray, ndarray] [source]
Extract y data with mean and standard deviation across runs.
- Parameters:
x_param – X-axis parameter name
y_param – Y-axis parameter name
use_design_var_as_x – If True, use design variable for x instead of parameter
sort_by_x – If True, sort the data by x values
- Returns:
Tuple of (x_values, y_mean, y_std)
- class qdesignoptimizer.sim_plot_progress.OptimizationPlotter(data_extractor: DataExtractor, plot_variance: bool = False, save_figures: bool = False)[source]
Bases:
object
Handles plotting of optimization progress data.
- plot_standard(fig: Figure, axes: Axes | List[Axes], plot_settings: List[OptPltSet], plot_name: str) None [source]
Create standard parameter vs. iteration plots.
- Parameters:
fig – Matplotlib figure
axes – Single axis or list of axes
plot_settings – List of plot configurations
plot_name – Name for the plot (used for saving)
- plot_params_vs_design_vars(fig: Figure, axes: Axes | List[Axes], plot_settings: List[OptPltSet], plot_name: str, sort_by_x: bool = True) None [source]
Create plots of parameters vs. their associated design variables.
- Parameters:
fig – Matplotlib figure
axes – Single axis or list of axes
plot_settings – List of plot configurations
plot_name – Name for the plot (used for saving)
sort_by_x – If True, sort data points by x value
- plot_design_vars_vs_iteration(fig: Figure, axes: Axes | List[Axes], plot_settings: List[OptPltSet], plot_name: str) None [source]
Create plots of design variables vs. iteration.
- Parameters:
fig – Matplotlib figure
axes – Single axis or list of axes
plot_settings – List of plot configurations
plot_name – Name for the plot (used for saving)
- qdesignoptimizer.sim_plot_progress.plot_progress(opt_results: List[List[Dict[str, Any]]], system_target_params: Dict[str, Any], plot_settings: Dict[str, List[OptPltSet]], block_plots: bool = False, save_figures: bool = False, plot_variance: bool = False, plot_design_variables: Literal['chronological', 'sorted'] | None = None, opt_target_list: List[OptTarget] | None = None) None [source]
Plot the progress of optimization iterations.
- Parameters:
opt_results – List of optimization result sequences (one per optimization run)
system_target_params – Target system parameters
plot_settings – Plot configurations by plot name
block_plots – If True, block execution until plots are closed
save_figures – If True, save figures to disk
plot_variance – If True, plot mean and variance across runs
plot_design_variables – How to plot design variables (“chronological”, “sorted”, or None to disable)
opt_target_list – Optional list of optimization targets