paraqeet.optimizers.dcrab_optimizer_gradient.DCRABOptimizerGradient#

class paraqeet.optimizers.dcrab_optimizer_gradient.DCRABOptimizerGradient(measure, 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)#

Bases: ScipyOptimizerGradient

A dCRAB optimization method.

Implements dCRAB optimization involving super-iterations that adds additional optimization components to the dCRAB envelope and freezes the older parameters.

Note - This works with a `DCRABEnvelope` or a `list[DCRABEnvelope]` as envelopes.

_num_iteration: int

Current iteration number.

_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.

_num_print_every: int

Print every this many iterations the current optimization value. Defaults to 5.

_old_parameters_dictdict[int, list[Quantity]]

Store the parameters of the previous super-iteration in a dictionary labelled by the number of parameters.

Parameters:
  • measure (NormalizableMeasurement) – Measurement class that measures the observable to be maximised.

  • optimization_map (OptimizationMap) – An optimization map containing all parameters that can be optimized.

  • super_iteration_every (int)

  • max_super_iteration_num (int)

  • print_every_iteration_num (int)

  • fallback_optimization (Optimizer | None)

  • super_iteration_tol (float)

  • seed (int | None)

__init__(measure, 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)#
Parameters:
  • measure (NormalizableMeasurement)

  • optimization_map (OptimizationMap)

  • super_iteration_every (int)

  • max_super_iteration_num (int)

  • print_every_iteration_num (int)

  • fallback_optimization (Optimizer | None)

  • super_iteration_tol (float)

  • seed (int | None)

Methods

__init__(measure, optimization_map[, ...])

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)

Updates one option for the system.

Attributes

best_fid

callback

Returns the callback function.

logger

Returns the current logger that is being used by this optimizer, or None if no logger was set yet.

method

Returns the currently selected optimization method.

optimization_map

Return the optimization map that this optimizer uses.

best_params

property callback: Callable | None#

Returns the callback function.

property logger: Logger | None#

Returns the current logger that is being used by this optimizer, or None if no logger was set yet.

property method: str#

Returns the currently selected optimization method.

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:

Returns the optimization map that this optimizer uses.

Return type:

paraqeet.optimization_map

optimize(times)#

Optimize via the Scipy optimizer gradient model.

Performs the actual optimization.

Note - If input `times` is 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.

Returns:

The result of the optimization.

Return type:

OptimizationResult

Parameters:

times (Array | float)

set_options(opts)#

Set the options for the system.

Parameters:

opts (dict)

set_parameters(values)#

Update the parameter values.

This method is derived from the ScipyoptimizerGradient class 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).

Parameters:

values (Array) – Parameter values for the update.

Returns:

Returns the inverse of the fidelity.

Return type:

Array

update_option(key, val)#

Updates one option for the system.