qutip_qoc.objective module
This module contains the Objective class for storing information about an optimization objective, and the _MultiObjective class for optimizing multiple objectives simultaneously.
- class qutip_qoc.objective.Objective(initial, H, target, weight=1)[source]
Bases:
objectA class for storing information about an optimization objective.
Examples
To specify an objective for GOAT, provide a gradient function:
initial = qt.basis(2, 0) target = qt.basis(2, 1) sin = lambda t, p: np.sin(p * t) def d_sin(t, p, idx): if idx==0: return t * np.cos(t) # w.r.t. p if idx==1: return p * np.cos(t) # w.r.t. t H = [qt.sigmax(), [qt.sigmay(), sin, {'grad': d_sin}]] obj = Objective(initial, H, target)
To specify an objective for JOPT, no need for gradient function:
initial = qt.basis(2, 0) target = qt.basis(2, 1) @jax.jit def sin(t, p) return jax.numpy.sin(p * t) def d_sin(t, p, idx): if idx==0: return t * np.cos(t) # w.r.t. p if idx==1: return p * np.cos(t) # w.r.t. t H = [qt.sigmax(), [qt.sigmay(), sin]] obj = Objective(initial, H, target)
- Attributes:
- initial
qutip.Qobj The initial state or operator to be transformed.
- Hcallable, list
A specification of the time-depedent quantum object. Usually a list with drift Hamiltonian at zero-index followed by the control Hamiltonians. See
qutip.QobjEvofor details and examples.- target
qutip.Qobj The target state or operator.
- weightfloat
Only used in multi-objective scenarios. The weight of this objective in the optimization. All weights are normalized to sum to 1.
- initial