qutip_qoc._grape module
This module provides an interface to the GRAPE optimization algorithm in qutip-qtrl. It defines the _GRAPE class, which uses a qutip_qtrl.optimizer.Optimizer object to store the control problem and calculate the fidelity error function and its gradient with respect to the control parameters, according to the CRAB algorithm.
- class qutip_qoc._grape._GRAPE(qtrl_optimizer)[source]
Bases:
objectClass to interface with the CRAB optimization algorithm in qutip-qtrl. It has an attribute qtrl that is a qutip_qtrl.optimizer.Optimizer object for storing the control problem and calculating the fidelity error function and its gradient wrt the control parameters, according to the GRAPE algorithm. The class does provide both infidelity and gradient methods.
- gradient(*args)[source]
This method is adapted from the original qutip_qtrl.optimizer.Optimizer.fid_err_grad_wrapper
Get the gradient of the fidelity error with respect to all of the variables, i.e. the ctrl amplidutes in each timeslot
This is called by generic optimisation algorithm as the gradients of func to the minimised wrt the variables. The argument is the current variable values, i.e. control amplitudes, passed as a flat array. Hence these are reshaped as [nTimeslots, n_ctrls] and then used to update the stored ctrl values (if they have changed)
- infidelity(*args)[source]
This method is adapted from the original qutip_qtrl.optimizer.Optimizer.fid_err_func_wrapper
Get the fidelity error achieved using the ctrl amplitudes passed in as the first argument.
This is called by generic optimisation algorithm as the func to the minimised. The argument is the current variable values, i.e. control amplitudes, passed as a flat array. Hence these are reshaped as [nTimeslots, n_ctrls] and then used to update the stored ctrl values (if they have changed)