|
Quandary
|
Optimization problem solver for quantum optimal control. More...
#include <optimproblem.hpp>

Public Member Functions | |
| OptimProblem (const Config &config, OptimTarget *optim_target_, TimeStepper *timestepper_, MasterEq *mastereq_, MPI_Comm comm_init_, MPI_Comm comm_optim, Output *output_, bool quietmode=false) | |
| Constructor for optimization problem. | |
| ~OptimProblem () | |
| int | getNdesign () |
| double | getObjective () |
| double | getCostT () |
| double | getRegul () |
| double | getPenaltyLeakage () |
| double | getPenaltyWeightedCost () |
| double | getPenaltyDpDm () |
| double | getPenaltyVariation () |
| double | getPenaltyEnergy () |
| double | getFidelity () |
| double | getTolFinalCost () |
| double | getTolGradAbs () |
| double | getTolInfidelity () |
| int | getMPIrank_world () |
| int | getMaxIter () |
| int | getOutputOptimizationStride () |
| Output * | getOutput () |
| TimeStepper * | getTimeStepper () |
| double | evalF (const Vec x) |
| Evaluates the objective function F(x). | |
| void | evalGradF (const Vec x, Vec G) |
| Evaluates the gradient of the objective function with respect to the control parameters. | |
| void | solve (Vec xinit) |
| Runs the optimization solver. | |
| void | getStartingPoint (Vec x) |
| Computes initial guess for optimization variables. | |
| void | getSolution (Vec *opt) |
| Retrieves the optimization solution and prints summary information. | |
Public Attributes | |
| Vec | xlower |
| Vec | xupper |
| Lower and upper bounds for optimization variables. | |
| Vec | xprev |
| Design vector at previous iteration. | |
| Vec | xinit |
| Initial design vector. | |
Protected Attributes | |
| size_t | ninit |
| Number of initial conditions to be considered (N^2, N, or 1) | |
| int | ninit_local |
| Local number of initial conditions on this processor. | |
| Vec | rho_t0 |
| Storage for initial condition of the ODE. | |
| Vec | rho_t0_bar |
| Storage for adjoint initial condition of the adjoint ODE (aka the terminal condition) | |
| OptimTarget * | optim_target |
| Pointer to the optimization target (gate or state) | |
| MPI_Comm | comm_init |
| MPI communicator for initial condition parallelization. | |
| MPI_Comm | comm_optim |
| MPI communicator for optimization parallelization, currently not used (size 1) | |
| int | mpirank_optim |
| int | mpisize_optim |
| MPI rank and size for optimization communicator. | |
| int | mpirank_petsc |
| int | mpisize_petsc |
| MPI rank and size for spatial parallelization (PETSc) | |
| int | mpirank_world |
| int | mpisize_world |
| MPI rank and size for global communicator. | |
| int | mpirank_init |
| int | mpisize_init |
| MPI rank and size for initial condition communicator. | |
| bool | quietmode |
| Flag for quiet mode operation. | |
| std::vector< double > | obj_weights |
| Weights for averaging objective over initial conditions. | |
| int | ndesign |
| Number of global design (optimization) parameters. | |
| double | objective |
| Current objective function value (sum over final-time cost, regularization terms and penalty terms) | |
| double | obj_cost |
| Final-time measure J(T) in objective. | |
| double | obj_regul |
| Regularization term in objective. | |
| double | obj_penal_leakage |
| Penalty term for leakage into guard levels. | |
| double | obj_penal_weightedcost |
| Penalty term for weighted running cost. | |
| double | obj_penal_dpdm |
| Penalty term second-order state derivatives (penalizes variations of the state evolution) | |
| double | obj_penal_variation |
| Penalty term for variation of control parameters. | |
| double | obj_penal_energy |
| Energy penalty term in objective. | |
| double | fidelity |
| Final-time fidelity: 1/ninit sum_i Tr(rho_target^dag rho(T)) for Lindblad, |1/ninit sum_i phi_target^dag phi|^2 for Schrodinger. | |
| double | gnorm |
| Current norm of gradient. | |
| double | gamma_tikhonov |
| Parameter for Tikhonov regularization. | |
| bool | tikhonov_use_x0 |
| Switch to use ||x - x0||^2 for Tikhonov regularization instead of ||x||^2. | |
| double | gamma_penalty_leakage |
| Parameter multiplying integral leakage term. | |
| double | gamma_penalty_weightedcost |
| Parameter multiplying integral weighted cost function. | |
| double | gamma_penalty_dpdm |
| Parameter multiplying integral penalty term for 2nd derivative of state variation. | |
| double | gamma_penalty_energy |
| Parameter multiplying energy penalty. | |
| double | gamma_penalty_variation |
| Parameter multiplying finite-difference squared regularization term. | |
| double | tol_grad_abs |
| Stopping criterion based on absolute gradient norm. | |
| double | tol_grad_rel |
| Stopping criterion based on relative gradient norm. | |
| double | tol_final_cost |
| Stopping criterion based on objective function value. | |
| double | tol_infidelity |
| Stopping criterion based on infidelity. | |
| int | maxiter |
| Stopping criterion based on maximum number of iterations. | |
| Tao | tao |
| PETSc's TAO optimization solver. | |
| double * | mygrad |
| Auxiliary gradient storage. | |
| Vec | xtmp |
| Temporary vector storage. | |
| int | output_optimization_stride |
| Write output files every N optimization iterations. | |
| TimeStepper * | timestepper |
| Pointer to time-stepping scheme. | |
| Output * | output |
| Pointer to output handler. | |
| MasterEq * | mastereq |
| Pointer to master equation solver. | |
Optimization problem solver for quantum optimal control.
This class manages the optimization of quantum control pulses using PETSc's TAO optimization library. It handles objective function evaluation, by propagating initial states forward in time solving the dynamical equation and computing the final-time objective cost function and integral penalty terms, as well as the gradient computation by backpropagating the adjoint terminal states backwards in time solving the adjoint dynamical equation and collecting gradient contributions. It further defines the interface functions for PETSc's TAO optimization via L-BFGS, including a callback function to monitor optimization progress.
Main functionality:
This class contains references to:
| OptimProblem::OptimProblem | ( | const Config & | config, |
| OptimTarget * | optim_target_, | ||
| TimeStepper * | timestepper_, | ||
| MasterEq * | mastereq_, | ||
| MPI_Comm | comm_init_, | ||
| MPI_Comm | comm_optim, | ||
| Output * | output_, | ||
| bool | quietmode = false |
||
| ) |
Constructor for optimization problem.
| config | Configuration parameters from input file |
| optim_target_ | Pointer to optimization target |
| timestepper_ | Pointer to time-stepping scheme |
| mastereq_ | Pointer to master equation solver |
| comm_init_ | MPI communicator for initial condition parallelization |
| comm_optim | MPI communicator for optimization parallelization |
| output_ | Pointer to output handler |
| quietmode | Flag for quiet operation (default: false) |
| OptimProblem::~OptimProblem | ( | ) |
| double OptimProblem::evalF | ( | const Vec | x | ) |
Evaluates the objective function F(x).
Performs forward simulations for each initial conditions and evaluates the objective function.
| x | Design vector |
| void OptimProblem::evalGradF | ( | const Vec | x, |
| Vec | G | ||
| ) |
Evaluates the gradient of the objective function with respect to the control parameters.
| x | Design (optimization) vector |
| G | Gradient vector to store result |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void OptimProblem::getSolution | ( | Vec * | opt | ) |
Retrieves the optimization solution and prints summary information.
This method should be called after TaoSolve() has finished.
| opt | Pointer to vector to store the optimal solution |
| void OptimProblem::getStartingPoint | ( | Vec | x | ) |
Computes initial guess for optimization variables.
| x | Vector to store the initial guess |
|
inline |
|
inline |
|
inline |
|
inline |
| void OptimProblem::solve | ( | Vec | xinit | ) |
Runs the optimization solver.
| xinit | Initial guess for design variables |
|
protected |
MPI communicator for initial condition parallelization.
|
protected |
MPI communicator for optimization parallelization, currently not used (size 1)
|
protected |
Final-time fidelity: 1/ninit sum_i Tr(rho_target^dag rho(T)) for Lindblad, |1/ninit sum_i phi_target^dag phi|^2 for Schrodinger.
|
protected |
Parameter multiplying integral penalty term for 2nd derivative of state variation.
|
protected |
Parameter multiplying energy penalty.
|
protected |
Parameter multiplying integral leakage term.
|
protected |
Parameter multiplying finite-difference squared regularization term.
|
protected |
Parameter multiplying integral weighted cost function.
|
protected |
Parameter for Tikhonov regularization.
|
protected |
Current norm of gradient.
|
protected |
Pointer to master equation solver.
|
protected |
Stopping criterion based on maximum number of iterations.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
MPI rank and size for initial condition communicator.
|
protected |
MPI rank and size for optimization communicator.
|
protected |
MPI rank and size for spatial parallelization (PETSc)
|
protected |
MPI rank and size for global communicator.
|
protected |
Auxiliary gradient storage.
|
protected |
Number of global design (optimization) parameters.
|
protected |
Number of initial conditions to be considered (N^2, N, or 1)
|
protected |
Local number of initial conditions on this processor.
|
protected |
Final-time measure J(T) in objective.
|
protected |
Penalty term second-order state derivatives (penalizes variations of the state evolution)
|
protected |
Energy penalty term in objective.
|
protected |
Penalty term for leakage into guard levels.
|
protected |
Penalty term for variation of control parameters.
|
protected |
Penalty term for weighted running cost.
|
protected |
Regularization term in objective.
|
protected |
Weights for averaging objective over initial conditions.
|
protected |
Current objective function value (sum over final-time cost, regularization terms and penalty terms)
|
protected |
Pointer to the optimization target (gate or state)
|
protected |
Pointer to output handler.
|
protected |
Write output files every N optimization iterations.
|
protected |
Flag for quiet mode operation.
|
protected |
Storage for initial condition of the ODE.
|
protected |
Storage for adjoint initial condition of the adjoint ODE (aka the terminal condition)
|
protected |
PETSc's TAO optimization solver.
|
protected |
Switch to use ||x - x0||^2 for Tikhonov regularization instead of ||x||^2.
|
protected |
Pointer to time-stepping scheme.
|
protected |
Stopping criterion based on objective function value.
|
protected |
Stopping criterion based on absolute gradient norm.
|
protected |
Stopping criterion based on relative gradient norm.
|
protected |
Stopping criterion based on infidelity.
| Vec OptimProblem::xinit |
Initial design vector.
| Vec OptimProblem::xlower |
| Vec OptimProblem::xprev |
Design vector at previous iteration.
|
protected |
Temporary vector storage.
| Vec OptimProblem::xupper |
Lower and upper bounds for optimization variables.