You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example to demonstrate using the control library to determine control
22
22
pulses using the ctrlpulseoptim.optimize_pulse_unitary function.
23
23
The (default) L-BFGS-B algorithm is used to optimise the pulse to
24
-
minimise the fidelity error, which is equivalent maximising the fidelity
24
+
minimise the fidelity error, which is equivalent to maximising the fidelity
25
25
to an optimal value of 1.
26
26
27
27
The system in this example is a single qubit in a constant field in z
28
28
with a variable control field in x
29
-
The target evolution is the Hadamard gate irrespective of global phase
29
+
The target evolution is the Hadamard gate, irrespective of global phase
30
30
31
31
The user can experiment with the timeslicing, by means of changing the
32
32
number of timeslots and/or total time for the evolution.
33
33
Different initial (starting) pulse types can be tried.
34
34
The initial and final pulses are displayed in a plot
35
35
36
-
An indepth discussion of using methods of this type can be found in [1]
36
+
An in-depth discussion of using methods of this type can be found in [1]
37
37
38
38
```python
39
39
import datetime
@@ -82,10 +82,10 @@ n_ts = 10
82
82
evo_time =10
83
83
```
84
84
85
-
### Set the conditions which will cause the pulse optimisation to terminate
85
+
### Set the conditions that will cause the pulse optimisation to terminate
86
86
87
87
88
-
At each iteration the fidelity of the evolution is tested by comparaing the calculated evolution U(T) with the target U_targ. For unitary systems such as this one this is typically:
88
+
At each iteration, the fidelity of the evolution is tested by comparaing the calculated evolution U(T) with the target U_targ. For unitary systems such as this one this is typically:
89
89
f = normalise(overlap(U(T), U_targ))
90
90
For details of the normalisation see [1] or the source code.
91
91
The maximum fidelity (for a unitary system) calculated this way would be 1, and hence the error is calculated as fid_err = 1 - fidelity. As such the optimisation is considered completed when the fid_err falls below such a target value.
In this step the L-BFGS-B algorithm is invoked. At each iteration the gradient of the fidelity error w.r.t. each control amplitude in each timeslot is calculated using an exact gradient method (see [1]). Using the gradients the algorithm will determine a set of piecewise control amplitudes that reduce the fidelity error. With repeated iterations an approximation of the Hessian matrix (the 2nd order differentials) is calculated, which enables a quasi 2nd order Newton method for finding a minima. The algorithm continues until one of the termination conditions defined above has been reached.
129
+
In this step the L-BFGS-B algorithm is invoked. At each iteration the gradient of the fidelity error w.r.t. each control amplitude in each timeslot is calculated using an exact gradient method (see [1]). Using the gradients, the algorithm will determine a set of piecewise control amplitudes that reduce the fidelity error. With repeated iterations, an approximation of the Hessian matrix (the 2nd order differentials) is calculated, which enables a quasi 2nd order Newton method for finding a minima. The algorithm continues until one of the termination conditions defined above has been reached.
130
130
131
131
```python
132
132
result = cpo.optimize_pulse_unitary(
@@ -149,11 +149,11 @@ result = cpo.optimize_pulse_unitary(
149
149
### Report the results
150
150
151
151
152
-
Firstly the performace statistics are reported, which gives a breadown of the processing times. The times given are those that are associated with calculating the fidelity and the gradients. Any remaining processing time can be assumed to be used by the optimisation algorithm (L-BFGS-B) itself. In this example it can be seen that the majority of time is spent calculating the propagators, i.e. exponentiating the combined Hamiltonian.
152
+
Firstly the performace statistics are reported, which gives a breakdown of the processing times. The times given are those that are associated with calculating the fidelity and the gradients. Any remaining processing time can be assumed to be used by the optimisation algorithm (L-BFGS-B) itself. In this example, it can be seen that the majority of time is spent calculating the propagators, i.e., exponentiating the combined Hamiltonian.
153
153
154
154
The optimised U(T) is reported as the 'final evolution', which is essentially the string representation of the Qobj that holds the full time evolution at the point when the optimisation is terminated.
155
155
156
-
The key information is in the summary (given) last. Here the final fidelity is reported and the reasonn for termination of the algorithm.
156
+
The key information is in the summary (given) last. Here the final fidelity is reported and the reason for termination of the algorithm.
0 commit comments