DCRABOptimizerGradient#
- class DCRABOptimizerGradient(measure_and_gradient_func, optimization_map, super_iteration_every=30, max_super_iteration_num=10, print_every_iteration_num=5, fallback_optimization=None, super_iteration_tol=1e-07, seed=None)[source]#
Bases:
ScipyOptimizerGradientA dCRAB optimization method [3, 14].
Implements dCRAB optimization involving super-iterations that add additional optimization components to the dCRAB envelope and freezes the older parameters.
Note
This works with a
DCRABEnvelopeor alist[DCRABEnvelope]as envelopes.- __init__(measure_and_gradient_func, optimization_map, super_iteration_every=30, max_super_iteration_num=10, print_every_iteration_num=5, fallback_optimization=None, super_iteration_tol=1e-07, seed=None)[source]#
- Parameters:
measure_and_gradient_func (Callable[[Array], tuple[Float, Array]]) – Function implementing measurement of observables to be minimized, returning (value, gradient).
optimization_map (OptimizationMap) – An optimization map containing all parameters that can be optimized.
super_iteration_every (int) – Number of iterations after which one super-iteration is performed. Defaults to 30.
max_super_iteration_num (int) – Maximum number of super-iterations to perform. Defaults to 10.
print_every_iteration_num (int) – Print every this many iterations the current optimization value. Defaults to 5.
fallback_optimization (Optimizer | None) – Fallback optimization to perform after all super-iterations.
super_iteration_tol (float) – Tolerance for triggering a super-iteration. Defaults to 1e-7.
seed (int | None) – Random seed for adding new dCRAB components.
Methods
__init__(measure_and_gradient_func, ...[, ...])optimize(times)Optimize via the Scipy optimizer gradient model.
set_options(opts)Set the options for the system.
set_parameters(values)Update the parameter values.
update_option(key, val)Update one option for the system.
Attributes
best_fidReturns the callback function.
Returns the current logger that is being used by this optimizer, or None if no logger was set yet.
Returns the currently selected optimization method.
Return the optimization map that this optimizer uses.
best_params- property logger: Logger | None#
Returns the current logger that is being used by this optimizer, or None if no logger was set yet.
- property optimization_map: OptimizationMap#
Return the optimization map that this optimizer uses.
Parameters that can be optimized need to be added to this map.
- Returns:
The optimization map that this optimizer uses.
- optimize(times)[source]#
Optimize via the Scipy optimizer gradient model.
Performs the actual optimization.
Note
If input
timesis a float, then the start time of propagation is implicitly assumed to be zero. For an array of times, the first time point is the start time.- Parameters:
times (Array | float) – Array of times or a float (assumed start time zero).
- Returns:
The result of the optimization.
- Return type:
- set_parameters(values)[source]#
Update the parameter values.
This method is derived from the
ScipyOptimizerGradientclass and designed to catch cases involving mismatch in dimension of parameters.Since, in dCRAB, new parameters are added in each super-iteration, the previous best result may be one with fewer parameters. In that case, all subsequent parameters are set to their minimum value (by setting the reduced value to -1).