qutip_qtrl.fidcomp
Fidelity Computer
These classes calculate the fidelity error - function to be minimised and fidelity error gradient, which is used to direct the optimisation
They may calculate the fidelity as an intermediary step, as in some case e.g. unitary dynamics, this is more efficient
The idea is that different methods for computing the fidelity can be tried and compared using simple configuration switches.
Note the methods in these classes were inspired by: DYNAMO - Dynamic Framework for Quantum Optimal Control See Machnes et.al., arXiv.1011.4874 The unitary dynamics fidelity is taken directly frm DYNAMO The other fidelity measures are extensions, and the sources are given in the class descriptions.
Classes
|
Computes fidelity error and gradient for general system dynamics by calculating the the fidelity error as the trace of the overlap of the difference between the target and evolution resulting from the pulses with the transpose of the same. |
|
As FidCompTraceDiff, except uses the finite difference method to compute approximate gradients |
|
Computes fidelity error and gradient assuming unitary dynamics, e.g. |
|
Base class for all Fidelity Computers. |
- class qutip_qtrl.fidcomp.FidCompTraceDiff(dynamics, params=None)[source]
Computes fidelity error and gradient for general system dynamics by calculating the the fidelity error as the trace of the overlap of the difference between the target and evolution resulting from the pulses with the transpose of the same. This should provide a distance measure for dynamics described by matrices Note the gradient calculation is taken from: ‘Robust quantum gates for open systems via optimal control: Markovian versus non-Markovian dynamics’ Frederik F Floether, Pierre de Fouquieres, and Sophie G Schirmer
- Attributes:
- scale_factorfloat
The fidelity error calculated is of some arbitary scale. This factor can be used to scale the fidelity error such that it may represent some physical measure If None is given then it is caculated as 1/2N, where N is the dimension of the drift, when the Dynamics are initialised.
- compute_fid_err_grad()[source]
Calculate exact gradient of the fidelity error function wrt to each timeslot control amplitudes. Uses the trace difference norm fidelity These are returned as a (nTimeslots x n_ctrls) array
- get_fid_err_gradient()[source]
Returns the normalised gradient of the fidelity error in a (nTimeslots x n_ctrls) array The gradients are cached in case they are requested mutliple times between control updates (although this is not typically found to happen)
- class qutip_qtrl.fidcomp.FidCompTraceDiffApprox(dynamics, params=None)[source]
As FidCompTraceDiff, except uses the finite difference method to compute approximate gradients
- Attributes:
- epsilonfloat
control amplitude offset to use when approximating the gradient wrt a timeslot control amplitude
- class qutip_qtrl.fidcomp.FidCompUnitary(dynamics, params=None)[source]
Computes fidelity error and gradient assuming unitary dynamics, e.g. closed qubit systems Note fidelity and gradient calculations were taken from DYNAMO (see file header)
- Attributes:
- phase_optionstring
- determines how global phase is treated in fidelity calculations:
PSU - global phase ignored SU - global phase included
- fidelity_prenormcomplex
Last computed value of the fidelity before it is normalised It is stored to use in the gradient normalisation calculation
- fidelity_prenorm_currentboolean
flag to specify whether fidelity_prenorm are based on the current amplitude values. Set False when amplitudes change
- compute_fid_grad()[source]
Calculates exact gradient of function wrt to each timeslot control amplitudes. Note these gradients are not normalised These are returned as a (nTimeslots x n_ctrls) array
- get_fid_err_gradient()[source]
Returns the normalised gradient of the fidelity error in a (nTimeslots x n_ctrls) array The gradients are cached in case they are requested mutliple times between control updates (although this is not typically found to happen)
- get_fidelity()[source]
Gets the appropriately normalised fidelity value The normalisation is determined by the fid_norm_func pointer which should be set in the config
- get_fidelity_prenorm()[source]
Gets the current fidelity value prior to normalisation Note the gradient function uses this value The value is cached, because it is used in the gradient calculation
- init_normalization()[source]
Calc norm of <Ufinal | Ufinal> to scale subsequent norms When considering unitary time evolution operators, this basically results in calculating the trace of the identity matrix and is hence equal to the size of the target matrix There may be situations where this is not the case, and hence it is not assumed to be so. The normalisation function called should be set to either the PSU - global phase ignored SU - global phase respected
- normalize_gradient_PSU(grad)[source]
Normalise the gradient matrix passed as grad This PSU version is independent of global phase
- class qutip_qtrl.fidcomp.FidelityComputer(dynamics, params=None)[source]
Base class for all Fidelity Computers. This cannot be used directly. See subclass descriptions and choose one appropriate for the application Note: this must be instantiated with a Dynamics object, that is the container for the data that the methods operate on
- Attributes:
- log_levelinteger
level of messaging output from the logger. Options are attributes of qutip_qtrl.logging_utils, in decreasing levels of messaging, are: DEBUG_INTENSE, DEBUG_VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL Anything WARN or above is effectively ‘quiet’ execution, assuming everything runs as expected. The default NOTSET implies that the level will be taken from the QuTiP settings file, which by default is WARN
- dimensional_normfloat
Normalisation constant
- fid_norm_funcfunction
Used to normalise the fidelity See SU and PSU options for the unitary dynamics
- grad_norm_funcfunction
Used to normalise the fidelity gradient See SU and PSU options for the unitary dynamics
- uses_onwd_evoboolean
flag to specify whether the onwd_evo evolution operator (see Dynamics) is used by the FidelityComputer
- uses_onto_evoboolean
- flag to specify whether the onto_evo evolution operator
(see Dynamics) is used by the FidelityComputer
- fid_errfloat
Last computed value of the fidelity error
- fidelityfloat
Last computed value of the normalised fidelity
- fidelity_currentboolean
flag to specify whether the fidelity / fid_err are based on the current amplitude values. Set False when amplitudes change
- fid_err_grad: array[num_tslot, num_ctrls] of float
Last computed values for the fidelity error gradients wrt the control in the timeslot
- grad_normfloat
Last computed value for the norm of the fidelity error gradients (sqrt of the sum of the squares)
- fid_err_grad_currentboolean
flag to specify whether the fidelity / fid_err are based on the current amplitude values. Set False when amplitudes change
- apply_params(params=None)[source]
Set object attributes based on the dictionary (if any) passed in the instantiation, or passed as a parameter This is called during the instantiation automatically. The key value pairs are the attribute name and value Note: attributes are created if they do not exist already, and are overwritten if they do.