Classes
This part is the classes of the Python-Julia package which written in Python.
Dynamics¶
Class for simulating quantum dynamics governed by the Lindblad master equation.
The dynamics of a density matrix is described by the Lindblad master equation:
Symbols
- \(\rho\): the evolved density matrix
- \(H\): the Hamiltonian of the system
- \(\Gamma_i\): the \(i\)th decay operator
- \(\gamma_i\): the \(i\)th decay rate
Attributes:
| Name | Type | Description |
|---|---|---|
tspan |
array
|
Time points for the evolution. |
rho0 |
array
|
Initial state (density matrix). |
H0 |
array / list
|
Free Hamiltonian. It is a matrix when time-independent, or a list of matrices
(with length equal to |
dH |
list
|
Derivatives of the free Hamiltonian with respect to the unknown parameters. |
decay |
list
|
Decay operators and corresponding decay rates. Input format: |
Hc |
list
|
Control Hamiltonians. |
ctrl |
list
|
Control coefficients for each control Hamiltonian. |
Source code in quanestimation/base/Parameterization/GeneralDynamics.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
__init__(tspan, rho0, H0, dH, decay=None, Hc=None, ctrl=None)
¶
Initialize Lindblad dynamics.
Parameters¶
tspan : np.array
Time points for the evolution.
rho0 : np.array
Initial state (density matrix).
H0 : np.array or list
Free Hamiltonian. A matrix when time-independent, or a list of matrices
when time-dependent.
dH : list
Derivatives of the free Hamiltonian with respect to parameters.
decay : list, optional
Decay operators and rates as [[Gamma_1, gamma_1], [Gamma_2, gamma_2], ...].
Hc : list, optional
Control Hamiltonians.
ctrl : list, optional
Control coefficients for each control Hamiltonian.
Source code in quanestimation/base/Parameterization/GeneralDynamics.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
expm()
¶
Calculate the density matrix and its derivatives using the matrix exponential method.
The density matrix at the \(j\)th time interval is obtained by:
where \(\Delta t\) is the time interval and \(\rho_{j-1}\) is the density matrix at the previous time step.
The derivative \(\partial_{\textbf{x}}\rho_j\) is calculated as:
Returns:
| Type | Description |
|---|---|
tuple
|
rho (list):
Density matrices at each time point in drho (list):
Derivatives of the density matrices with respect to the unknown parameters. |
Source code in quanestimation/base/Parameterization/GeneralDynamics.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
ode()
¶
Calculate the density matrix and its derivatives using an ODE solver.
The density matrix at the \(j\)th time interval is obtained by:
where \(\Delta t\) is the time interval and \(\rho_{j-1}\) is the density matrix at the previous time step.
The derivative \(\partial_{\textbf{x}}\rho_j\) is calculated as:
Returns:
| Type | Description |
|---|---|
tuple
|
rho (list):
Density matrices at each time point in drho (list):
Derivatives of the density matrices with respect to the unknown parameters. |
Source code in quanestimation/base/Parameterization/GeneralDynamics.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
secondorder_derivative(d2H)
¶
Calculate the density matrix, its first derivatives, and second derivatives with respect to the unknown parameters.
The density matrix at the \(j\)th time interval is obtained by:
The first derivative \(\partial_{\textbf{x}}\rho_j\) is calculated as:
The second derivative \(\partial_{\textbf{x}}^2\rho_j\) is calculated as:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d2H |
list
|
Second-order derivatives of the free Hamiltonian with respect to the unknown parameters. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
rho (list):
Density matrices at each time point in drho (list): First derivatives of the density matrices with respect to the unknown parameters. d2rho (list): Second derivatives of the density matrices with respect to the unknown parameters. |
Source code in quanestimation/base/Parameterization/GeneralDynamics.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
Parameterization of a quantum state using Kraus operators.
The evolved density matrix \(\rho\) is given by
where \(\rho_0\) is the initial density matrix and \(K_i\) are the Kraus operators.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho0 |
array
|
Initial density matrix. |
required |
K |
list
|
Kraus operators. |
required |
dK |
list
|
Derivatives of the Kraus operators with respect to the unknown parameters to be
estimated. This is a nested list where the first index corresponds to the Kraus operator
and the second index corresponds to the parameter. For example, |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
rho (np.array): Evolved density matrix. drho (list):
Derivatives of the evolved density matrix with respect to the unknown parameters. |
Source code in quanestimation/base/Parameterization/NonDynamics.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
Construct Lindblad dynamics for a single qubit under dephasing.
Hamiltonian H = rx·σx + ry·σy + rz·σz, with dephasing
channel Γ = σz at rate γ. Delegates to Julia's
QubitDephasing(r, para_est, gamma, tspan).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
r |
Bloch vector components [rx, ry, rz]. |
required | |
para_est |
Parameter to estimate, |
required | |
gamma |
Dephasing rate. |
required | |
tspan |
Time span for evolution. |
required |
Returns:
| Type | Description |
|---|---|
|
Lindblad dynamics object (Julia Lindblad). |
Source code in quanestimation/base/Parameterization/GeneralDynamics.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
Control Waveforms¶
Predefined control coefficient functions for constructing controlled Hamiltonians.
Each returns a callable object that evaluates the waveform at time t.
Zero control: c(t) = 0.
Source code in quanestimation/base/Parameterization/ControlWaveform.py
24 25 26 | |
Linear-in-time control: c(t) = k·t + c0.
Source code in quanestimation/base/Parameterization/ControlWaveform.py
29 30 31 | |
Sinusoidal control: c(t) = A·sin(ω·t + φ).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A |
Amplitude. |
1.0
|
|
omega |
Angular frequency ω. |
1.0
|
|
phi |
Phase offset φ. |
0.0
|
Source code in quanestimation/base/Parameterization/ControlWaveform.py
34 35 36 37 38 39 40 41 42 | |
Sawtooth-wave control.
Source code in quanestimation/base/Parameterization/ControlWaveform.py
45 46 47 | |
Triangle-wave control.
Source code in quanestimation/base/Parameterization/ControlWaveform.py
50 51 52 | |
Gaussian-pulse control: c(t) = A·exp(-(t-μ)²/(2σ)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A |
Amplitude. |
1.0
|
|
mu |
Center μ. |
0.0
|
|
sigma |
Width σ (variance). |
1.0
|
Source code in quanestimation/base/Parameterization/ControlWaveform.py
55 56 57 58 59 60 61 62 63 | |
Gaussian-edge control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A |
Amplitude. |
1.0
|
|
sigma |
Width σ. |
1.0
|
Source code in quanestimation/base/Parameterization/ControlWaveform.py
66 67 68 69 70 71 72 73 | |
NV Magnetometer¶
NV-center magnetometer estimation scheme.
Provides a high-level interface for constructing NV-center estimation schemes and evaluating quantum/classical Fisher information, Holevo Cramer-Rao bound, control optimization, error evaluation, and error control.
All defaults match Julia's NVMagnetometerScheme(; ...)
constructor exactly (NVMagnetometer.jl:107-143).
Parameters¶
D : float
Zero-field splitting in MHz. Default 2π·2870.
gS : float
Electron gyromagnetic ratio in MHz/mT. Default 2π·28.03.
gI : float
Nuclear gyromagnetic ratio in MHz/mT. Default 2π·4.32·10⁻³.
A1 : float
Transverse hyperfine coupling in MHz. Default 2π·3.65.
A2 : float
Longitudinal hyperfine coupling in MHz. Default 2π·3.03.
B1 : float
Magnetic field B_x in mT. Default 0.5.
B2 : float
Magnetic field B_y in mT. Default 0.5.
B3 : float
Magnetic field B_z in mT. Default 0.5.
gamma : float
Dephasing rate in MHz. Default 2π.
decay_opt : list, optional
Decay operators. Default [S₃] (Julia-computed).
init_state : np.ndarray, optional
Initial state vector. Default (|+1⟩+|−1⟩)/√2.
Hc : list, optional
Control Hamiltonians. Default [S₁,S₂,S₃] (Julia-computed).
ctrl : list or None, optional
Control coefficient sequences. Default None (zeros).
tspan : np.ndarray, optional
Time span. Default 0:0.01:2.0.
M : list or None, optional
POVM measurement. Default None (SIC-POVM).
Source code in quanestimation/nv/scheme.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
CFIM(**kwargs)
¶
Classical Fisher information matrix.
Delegates to CFIM(nv::NVMagnetometerScheme)
(NVMagnetometer.jl:292).
Source code in quanestimation/nv/scheme.py
115 116 117 118 119 120 121 | |
HCRB(**kwargs)
¶
Holevo Cramer-Rao bound.
Delegates to HCRB(nv::NVMagnetometerScheme)
(NVMagnetometer.jl:300).
Source code in quanestimation/nv/scheme.py
123 124 125 126 127 128 129 | |
QFIM(**kwargs)
¶
Quantum Fisher information matrix.
Delegates to QFIM(nv::NVMagnetometerScheme)
(NVMagnetometer.jl:284).
Source code in quanestimation/nv/scheme.py
107 108 109 110 111 112 113 | |
error_control(**kwargs)
¶
Error control analysis.
Delegates to error_control(nv)
(NVMagnetometer.jl:334).
Source code in quanestimation/nv/scheme.py
187 188 189 190 191 192 193 | |
error_evaluation(**kwargs)
¶
Evaluate estimation error.
Delegates to error_evaluation(nv)
(NVMagnetometer.jl:325).
Source code in quanestimation/nv/scheme.py
179 180 181 182 183 184 185 | |
optimize(opt, algorithm=None, objective=None, savefile=False)
¶
Run control optimization.
Converts the Python ControlOpt instance to a Julia
ControlOpt struct before delegating to optimize!.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opt |
|
required | |
algorithm |
Julia algorithm struct (default |
None
|
|
objective |
Julia objective (default |
None
|
|
savefile |
Whether to save results to file. |
False
|
Source code in quanestimation/nv/scheme.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
Control Optimization¶
The Hamiltonian of a controlled system can be written as \begin{align} H = H_0(\textbf{x})+\sum_{k=1}^K u_k(t) H_k, \end{align}
where \(H_0(\textbf{x})\) is the free evolution Hamiltonian with unknown parameters
\(\textbf{x}\) and \(H_k\) represents the \(k\)th control Hamiltonian with \(u_k\) the
corresponding control coefficient. In QuanEstimation, different algorithms are invoked to
update the optimal control coefficients. The control optimization algorithms are
gradient ascent pulse engineering (GRAPE), GRAPE algorithm based on the automatic
differentiation (auto-GRAPE), particle swarm optimization (PSO),
differential evolution (DE) and deep deterministic policy gradients (DDPG).
Base¶
Attributes¶
savefile:
bool-- Whether or not to save all the control coeffients.
If setTruethen the control coefficients and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe control coefficients in the final episode and the values of the objective function in all episodes will be saved.ctrl0:
list of arrays-- Initial guesses of control coefficients.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load control coefficients in the current location.
If setTruethen the program will load control coefficients from "controls.csv" file in the current location and use it as the initial control coefficients.
Source code in quanestimation/base/ControlOpt/ControlStruct.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
CFIM(M=None, W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.M:
list-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ControlOpt/ControlStruct.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
HCRB(W=None)
¶
Choose HCRB as the objective function.
Notes: (1) In single parameter estimation, HCRB is equivalent to QFI, please choose QFI as the objective function. (2) GRAPE and auto-GRAPE are not available when the objective function is HCRB. Supported methods are PSO, DE and DDPG.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ControlOpt/ControlStruct.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
QFIM(W=None, LDtype='SLD')
¶
Choose QFI or \(\mathrm{Tr}(WF^{-1})\) as the objective function. In single parameter estimation the objective function is QFI and in multiparameter estimation it will be \(\mathrm{Tr}(WF^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Source code in quanestimation/base/ControlOpt/ControlStruct.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
__init__(savefile, ctrl0, seed, eps, load)
¶
Initialize the control optimization system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all control coefficients during
training. If |
required |
ctrl0 |
list of arrays
|
Initial guesses of control coefficients. |
required |
seed |
int
|
Random seed. |
required |
eps |
float
|
Machine epsilon. |
required |
load |
bool
|
Whether to load control coefficients from
|
required |
Source code in quanestimation/base/ControlOpt/ControlStruct.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
dynamics(tspan, rho0, H0, dH, Hc, decay=None, ctrl_bound=None, dyn_method='expm')
¶
The dynamics of a density matrix is of the form
where \(\rho\) is the evolved density matrix, H is the Hamiltonian of the system, \(\Gamma_i\) and \(\gamma_i\) are the \(i\mathrm{th}\) decay operator and corresponding decay rate.
Parameters¶
tspan:
array-- Time length for the evolution.rho0:
matrix-- Initial state (density matrix).H0:
matrix or list-- Free Hamiltonian. It is a matrix when the free Hamiltonian is time- independent and a list of length equal totspanwhen it is time-dependent.dH:
list-- Derivatives of the free Hamiltonian on the unknown parameters to be estimated. For example, dH[0] is the derivative vector on the first parameter.Hc:
list-- Control Hamiltonians.decay:
list-- Decay operators and the corresponding decay rates. Its input rule is decay=[[\(\Gamma_1\), \(\gamma_1\)], [\(\Gamma_2\),\(\gamma_2\)],...], where \(\Gamma_1\) \((\Gamma_2)\) represents the decay operator and \(\gamma_1\) \((\gamma_2)\) is the corresponding decay rate.ctrl_bound:
array-- Lower and upper bounds of the control coefficients.ctrl_bound[0]represents the lower bound of the control coefficients andctrl_bound[1]represents the upper bound of the control coefficients.dyn_method:
string-- Setting the method for solving the Lindblad dynamics. Options are:
"expm" (default) -- Matrix exponential.
"ode" -- Solving the differential equations directly.
Source code in quanestimation/base/ControlOpt/ControlStruct.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
load_save(cnum, max_episode)
¶
Load control coefficients saved by the Julia backend from controls.dat
and save them as a controls.npy file.
The Julia backend writes controls.dat atomically (temp → rename),
and the file is deleted after a successful read to avoid stale data
from interfering with subsequent runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cnum |
int
|
Number of control Hamiltonian channels. |
required |
max_episode |
int
|
Maximum number of episodes. |
required |
Source code in quanestimation/base/ControlOpt/ControlStruct.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
mintime(f, W=None, M=None, method='binary', target='QFIM', LDtype='SLD')
¶
Search of the minimum time to reach a given value of the objective function.
Parameters¶
f:
float-- The given value of the objective function.W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).method:
string-- Methods for searching the minimum time to reach the given value of the objective function. Options are:
"binary" (default) -- Binary search (logarithmic search).
"forward" -- Forward search from the beginning of time.target:
string-- Objective functions for searching the minimum time to reach the given value of the objective function. Options are:
"QFIM" (default) -- Choose QFI (QFIM) as the objective function.
"CFIM" -- Choose CFI (CFIM) as the objective function.
"HCRB" -- Choose HCRB as the objective function.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Source code in quanestimation/base/ControlOpt/ControlStruct.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
Control optimization with GRAPE and auto-GRAPE¶
Bases: ControlSystem
Attributes¶
savefile:
bool-- Whether or not to save all the control coeffients.
If setTruethen the control coefficients and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe control coefficients in the final episode and the values of the objective function in all episodes will be saved.Adam:
bool-- Whether or not to use Adam for updating control coefficients.ctrl0:
list of arrays-- Initial guesses of control coefficients.max_episode:
int-- The number of episodes.epsilon:
float-- Learning rate.beta1:
float-- The exponential decay rate for the first moment estimates.beta2:
float-- The exponential decay rate for the second moment estimates.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load control coefficients in the current location.
If setTruethen the program will load control coefficients from "controls.csv" file in the current location and use it as the initial control coefficients.auto:
bool-- Whether or not to invoke automatic differentiation algorithm to evaluate
the gradient. If setTruethen the gradient will be calculated with automatic differentiation algorithm otherwise it will be calculated using analytical method.
Source code in quanestimation/base/ControlOpt/GRAPE_Copt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
CFIM(M=None, W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ControlOpt/GRAPE_Copt.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
HCRB(W=None)
¶
GRAPE and auto-GRAPE are not available when the objective function is HCRB. Supported methods are PSO, DE and DDPG.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ControlOpt/GRAPE_Copt.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
QFIM(W=None, LDtype='SLD')
¶
Choose QFI or \(\mathrm{Tr}(WF^{-1})\) as the objective function. In single parameter estimation the objective function is QFI and in multiparameter estimation it will be \(\mathrm{Tr}(WF^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Source code in quanestimation/base/ControlOpt/GRAPE_Copt.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
__init__(savefile=False, Adam=True, ctrl0=[], max_episode=300, epsilon=0.01, beta1=0.9, beta2=0.99, eps=1e-08, seed=1234, load=False, auto=True)
¶
Initialize GRAPE (GRadient Ascent Pulse Engineering) control optimization.
Supports both standard GRAPE and automatic-differentiation GRAPE (auto-GRAPE) with optional Adam optimizer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all control coefficients during
training. Default |
False
|
Adam |
bool
|
Whether to use the Adam optimizer. Default |
True
|
ctrl0 |
list of arrays
|
Initial guesses of control coefficients.
Default |
[]
|
max_episode |
int
|
Number of training episodes. Default 300. |
300
|
epsilon |
float
|
Learning rate. Default 0.01. |
0.01
|
beta1 |
float
|
Exponential decay rate for first moment estimates (Adam). Default 0.90. |
0.9
|
beta2 |
float
|
Exponential decay rate for second moment estimates (Adam). Default 0.99. |
0.99
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
seed |
int
|
Random seed. Default 1234. |
1234
|
load |
bool
|
Whether to load initial control coefficients
from |
False
|
auto |
bool
|
Whether to use automatic differentiation.
Default |
True
|
Source code in quanestimation/base/ControlOpt/GRAPE_Copt.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
mintime(f, W=None, M=None, method='binary', target='QFIM', LDtype='SLD')
¶
Search of the minimum time to reach a given value of the objective function.
Parameters¶
f:
float-- The given value of the objective function.W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).method:
string-- Methods for searching the minimum time to reach the given value of the objective function. Options are:
"binary" (default) -- Binary search (logarithmic search).
"forward" -- Forward search from the beginning of time.target:
string-- Objective functions for searching the minimum time to reach the given value of the objective function. Options are:
"QFIM" (default) -- Choose QFI (QFIM) as the objective function.
"CFIM" -- Choose CFI (CFIM) as the objective function.
"HCRB" -- Choose HCRB as the objective function.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ControlOpt/GRAPE_Copt.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
Control Optimization with PSO¶
Bases: ControlSystem
Attributes¶
savefile:
bool-- Whether or not to save all the control coeffients.
If setTruethen the control coefficients and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe control coefficients in the final episode and the values of the objective function in all episodes will be saved.p_num:
int-- The number of particles.ctrl0:
list of arrays-- Initial guesses of control coefficients.max_episode:
int or list-- If it is an integer, for example max_episode=1000, it means the program will continuously run 1000 episodes. However, if it is an array, for example max_episode=[1000,100], the program will run 1000 episodes in total but replace control coefficients of all the particles with global best every 100 episodes.c0:
float-- The damping factor that assists convergence, also known as inertia weight.c1:
float-- The exploitation weight that attracts the particle to its best previous position, also known as cognitive learning factor.c2:
float-- The exploitation weight that attracts the particle to the best position
in the neighborhood, also known as social learning factor.seed:
int-- Random seed.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load control coefficients in the current location.
If setTruethen the program will load control coefficients from "controls.csv" file in the current location and use it as the initial control coefficients.
Source code in quanestimation/base/ControlOpt/PSO_Copt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
CFIM(M=None, W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ControlOpt/PSO_Copt.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
HCRB(W=None)
¶
Choose HCRB as the objective function.
Note: in single parameter estimation, HCRB is equivalent to QFI, please choose QFI as the objective function.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ControlOpt/PSO_Copt.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
QFIM(W=None, LDtype='SLD')
¶
Choose QFI or \(\mathrm{Tr}(WF^{-1})\) as the objective function. In single parameter estimation the objective function is QFI and in multiparameter estimation it will be \(\mathrm{Tr}(WF^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Source code in quanestimation/base/ControlOpt/PSO_Copt.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
__init__(savefile=False, p_num=10, ctrl0=[], max_episode=[1000, 100], c0=1.0, c1=2.0, c2=2.0, seed=1234, eps=1e-08, load=False)
¶
Initialize particle swarm optimization for control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all control coefficients
during training. Default |
False
|
p_num |
int
|
Number of particles. Default 10. |
10
|
ctrl0 |
list of arrays
|
Initial guesses of control
coefficients. Default |
[]
|
max_episode |
int or list
|
Number of episodes. If a list
|
[1000, 100]
|
c0 |
float
|
Inertia weight (damping factor). Default 1.0. |
1.0
|
c1 |
float
|
Cognitive learning factor. Default 2.0. |
2.0
|
c2 |
float
|
Social learning factor. Default 2.0. |
2.0
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
load |
bool
|
Whether to load initial control coefficients
from |
False
|
Source code in quanestimation/base/ControlOpt/PSO_Copt.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
mintime(f, W=None, M=None, method='binary', target='QFIM', LDtype='SLD')
¶
Search of the minimum time to reach a given value of the objective function.
Parameters¶
f:
float-- The given value of the objective function.W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).method:
string-- Methods for searching the minimum time to reach the given value of the objective function. Options are:
"binary" (default) -- Binary search (logarithmic search).
"forward" -- Forward search from the beginning of time.target:
string-- Objective functions for searching the minimum time to reach the given value of the objective function. Options are:
"QFIM" (default) -- Choose QFI (QFIM) as the objective function.
"CFIM" -- Choose CFI (CFIM) as the objective function.
"HCRB" -- Choose HCRB as the objective function.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ControlOpt/PSO_Copt.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
Control Optimization DE¶
Bases: ControlSystem
Attributes¶
savefile:
bool--Whether or not to save all the control coeffients.
If setTruethen the control coefficients and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe control coefficients in the final episode and the values of the objective function in all episodes will be saved.p_num:
int-- The number of populations.ctrl0: list of arrays -- Initial guesses of control coefficients.
max_episode:
int-- The number of episodes.c:
float-- Mutation constant.cr:
float-- Crossover constant.seed:
int-- Random seed.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load control coefficients in the current location.
If setTruethen the program will load control coefficients from "controls.csv" file in the current location and use it as the initial control coefficients.
Source code in quanestimation/base/ControlOpt/DE_Copt.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
CFIM(M=None, W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ControlOpt/DE_Copt.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
HCRB(W=None)
¶
Choose HCRB as the objective function.
Note: in single parameter estimation, HCRB is equivalent to QFI, please choose QFI as the objective function.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ControlOpt/DE_Copt.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
QFIM(W=None, LDtype='SLD')
¶
Choose QFI or \(\mathrm{Tr}(WF^{-1})\) as the objective function. In single parameter estimation the objective function is QFI and in multiparameter estimation it will be \(\mathrm{Tr}(WF^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Source code in quanestimation/base/ControlOpt/DE_Copt.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
__init__(savefile=False, p_num=10, ctrl0=[], max_episode=1000, c=1.0, cr=0.5, seed=1234, eps=1e-08, load=False)
¶
Initialize differential evolution (DE) for control optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all control coefficients
during training. Default |
False
|
p_num |
int
|
Number of populations. Default 10. |
10
|
ctrl0 |
list of arrays
|
Initial guesses of control
coefficients. Default |
[]
|
max_episode |
int
|
Number of episodes. Default 1000. |
1000
|
c |
float
|
Mutation constant. Default 1.0. |
1.0
|
cr |
float
|
Crossover constant. Default 0.5. |
0.5
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
load |
bool
|
Whether to load initial control coefficients
from |
False
|
Source code in quanestimation/base/ControlOpt/DE_Copt.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
mintime(f, W=None, M=None, method='binary', target='QFIM', LDtype='SLD')
¶
Search of the minimum time to reach a given value of the objective function.
Parameters¶
f:
float-- The given value of the objective function.W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).method:
string-- Methods for searching the minimum time to reach the given value of the objective function. Options are:
"binary" (default) -- Binary search (logarithmic search).
"forward" -- Forward search from the beginning of time.target:
string-- Objective functions for searching the minimum time to reach the given value of the objective function. Options are:
"QFIM" (default) -- Choose QFI (QFIM) as the objective function.
"CFIM" -- Choose CFI (CFIM) as the objective function.
"HCRB" -- Choose HCRB as the objective function.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ControlOpt/DE_Copt.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
State Optimization¶
The probe state is expanded as \(|\psi\rangle=\sum_i c_i|i\rangle\) in a specific basis, i.e., \(\{|i\rangle\}\). In state optimization, the search of the optimal probe states is equal to search of the normalized complex coefficients \(\{c_i\}\). In QuanEstimation, the state optimization algorithms are automatic differentiation (AD), reverse iterative (RI) algorithm, particle swarm optimization (PSO), differential evolution (DE), deep deterministic policy gradients (DDPG) and Nelder-Mead (NM).
Base¶
Attributes¶
savefile:
bool-- Whether or not to save all the states. If setTruethen the states and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe state in the final episode and the values of the objective function in all episodes will be saved.psi0:
list of arrays-- Initial guesses of states.seed:
int-- Random seed.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load states in the current location. If setTruethen the program will load state from "states.csv" file in the current location and use it as the initial state.
Source code in quanestimation/base/StateOpt/StateStruct.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
CFIM(M=None, W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/StateOpt/StateStruct.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
HCRB(W=None)
¶
Choose HCRB as the objective function.
Notes: (1) In single parameter estimation, HCRB is equivalent to QFI, please
choose QFI as the objective function. (2) GRAPE and auto-GRAPE are not available
when the objective function is HCRB. Supported methods are PSO, DE and DDPG.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/StateOpt/StateStruct.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
Kraus(K, dK)
¶
The parameterization of a state is \begin{align} \rho=\sum_i K_i\rho_0K_i^{\dagger}, \end{align}
where \(\rho\) is the evolved density matrix, \(K_i\) is the Kraus operator.
Parameters¶
K:
list-- Kraus operators.dK:
list-- Derivatives of the Kraus operators on the unknown parameters to be estimated. For example, dK[0] is the derivative vector on the first parameter.
Source code in quanestimation/base/StateOpt/StateStruct.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |
QFIM(W=None, LDtype='SLD')
¶
Choose QFI or \(\mathrm{Tr}(WF^{-1})\) as the objective function. In single parameter estimation the objective function is QFI and in multiparameter estimation it will be \(\mathrm{Tr}(WF^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are: "SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD). "RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD). "LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Source code in quanestimation/base/StateOpt/StateStruct.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
__init__(savefile, psi0, seed, eps, load)
¶
Initialize the state optimization system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all states during training.
If |
required |
psi0 |
list of arrays
|
Initial guesses of probe states. |
required |
seed |
int
|
Random seed. |
required |
eps |
float
|
Machine epsilon. |
required |
load |
bool
|
Whether to load states from |
required |
Source code in quanestimation/base/StateOpt/StateStruct.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
dynamics(tspan, H0, dH, Hc=None, ctrl=None, decay=None, dyn_method='expm')
¶
The dynamics of a density matrix is of the form
where \(\rho\) is the evolved density matrix, H is the Hamiltonian of the system, \(\Gamma_i\) and \(\gamma_i\) are the \(i\mathrm{th}\) decay operator and corresponding decay rate.
Parameters¶
tspan:
array-- Time length for the evolution.H0:
matrix or list-- Free Hamiltonian. It is a matrix when the free Hamiltonian is time- independent and a list of length equal totspanwhen it is time-dependent.dH:
list-- Derivatives of the free Hamiltonian on the unknown parameters to be estimated. For example, dH[0] is the derivative vector on the first parameter.Hc:
list-- Control Hamiltonians.ctrl:
list of arrays-- Control coefficients.decay:
list-- Decay operators and the corresponding decay rates. Its input rule is decay=[[\(\Gamma_1\), \(\gamma_1\)], [\(\Gamma_2\),\(\gamma_2\)],...], where \(\Gamma_1\) \((\Gamma_2)\) represents the decay operator and \(\gamma_1\) \((\gamma_2)\) is the corresponding decay rate.dyn_method:
string-- Setting the method for solving the Lindblad dynamics. Options are:
"expm" (default) -- Matrix exponential.
"ode" -- Solving the differential equations directly.
Source code in quanestimation/base/StateOpt/StateStruct.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
load_save(max_episode)
¶
Load optimized states saved by the Julia backend from states.dat
and save them as a states.npy file.
The Julia backend writes states.dat atomically (temp → rename),
and the file is deleted after a successful read to avoid stale data
from interfering with subsequent runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_episode |
int
|
Maximum number of episodes. |
required |
Source code in quanestimation/base/StateOpt/StateStruct.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
State optimization with AD¶
Bases: StateSystem
Attributes¶
savefile:
bool-- Whether or not to save all the states.
If setTruethen the states and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe state in the final episode and the values of the objective function in all episodes will be saved.Adam:
bool-- Whether or not to use Adam for updating states.psi0:
list of arrays-- Initial guesses of states.max_episode:
int-- The number of episodes.epsilon:
float-- Learning rate.beta1:
float-- The exponential decay rate for the first moment estimates.beta2:
float-- The exponential decay rate for the second moment estimates.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load states in the current location.
If setTruethen the program will load state from "states.csv" file in the current location and use it as the initial state.
Source code in quanestimation/base/StateOpt/AD_Sopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
CFIM(M=None, W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/StateOpt/AD_Sopt.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
HCRB(W=None)
¶
AD is not available when the objective function is HCRB. Supported methods are PSO, DE, DDPG and NM.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/StateOpt/AD_Sopt.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
QFIM(W=None, LDtype='SLD')
¶
Choose QFI or \(\mathrm{Tr}(WF^{-1})\) as the objective function. In single parameter estimation the objective function is QFI and in multiparameter estimation it will be \(\mathrm{Tr}(WF^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Source code in quanestimation/base/StateOpt/AD_Sopt.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
__init__(savefile=False, Adam=False, psi0=[], max_episode=300, epsilon=0.01, beta1=0.9, beta2=0.99, seed=1234, eps=1e-08, load=False)
¶
Initialize automatic differentiation (AD) for state optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all states during
training. Default |
False
|
Adam |
bool
|
Whether to use the Adam optimizer.
Default |
False
|
psi0 |
list of arrays
|
Initial guesses of probe states.
Default |
[]
|
max_episode |
int
|
Number of training episodes. Default 300. |
300
|
epsilon |
float
|
Learning rate. Default 0.01. |
0.01
|
beta1 |
float
|
Exponential decay rate for first moment estimates (Adam). Default 0.90. |
0.9
|
beta2 |
float
|
Exponential decay rate for second moment estimates (Adam). Default 0.99. |
0.99
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
load |
bool
|
Whether to load initial states from
|
False
|
Source code in quanestimation/base/StateOpt/AD_Sopt.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
State optimization with RI¶
Bases: StateSystem
Attributes¶
savefile:
bool-- Whether or not to save all the states.
If setTruethen the states and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe state in the final episode and the values of the objective function in all episodes will be saved.psi0:
list of arrays-- Initial guesses of states.max_episode:
int-- The number of episodes.seed:
int-- Random seed.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load states in the current location.
If setTruethen the program will load state from "states.csv" file in the current location and use it as the initial state.
Source code in quanestimation/base/StateOpt/RI_Sopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
CFIM(M=None, W=None)
¶
Choose CFIM as the objective function.
Note: CFIM is not available.
Parameters¶
M:
list-- POVM.W:
matrix-- Weight matrix.
Source code in quanestimation/base/StateOpt/RI_Sopt.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
HCRB(W=None)
¶
Choose HCRB as the objective function.
Note: Here HCRB is not available.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/StateOpt/RI_Sopt.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
QFIM(W=None, LDtype='SLD')
¶
Choose QFI as the objective function.
Parameters¶
W:
matrix-- Weight matrix.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Only SLD can is available here.
Source code in quanestimation/base/StateOpt/RI_Sopt.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
__init__(savefile=False, psi0=[], max_episode=300, seed=1234, eps=1e-08, load=False)
¶
Initialize random iteration (RI) for state optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all states during
training. Default |
False
|
psi0 |
list of arrays
|
Initial guesses of probe states.
Default |
[]
|
max_episode |
int
|
Number of episodes. Default 300. |
300
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
load |
bool
|
Whether to load initial states from
|
False
|
Source code in quanestimation/base/StateOpt/RI_Sopt.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
State Optimization with PSO¶
Bases: StateSystem
Attributes¶
savefile:
bool-- Whether or not to save all the states.
If setTruethen the states and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe state in the final episode and the values of the objective function in all episodes will be saved.p_num:
int-- The number of particles.psi0:
list of arrays-- Initial guesses of states.max_episode:
int or list-- If it is an integer, for example max_episode=1000, it means the program will continuously run 1000 episodes. However, if it is an array, for example max_episode=[1000,100], the program will run 1000 episodes in total but replace states of all the particles with global best every 100 episodes.c0:
float-- The damping factor that assists convergence, also known as inertia weight.c1:
float-- The exploitation weight that attracts the particle to its best previous position, also known as cognitive learning factor.c2:
float-- The exploitation weight that attracts the particle to the best position
in the neighborhood, also known as social learning factor.seed:
int-- Random seed.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load states in the current location. If setTruethen the program will load state from "states.csv" file in the current location and use it as the initial state.
Source code in quanestimation/base/StateOpt/PSO_Sopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
CFIM(M=None, W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/StateOpt/PSO_Sopt.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
HCRB(W=None)
¶
Choose HCRB as the objective function.
Note: in single parameter estimation, HCRB is equivalent to QFI, please choose QFI as the objective function.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/StateOpt/PSO_Sopt.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
QFIM(W=None, LDtype='SLD')
¶
Choose QFI or \(\mathrm{Tr}(WF^{-1})\) as the objective function. In single parameter estimation the objective function is QFI and in multiparameter estimation it will be \(\mathrm{Tr}(WF^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Source code in quanestimation/base/StateOpt/PSO_Sopt.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
__init__(savefile=False, p_num=10, psi0=[], max_episode=[1000, 100], c0=1.0, c1=2.0, c2=2.0, seed=1234, eps=1e-08, load=False)
¶
Initialize particle swarm optimization for state optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all states during
training. Default |
False
|
p_num |
int
|
Number of particles. Default 10. |
10
|
psi0 |
list of arrays
|
Initial guesses of probe states.
Default |
[]
|
max_episode |
int or list
|
Number of episodes. If a list
|
[1000, 100]
|
c0 |
float
|
Inertia weight (damping factor). Default 1.0. |
1.0
|
c1 |
float
|
Cognitive learning factor. Default 2.0. |
2.0
|
c2 |
float
|
Social learning factor. Default 2.0. |
2.0
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
load |
bool
|
Whether to load initial states from
|
False
|
Source code in quanestimation/base/StateOpt/PSO_Sopt.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
State Optimization DE¶
Bases: StateSystem
Attributes¶
savefile:
bool-- Whether or not to save all the states.
If setTruethen the states and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe state in the final episode and the values of the objective function in all episodes will be saved.p_num:
int-- The number of populations.psi0:
list of arrays-- Initial guesses of states.max_episode:
int-- The number of episodes.c:
float-- Mutation constant.cr:
float-- Crossover constant.seed:
int-- Random seed.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load states in the current location.
If setTruethen the program will load state from "states.csv" file in the current location and use it as the initial state.
Source code in quanestimation/base/StateOpt/DE_Sopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
CFIM(M=None, W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/StateOpt/DE_Sopt.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
HCRB(W=None)
¶
Choose HCRB as the objective function.
Note: in single parameter estimation, HCRB is equivalent to QFI, please choose QFI as the objective function.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/StateOpt/DE_Sopt.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
QFIM(W=None, LDtype='SLD')
¶
Choose QFI or \(\mathrm{Tr}(WF^{-1})\) as the objective function. In single parameter estimation the objective function is QFI and in multiparameter estimation it will be \(\mathrm{Tr}(WF^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Source code in quanestimation/base/StateOpt/DE_Sopt.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
__init__(savefile=False, p_num=10, psi0=[], max_episode=1000, c=1.0, cr=0.5, seed=1234, eps=1e-08, load=False)
¶
Initialize differential evolution (DE) for state optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all states during
training. Default |
False
|
p_num |
int
|
Number of populations. Default 10. |
10
|
psi0 |
list of arrays
|
Initial guesses of probe states.
Default |
[]
|
max_episode |
int
|
Number of episodes. Default 1000. |
1000
|
c |
float
|
Mutation constant. Default 1.0. |
1.0
|
cr |
float
|
Crossover constant. Default 0.5. |
0.5
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
load |
bool
|
Whether to load initial states from
|
False
|
Source code in quanestimation/base/StateOpt/DE_Sopt.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
Measurement Optimization¶
In QuanEstimation, three measurement optimization scenarios are considered. The first one is to optimize a set of rank-one projective measurement, it can be written in a specific basis \(\{|\phi_i\rangle\}\) with \(|\phi_i\rangle=\sum_j C_{ij}|j\rangle\) in the Hilbert space as \(\{|\phi_i\rangle\langle\phi_i|\}\). In this case, the goal is to search a set of optimal coefficients \(C_{ij}\). The second scenario is to find the optimal linear combination of an input measurement \(\{\Pi_j\}\). The third scenario is to find the optimal rotated measurement of an input measurement. After rotation, the new measurement is \(\{U\Pi_i U^{\dagger}\}\), where \(U=\prod_k \exp(i s_k\lambda_k)\) with \(\lambda_k\) a SU(\(N\)) generator and \(s_k\) a real number in the regime \([0,2\pi]\). In this scenario, the goal is to search a set of optimal coefficients \(s_k\). Here different algorithms are invoked to search the optimal measurement include particle swarm optimization (PSO) [1], differential evolution (DE) [2], and automatic differentiation (AD) [[3]] (#Baydin2018).
Base¶
Attributes
mtype:
string-- The type of scenarios for the measurement optimization. Options are:
"projection" (default) -- Optimization of rank-one projective measurements.
"input" -- Find the optimal linear combination or the optimal rotated measurement of a given set of POVM.minput:
list-- In the case of optimization of rank-one projective measurements, theminputshould keep empty. For finding the optimal linear combination and the optimal rotated measurement of a given set of POVM, the input rule areminput=["LC", [Pi1,Pi2,...], m]andminput=["LC", [Pi1,Pi2,...]]respectively. Here[Pi1,Pi2,...]represents a list of input POVM andmis the number of operators of the output measurement.savefile:
bool-- Whether or not to save all the measurements.
If setTruethen the measurements and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe measurement in the final episode and the values of the objective function in all episodes will be saved.measurement0:
list of arrays-- Initial guesses of measurements.seed:
int-- Random seed.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load measurements in the current location.
If setTruethen the program will load measurement from "measurements.csv" file in the current location and use it as the initial measurement.dyn_method:
string-- The method for solving the Lindblad dynamcs. Options are: "expm" (default) -- matrix exponential. "ode" -- ordinary differential equation solvers.
Source code in quanestimation/base/MeasurementOpt/MeasurementStruct.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |
CFIM(W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/MeasurementOpt/MeasurementStruct.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |
Kraus(rho0, K, dK)
¶
The parameterization of a state is \begin{align} \rho=\sum_i K_i\rho_0K_i^{\dagger}, \end{align}
where \(\rho\) is the evolved density matrix, \(K_i\) is the Kraus operator.
Parameters¶
rho0:
matrix-- Initial state (density matrix).K:
list-- Kraus operators.dK:
list-- Derivatives of the Kraus operators on the unknown parameters to be estimated. For example, dK[0] is the derivative vector on the first parameter.
Source code in quanestimation/base/MeasurementOpt/MeasurementStruct.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | |
__init__(mtype, minput, savefile, measurement0, seed, eps, load)
¶
Initialize the measurement optimization system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mtype |
str
|
Measurement optimization scenario. Options are:
|
required |
minput |
list
|
Additional parameters for the |
required |
savefile |
bool
|
Whether to save all measurements during training.
If |
required |
measurement0 |
list of arrays
|
Initial guesses of measurements. |
required |
seed |
int
|
Random seed. |
required |
eps |
float
|
Machine epsilon. |
required |
load |
bool
|
Whether to load measurements from |
required |
Source code in quanestimation/base/MeasurementOpt/MeasurementStruct.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
dynamics(tspan, rho0, H0, dH, Hc=None, ctrl=None, decay=None, dyn_method='expm')
¶
The dynamics of a density matrix is of the form
where \(\rho\) is the evolved density matrix, H is the Hamiltonian of the system, \(\Gamma_i\) and \(\gamma_i\) are the \(i\mathrm{th}\) decay operator and corresponding decay rate.
Parameters¶
tspan:
array-- Time length for the evolution.rho0:
matrix-- Initial state (density matrix).H0:
matrix or list-- Free Hamiltonian. It is a matrix when the free Hamiltonian is time- independent and a list of length equal totspanwhen it is time-dependent.dH:
list-- Derivatives of the free Hamiltonian on the unknown parameters to be estimated. For example, dH[0] is the derivative vector on the first parameter.Hc:
list-- Control Hamiltonians.ctrl:
list of arrays-- Control coefficients.decay:
list-- Decay operators and the corresponding decay rates. Its input rule is decay=[[\(\Gamma_1\), \(\gamma_1\)], [\(\Gamma_2\),\(\gamma_2\)],...], where \(\Gamma_1\) \((\Gamma_2)\) represents the decay operator and \(\gamma_1\) \((\gamma_2)\) is the corresponding decay rate.dyn_method:
string-- Setting the method for solving the Lindblad dynamics. Options are:
"expm" (default) -- Matrix exponential.
"ode" -- Solving the differential equations directly.
Source code in quanestimation/base/MeasurementOpt/MeasurementStruct.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
load_save(mnum, max_episode)
¶
Load optimized measurements saved by the Julia backend from
measurements.dat and save them as a measurements.npy file.
The Julia backend writes measurements.dat atomically (temp → rename),
and the file is deleted after a successful read to avoid stale data
from interfering with subsequent runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mnum |
int
|
Number of measurement operators. |
required |
max_episode |
int
|
Maximum number of episodes. |
required |
Source code in quanestimation/base/MeasurementOpt/MeasurementStruct.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
Measurement optimization with AD¶
Bases: MeasurementSystem
Attributes¶
savefile:
bool-- Whether or not to save all the measurements.
If setTruethen the measurements and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe measurement in the final episode and the values of the objective function in all episodes will be saved.Adam:
bool-- Whether or not to use Adam for updating measurements.measurement0:
list of arrays-- Initial guesses of measurements.max_episode:
int-- The number of episodes.epsilon:
float-- Learning rate.beta1:
float-- The exponential decay rate for the first moment estimates.beta2:
float-- The exponential decay rate for the second moment estimates.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load measurements in the current location.
If setTruethen the program will load measurement from "measurements.csv" file in the current location and use it as the initial measurement.
Source code in quanestimation/base/MeasurementOpt/AD_Mopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
CFIM(W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/MeasurementOpt/AD_Mopt.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
__init__(mtype, minput, savefile=False, Adam=False, measurement0=[], max_episode=300, epsilon=0.01, beta1=0.9, beta2=0.99, seed=1234, eps=1e-08, load=False)
¶
Initialize automatic differentiation (AD) for measurement optimization.
Supports both gradient descent and Adam optimizer. Note: AD is only
available for mtype="input" (not for projective measurements).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mtype |
str
|
Measurement optimization scenario. |
required |
minput |
list
|
Additional input parameters for the |
required |
savefile |
bool
|
Whether to save all measurements during
training. Default |
False
|
Adam |
bool
|
Whether to use the Adam optimizer.
Default |
False
|
measurement0 |
list of arrays
|
Initial guesses of
measurements. Default |
[]
|
max_episode |
int
|
Number of training episodes. Default 300. |
300
|
epsilon |
float
|
Learning rate. Default 0.01. |
0.01
|
beta1 |
float
|
Exponential decay rate for first moment estimates (Adam). Default 0.90. |
0.9
|
beta2 |
float
|
Exponential decay rate for second moment estimates (Adam). Default 0.99. |
0.99
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
load |
bool
|
Whether to load initial measurements from
|
False
|
Source code in quanestimation/base/MeasurementOpt/AD_Mopt.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
Measurement Optimization with PSO¶
Bases: MeasurementSystem
Attributes¶
savefile:
bool-- Whether or not to save all the measurements.
If setTruethen the measurements and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe measurement in the final episode and the values of the objective function in all episodes will be saved.p_num:
int-- The number of particles.measurement0:
list of arrays-- Initial guesses of measurements.max_episode:
int or list-- If it is an integer, for example max_episode=1000, it means the program will continuously run 1000 episodes. However, if it is an array, for example max_episode=[1000,100], the program will run 1000 episodes in total but replace measurements of all the particles with global best every 100 episodes.c0:
float-- The damping factor that assists convergence, also known as inertia weight.c1:
float-- The exploitation weight that attracts the particle to its best previous position, also known as cognitive learning factor.c2:
float-- The exploitation weight that attracts the particle to the best position
in the neighborhood, also known as social learning factor.seed:
int-- Random seed.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load measurements in the current location.
If setTruethen the program will load measurement from "measurements.csv" file in the current location and use it as the initial measurement.
Source code in quanestimation/base/MeasurementOpt/PSO_Mopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
CFIM(W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/MeasurementOpt/PSO_Mopt.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
__init__(mtype, minput, savefile=False, p_num=10, measurement0=[], max_episode=[1000, 100], c0=1.0, c1=2.0, c2=2.0, seed=1234, eps=1e-08, load=False)
¶
Initialize particle swarm optimization for measurement optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mtype |
str
|
Measurement optimization scenario. |
required |
minput |
list
|
Additional input parameters for the |
required |
savefile |
bool
|
Whether to save all measurements during
training. Default |
False
|
p_num |
int
|
Number of particles. Default 10. |
10
|
measurement0 |
list of arrays
|
Initial guesses of
measurements. Default |
[]
|
max_episode |
int or list
|
Number of episodes. If a list
|
[1000, 100]
|
c0 |
float
|
Inertia weight (damping factor). Default 1.0. |
1.0
|
c1 |
float
|
Cognitive learning factor. Default 2.0. |
2.0
|
c2 |
float
|
Social learning factor. Default 2.0. |
2.0
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
load |
bool
|
Whether to load initial measurements from
|
False
|
Source code in quanestimation/base/MeasurementOpt/PSO_Mopt.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
Measurement Optimization with DE¶
Bases: MeasurementSystem
Attributes¶
savefile:
bool-- Whether or not to save all the measurements.
If setTruethen the measurements and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe measurement in the final episode and the values of the objective function in all episodes will be saved.p_num:
int-- The number of populations.measurement0:
list of arrays-- Initial guesses of measurements.max_episode:
int-- The number of episodes.c:
float-- Mutation constant.cr:
float-- Crossover constant.seed:
int-- Random seed.eps:
float-- Machine epsilon.load:
bool-- Whether or not to load measurements in the current location.
If setTruethen the program will load measurement from "measurements.csv" file in the current location and use it as the initial measurement.
Source code in quanestimation/base/MeasurementOpt/DE_Mopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
CFIM(W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/MeasurementOpt/DE_Mopt.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
__init__(mtype, minput, savefile=False, p_num=10, measurement0=[], max_episode=1000, c=1.0, cr=0.5, seed=1234, eps=1e-08, load=False)
¶
Initialize differential evolution (DE) for measurement optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mtype |
str
|
Measurement optimization scenario. |
required |
minput |
list
|
Additional input parameters for the |
required |
savefile |
bool
|
Whether to save all measurements during
training. Default |
False
|
p_num |
int
|
Number of populations. Default 10. |
10
|
measurement0 |
list of arrays
|
Initial guesses of
measurements. Default |
[]
|
max_episode |
int
|
Number of episodes. Default 1000. |
1000
|
c |
float
|
Mutation constant. Default 1.0. |
1.0
|
cr |
float
|
Crossover constant. Default 0.5. |
0.5
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
load |
bool
|
Whether to load initial measurements from
|
False
|
Source code in quanestimation/base/MeasurementOpt/DE_Mopt.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
Comprehensive Optimization¶
In order to obtain the optimal parameter estimation schemes, it is necessary to simultaneously optimize the probe state, control and measurement. The comprehensive optimization for the probe state and measurement (SM), the probe state and control (SC), the control and measurement (CM) and the probe state, control and measurement (SCM) are proposed for this. In QuanEstimation, the comprehensive optimization algorithms are particle swarm optimization (PSO), differential evolution (DE), and automatic differentiation (AD).
Base¶
Attributes¶
savefile:
bool-- Whether or not to save all the optimized variables (probe states, control coefficients and measurements).
If setTruethen the optimized variables and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe optimized variables in the final episode and the values of the objective function in all episodes will be saved.psi0:
list of arrays-- Initial guesses of states.ctrl0:
list of arrays-- Initial guesses of control coefficients.measurement0:
list of arrays-- Initial guesses of measurements.seed:
int-- Random seed.eps:
float-- Machine epsilon.
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | |
CM(rho0, W=None)
¶
Comprehensive optimization of the control and measurement (CM).
Parameters¶
rho0:
matrix-- Initial state (density matrix).W:
matrix-- Weight matrix.
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
Kraus(K, dK)
¶
The parameterization of a state is \begin{align} \rho=\sum_i K_i\rho_0K_i^{\dagger}, \end{align}
where \(\rho\) is the evolved density matrix, \(K_i\) is the Kraus operator.
Parameters¶
K:
list-- Kraus operators.dK:
list-- Derivatives of the Kraus operators on the unknown parameters to be estimated. For example, dK[0] is the derivative vector on the first parameter.
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
SC(W=None, M=None, target='QFIM', LDtype='SLD')
¶
Comprehensive optimization of the probe state and control (SC).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).target:
string-- Objective functions for comprehensive optimization. Options are:
"QFIM" (default) -- choose QFI (QFIM) as the objective function.
"CFIM" -- choose CFI (CFIM) as the objective function.
"HCRB" -- choose HCRB as the objective function.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |
SCM(W=None)
¶
Comprehensive optimization of the probe state, control and measurement (SCM).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | |
SM(W=None)
¶
Comprehensive optimization of the probe state and measurement (SM).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | |
__init__(savefile, psi0, ctrl0, measurement0, seed, eps)
¶
Initialize the comprehensive optimization system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all optimized variables during training.
If |
required |
psi0 |
list of arrays
|
Initial guesses of probe states. |
required |
ctrl0 |
list of arrays
|
Initial guesses of control coefficients. |
required |
measurement0 |
list of arrays
|
Initial guesses of measurements. |
required |
seed |
int
|
Random seed. |
required |
eps |
float
|
Machine epsilon. |
required |
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
dynamics(tspan, H0, dH, Hc=None, ctrl=None, decay=None, ctrl_bound=None, dyn_method='expm')
¶
The dynamics of a density matrix is of the form
where \(\rho\) is the evolved density matrix, H is the Hamiltonian of the system, \(\Gamma_i\) and \(\gamma_i\) are the \(i\mathrm{th}\) decay operator and corresponding decay rate.
Parameters¶
tspan:
array-- Time length for the evolution.H0:
matrix or list-- Free Hamiltonian. It is a matrix when the free Hamiltonian is time- independent and a list of length equal totspanwhen it is time-dependent.dH:
list-- Derivatives of the free Hamiltonian on the unknown parameters to be estimated. For example, dH[0] is the derivative vector on the first parameter.Hc:
list-- Control Hamiltonians.ctrl:
list of arrays-- Control coefficients.decay:
list-- Decay operators and the corresponding decay rates. Its input rule is decay=[[\(\Gamma_1\), \(\gamma_1\)], [\(\Gamma_2\),\(\gamma_2\)],...], where \(\Gamma_1\) \((\Gamma_2)\) represents the decay operator and \(\gamma_1\) \((\gamma_2)\) is the corresponding decay rate.ctrl_bound:
array-- Lower and upper bounds of the control coefficients.ctrl_bound[0]represents the lower bound of the control coefficients andctrl_bound[1]represents the upper bound of the control coefficients.dyn_method:
string-- Setting the method for solving the Lindblad dynamics. Options are:
"expm" (default) -- Matrix exponential.
"ode" -- Solving the differential equations directly.
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
load_save_ctrls(cnum, max_episode)
¶
Load control coefficients saved by the Julia backend from controls.dat
and save them as a controls.npy file for later analysis.
The Julia backend writes controls.dat atomically (temp → rename),
and the file is deleted after a successful read to avoid stale data
from interfering with subsequent runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cnum |
int
|
Number of control Hamiltonian channels. |
required |
max_episode |
int
|
Maximum number of episodes. |
required |
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
load_save_meas(mnum, max_episode)
¶
Load optimized measurements saved by the Julia backend from
measurements.dat and save them as a measurements.npy file.
The Julia backend writes measurements.dat atomically (temp → rename),
and the file is deleted after a successful read to avoid stale data
from interfering with subsequent runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mnum |
int
|
Number of measurement operators. |
required |
max_episode |
int
|
Maximum number of episodes. |
required |
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
load_save_states(max_episode)
¶
Load optimized probe states saved by the Julia backend from states.dat
and save them as a states.npy file.
The Julia backend writes states.dat atomically (temp → rename),
and the file is deleted after a successful read to avoid stale data
from interfering with subsequent runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_episode |
int
|
Maximum number of episodes. |
required |
Source code in quanestimation/base/ComprehensiveOpt/ComprehensiveStruct.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
Comprehensive optimization with AD¶
Bases: ComprehensiveSystem
Attributes¶
savefile:
bool-- Whether or not to save all the optimized variables (probe states, control coefficients and measurements).
If setTruethen the optimized variables and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe optimized variables in the final episode and the values of the objective function in all episodes will be saved.Adam:
bool-- Whether or not to use Adam for updating.psi0:
list of arrays-- Initial guesses of states.ctrl0:
list of arrays-- Initial guesses of control coefficients.measurement0:
list of arrays-- Initial guesses of measurements.max_episode:
int-- The number of episodes.epsilon:
float-- Learning rate.beta1:
float-- The exponential decay rate for the first moment estimates.beta2:
float-- The exponential decay rate for the second moment estimates.seed:
int-- Random seed.eps:
float-- Machine epsilon.
Source code in quanestimation/base/ComprehensiveOpt/AD_Compopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
SC(W=None, M=None, target='QFIM', LDtype='SLD')
¶
Comprehensive optimization of the probe state and control (SC).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).target:
string-- Objective functions for searching the minimum time to reach the given value of the objective function. Options are:
"QFIM" (default) -- choose QFI (QFIM) as the objective function.
"CFIM" -- choose CFI (CFIM) as the objective function.
"HCRB" -- choose HCRB as the objective function.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Note: AD is only available when target is 'QFIM'.
Source code in quanestimation/base/ComprehensiveOpt/AD_Compopt.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
__init__(savefile=False, Adam=False, psi0=[], ctrl0=[], measurement0=[], max_episode=300, epsilon=0.01, beta1=0.9, beta2=0.99, seed=1234, eps=1e-08)
¶
Initialize automatic differentiation (AD) for comprehensive optimization.
Note: AD is only available when the objective function target is
"QFIM" (not "CFIM" or "HCRB").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all optimized variables
during training. Default |
False
|
Adam |
bool
|
Whether to use the Adam optimizer.
Default |
False
|
psi0 |
list of arrays
|
Initial guesses of probe states.
Default |
[]
|
ctrl0 |
list of arrays
|
Initial guesses of control
coefficients. Default |
[]
|
measurement0 |
list of arrays
|
Initial guesses of
measurements. Default |
[]
|
max_episode |
int
|
Number of training episodes. Default 300. |
300
|
epsilon |
float
|
Learning rate. Default 0.01. |
0.01
|
beta1 |
float
|
Exponential decay rate for first moment estimates (Adam). Default 0.90. |
0.9
|
beta2 |
float
|
Exponential decay rate for second moment estimates (Adam). Default 0.99. |
0.99
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
Source code in quanestimation/base/ComprehensiveOpt/AD_Compopt.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
Comprehensive Optimization with PSO¶
Bases: ComprehensiveSystem
Attributes¶
savefile:
bool-- Whether or not to save all the optimized variables (probe states, control coefficients and measurements).
If setTruethen the optimized variables and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe optimized variables in the final episode and the values of the objective function in all episodes will be saved.p_num:
int-- The number of particles.psi0:
list of arrays-- Initial guesses of states.ctrl0:
list of arrays-- Initial guesses of control coefficients.measurement0:
list of arrays-- Initial guesses of measurements.max_episode:
int or list-- If it is an integer, for example max_episode=1000, it means the program will continuously run 1000 episodes. However, if it is an array, for example max_episode=[1000,100], the program will run 1000 episodes in total but replace states of all the particles with global best every 100 episodes.c0:
float-- The damping factor that assists convergence, also known as inertia weight.c1:
float-- The exploitation weight that attracts the particle to its best previous position, also known as cognitive learning factor.c2:
float-- The exploitation weight that attracts the particle to the best position
in the neighborhood, also known as social learning factor.seed:
int-- Random seed.eps:
float-- Machine epsilon.
Source code in quanestimation/base/ComprehensiveOpt/PSO_Compopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
CM(rho0, W=None)
¶
Comprehensive optimization of the control and measurement (CM).
Parameters¶
rho0:
matrix-- Initial state (density matrix).W:
matrix-- Weight matrix.
Source code in quanestimation/base/ComprehensiveOpt/PSO_Compopt.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
SC(W=None, M=None, target='QFIM', LDtype='SLD')
¶
Comprehensive optimization of the probe state and control (SC).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).target:
string-- Objective functions for searching the minimum time to reach the given value of the objective function. Options are:
"QFIM" (default) -- choose QFI (QFIM) as the objective function.
"CFIM" -- choose CFI (CFIM) as the objective function.
"HCRB" -- choose HCRB as the objective function.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ComprehensiveOpt/PSO_Compopt.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
SCM(W=None)
¶
Comprehensive optimization of the probe state, the control and measurements (SCM).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ComprehensiveOpt/PSO_Compopt.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
SM(W=None)
¶
Comprehensive optimization of the probe state and measurement (SM).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ComprehensiveOpt/PSO_Compopt.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
__init__(savefile=False, p_num=10, psi0=[], ctrl0=[], measurement0=[], max_episode=[1000, 100], c0=1.0, c1=2.0, c2=2.0, seed=1234, eps=1e-08)
¶
Initialize particle swarm optimization for comprehensive optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all optimized variables
during training. Default |
False
|
p_num |
int
|
Number of particles. Default 10. |
10
|
psi0 |
list of arrays
|
Initial guesses of probe states.
Default |
[]
|
ctrl0 |
list of arrays
|
Initial guesses of control
coefficients. Default |
[]
|
measurement0 |
list of arrays
|
Initial guesses of
measurements. Default |
[]
|
max_episode |
int or list
|
Number of episodes. If a list
|
[1000, 100]
|
c0 |
float
|
Inertia weight (damping factor). Default 1.0. |
1.0
|
c1 |
float
|
Cognitive learning factor. Default 2.0. |
2.0
|
c2 |
float
|
Social learning factor. Default 2.0. |
2.0
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
Source code in quanestimation/base/ComprehensiveOpt/PSO_Compopt.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
Comprehensive Optimization with DE¶
Bases: ComprehensiveSystem
Attributes¶
savefile:
bool-- Whether or not to save all the optimized variables (probe states, control coefficients and measurements).
If setTruethen the optimized variables and the values of the objective function obtained in all episodes will be saved during the training. If setFalsethe optimized variables in the final episode and the values of the objective function in all episodes will be saved.p_num:
int-- The number of populations.psi0:
list of arrays-- Initial guesses of states.ctrl0:
list of arrays-- Initial guesses of control coefficients.measurement0:
list of arrays-- Initial guesses of measurements.max_episode:
int-- The number of episodes.c:
float-- Mutation constant.cr:
float-- Crossover constant.seed:
int-- Random seed.eps:
float-- Machine epsilon.
Source code in quanestimation/base/ComprehensiveOpt/DE_Compopt.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
CM(rho0, W=None)
¶
Comprehensive optimization of the control and measurement (CM).
Parameters¶
rho0:
matrix-- Initial state (density matrix).W:
matrix-- Weight matrix.
Source code in quanestimation/base/ComprehensiveOpt/DE_Compopt.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
SC(W=None, M=None, target='QFIM', LDtype='SLD')
¶
Comprehensive optimization of the probe state and control (SC).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).target:
string-- Objective functions for searching the minimum time to reach the given value of the objective function. Options are:
"QFIM" (default) -- choose QFI (QFIM) as the objective function.
"CFIM" -- choose CFI (CFIM) as the objective function.
"HCRB" -- choose HCRB as the objective function.LDtype:
string-- Types of QFI (QFIM) can be set as the objective function. Options are:
"SLD" (default) -- QFI (QFIM) based on symmetric logarithmic derivative (SLD).
"RLD" -- QFI (QFIM) based on right logarithmic derivative (RLD).
"LLD" -- QFI (QFIM) based on left logarithmic derivative (LLD).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/ComprehensiveOpt/DE_Compopt.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
SCM(W=None)
¶
Comprehensive optimization of the probe state, control and measurement (SCM).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ComprehensiveOpt/DE_Compopt.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
SM(W=None)
¶
Comprehensive optimization of the probe state and measurement (SM).
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/ComprehensiveOpt/DE_Compopt.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
__init__(savefile=False, p_num=10, psi0=[], ctrl0=[], measurement0=[], max_episode=1000, c=1.0, cr=0.5, seed=1234, eps=1e-08)
¶
Initialize differential evolution (DE) for comprehensive optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
savefile |
bool
|
Whether to save all optimized variables
during training. Default |
False
|
p_num |
int
|
Number of populations. Default 10. |
10
|
psi0 |
list of arrays
|
Initial guesses of probe states.
Default |
[]
|
ctrl0 |
list of arrays
|
Initial guesses of control
coefficients. Default |
[]
|
measurement0 |
list of arrays
|
Initial guesses of
measurements. Default |
[]
|
max_episode |
int
|
Number of episodes. Default 1000. |
1000
|
c |
float
|
Mutation constant. Default 1.0. |
1.0
|
cr |
float
|
Crossover constant. Default 0.5. |
0.5
|
seed |
int
|
Random seed. Default 1234. |
1234
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
Source code in quanestimation/base/ComprehensiveOpt/DE_Compopt.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
Adaptive measurement schemes¶
In QuanEstimation, the Hamiltonian of the adaptive system should be written as \(H(\textbf{x}+\textbf{u})\) with \(\textbf{x}\) the unknown parameters and \(\textbf{u}\) the tunable parameters. The tunable parameters \(\textbf{u}\) are used to let the Hamiltonian work at the optimal point \(\textbf{x}_{\mathrm{opt}}\).
Adaptive measurement¶
Attributes¶
x:
list-- The regimes of the parameters for the integral.p:
multidimensional array-- The prior distribution.rho0:
matrix-- Initial state (density matrix).method:
string-- Choose the method for updating the tunable parameters (u). Options are:
"FOP" (default) -- Fix optimal point.
"MI" -- mutual information.savefile:
bool-- Whether or not to save all the posterior distributions.
If setTruethen three files "pout.npy", "xout.npy" and "y.npy" will be generated including the posterior distributions, the estimated values, and the experimental results in the iterations. If setFalsethe posterior distribution in the final iteration, the estimated values and the experimental results in all iterations will be saved in "pout.npy", "xout.npy" and "y.npy".max_episode:
int-- The number of episodes.eps:
float-- Machine epsilon.
Source code in quanestimation/base/AdaptiveScheme/Adapt.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
CFIM(M=None, W=None)
¶
Choose CFI or \(\mathrm{Tr}(WI^{-1})\) as the objective function. In single parameter estimation the objective function is CFI and in multiparameter estimation it will be \(\mathrm{Tr}(WI^{-1})\).
Parameters¶
W:
matrix-- Weight matrix.M:
list of matrices-- A set of positive operator-valued measure (POVM). The default measurement is a set of rank-one symmetric informationally complete POVM (SIC-POVM).
Note: SIC-POVM is calculated by the Weyl-Heisenberg covariant SIC-POVM fiducial state which can be downloaded from here.
Source code in quanestimation/base/AdaptiveScheme/Adapt.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
Kraus(K, dK)
¶
Dynamics of the density matrix of the form \begin{align} \rho=\sum_i K_i\rho_0K_i^{\dagger} \end{align}
where \(\rho\) is the evolved density matrix, \(K_i\) is the Kraus operator.
Parameters¶
K:
multidimensional list-- Kraus operator(s) with respect to the values in x.dK:
multidimensional list-- Derivatives of the Kraus operator(s) with respect to the unknown parameters to be estimated.
Source code in quanestimation/base/AdaptiveScheme/Adapt.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
Mopt(W=None)
¶
Measurement optimization for the optimal x.
Parameters¶
W:
matrix-- Weight matrix.
Source code in quanestimation/base/AdaptiveScheme/Adapt.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
__init__(x, p, rho0, method='FOP', savefile=False, max_episode=1000, eps=1e-08)
¶
Initialize the adaptive scheme for quantum parameter estimation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x |
list
|
The regimes of the parameters for the integral. |
required |
p |
ndarray
|
The prior distribution. |
required |
rho0 |
matrix
|
Initial state (density matrix). |
required |
method |
str
|
Method for updating the tunable parameters. "FOP" (default) -- Fix optimal point. "MI" -- mutual information. |
'FOP'
|
savefile |
bool
|
Whether to save all posterior distributions.
Default |
False
|
max_episode |
int
|
The number of episodes. Default 1000. |
1000
|
eps |
float
|
Machine epsilon. Default 1e-8. |
1e-08
|
Source code in quanestimation/base/AdaptiveScheme/Adapt.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
dynamics(tspan, H, dH, Hc=None, ctrl=None, decay=None, dyn_method='expm')
¶
Dynamics of the density matrix of the form
where \(\rho\) is the evolved density matrix, H is the Hamiltonian of the system, \(\Gamma_i\) and \(\gamma_i\) are the \(i\mathrm{th}\) decay operator and decay rate.
Parameters¶
tspan:
array-- Time length for the evolution.H0:
multidimensional list-- Free Hamiltonian with respect to the values in x.dH:
multidimensional list-- Derivatives of the free Hamiltonian with respect to the unknown parameters to be estimated.Hc:
list-- Control Hamiltonians.ctrl:
list-- Control coefficients.decay:
list-- Decay operators and the corresponding decay rates. Its input rule isdecay=[[Gamma1, gamma1], [Gamma2,gamma2],...], whereGamma1 (Gamma2)represents the decay operator andgamma1 (gamma2)is the corresponding decay rate.dyn_method:
string-- Setting the method for solving the Lindblad dynamics. Options are:
"expm" (default) -- Matrix exponential.
"ode" -- Solving the differential equations directly.
Source code in quanestimation/base/AdaptiveScheme/Adapt.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
Attributes¶
x:
list-- The regimes of the parameters for the integral.p:
multidimensional array-- The prior distribution.rho0:
matrix-- Initial state (density matrix).
Source code in quanestimation/base/AdaptiveScheme/Adapt_MZI.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
__init__(x, p, rho0)
¶
Initialize the adaptive MZI (Mach-Zehnder interferometer) estimation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x |
list
|
The regimes of the parameters for the integral. |
required |
p |
ndarray
|
The prior distribution. |
required |
rho0 |
matrix
|
Initial state (density matrix). |
required |
Source code in quanestimation/base/AdaptiveScheme/Adapt_MZI.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
general()
¶
Set the MZI type to general, indicating the use of a general Mach-Zehnder interferometer scheme with two input ports.
Source code in quanestimation/base/AdaptiveScheme/Adapt_MZI.py
37 38 39 40 41 42 | |
offline(target='sharpness', method='DE', p_num=10, deltaphi0=[], c=1.0, cr=0.5, c0=1.0, c1=2.0, c2=2.0, seed=1234, max_episode=1000, eps=1e-08)
¶
Parameters¶
target:
string-- Setting the target function for calculating the tunable phase. Options are:
"sharpness" (default) -- Sharpness.
"MI" -- Mutual information.method:
string-- The method for the adaptive phase estimation. Options are:
"DE" (default) -- DE algorithm for the adaptive phase estimation.
"PSO" -- PSO algorithm for the adaptive phase estimation.
If the method=DE, the parameters are:
p_num:
int-- The number of populations.deltaphi0:
list-- Initial guesses of phase difference.max_episode:
int-- The number of episodes.c:
float-- Mutation constant.cr:
float-- Crossover constant.seed:
int-- Random seed.eps:
float-- Machine epsilon.
If the method=PSO, the parameters are:
deltaphi0:
list-- Initial guesses of phase difference.max_episode:
int or list-- If it is an integer, for example max_episode=1000, it means the program will continuously run 1000 episodes. However, if it is an array, for example max_episode=[1000,100], the program will run 1000 episodes in total but replace states of all the particles with global best every 100 episodes.c0:
float-- The damping factor that assists convergence, also known as inertia weight.c1:
float-- The exploitation weight that attracts the particle to its best previous position, also known as cognitive learning factor.c2:
float-- The exploitation weight that attracts the particle to the best position
in the neighborhood, also known as social learning factor.eps:
float-- Machine epsilon.
Source code in quanestimation/base/AdaptiveScheme/Adapt_MZI.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
online(target='sharpness', output='phi')
¶
Parameters¶
target:
string-- Setting the target function for calculating the tunable phase. Options are:
"sharpness" (default) -- Sharpness.
"MI" -- Mutual information.output:
string-- The output the class. Options are:
"phi" (default) -- The tunable phase.
"dphi" -- Phase difference.
Source code in quanestimation/base/AdaptiveScheme/Adapt_MZI.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |