Quandary
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
OptimProblem Class Reference

Optimization problem solver for quantum optimal control. More...

#include <optimproblem.hpp>

Collaboration diagram for OptimProblem:
Collaboration graph
[legend]

Public Member Functions

 OptimProblem (const Config &config, TimeStepper *timestepper_, MPI_Comm comm_init_, MPI_Comm comm_optim, Output *output_, bool quietmode=false)
 Constructor for optimization problem.
 
 ~OptimProblem ()
 
int getNdesign ()
 Retrieves the number of design variables.
 
double getObjective ()
 Retrieves the current objective function value.
 
double getCostT ()
 Retrieves the final-time cost term.
 
double getRegul ()
 Retrieves the Tikhonov regularization term.
 
double getPenaltyLeakage ()
 Retrieves the integral term for leakage.
 
double getPenaltyWeightedCost ()
 Retrieves the integral penalty term for weighted running cost.
 
double getPenaltyDpDm ()
 Retrieves the second-order state derivative penalty term.
 
double getPenaltyVariation ()
 Retrieves the control variation penalty term.
 
double getPenaltyEnergy ()
 Retrieves the control energy penalty term.
 
double getFidelity ()
 Retrieves the current fidelity.
 
double getTolFinalCost ()
 Retrieves the objective function tolerance.
 
double getTolGradAbs ()
 Retrieves the gradient tolerance.
 
double getTolInfidelity ()
 Retrieves the infidelity tolerance.
 
int getMPIrank_world ()
 Retrieves the MPI rank in the world communicator.
 
int getMaxIter ()
 Retrieves the maximum number of iterations.
 
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

Outputoutput
 Pointer to output handler.
 
TimeSteppertimestepper
 Pointer to time-stepping scheme.
 
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)
 
std::vector< Vec > store_finalstates
 Storage for final states for each initial condition.
 
OptimTargetoptim_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.
 

Detailed Description

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:

Constructor & Destructor Documentation

◆ OptimProblem()

OptimProblem::OptimProblem ( const Config config,
TimeStepper timestepper_,
MPI_Comm  comm_init_,
MPI_Comm  comm_optim,
Output output_,
bool  quietmode = false 
)

Constructor for optimization problem.

Parameters
configConfiguration parameters from input file
timestepper_Pointer to time-stepping scheme
comm_init_MPI communicator for initial condition parallelization
comm_optimMPI communicator for optimization parallelization
output_Pointer to output handler
quietmodeFlag for quiet operation (default: false)

◆ ~OptimProblem()

OptimProblem::~OptimProblem ( )

Member Function Documentation

◆ evalF()

double OptimProblem::evalF ( const Vec  x)

Evaluates the objective function F(x).

Performs forward simulations for each initial conditions and evaluates the objective function.

Parameters
xDesign vector
Returns
double Objective function value

◆ evalGradF()

void OptimProblem::evalGradF ( const Vec  x,
Vec  G 
)

Evaluates the gradient of the objective function with respect to the control parameters.

Parameters
xDesign (optimization) vector
GGradient vector to store result

◆ getCostT()

double OptimProblem::getCostT ( )
inline

Retrieves the final-time cost term.

Returns
double Final-time cost J(T)

◆ getFidelity()

double OptimProblem::getFidelity ( )
inline

Retrieves the current fidelity.

Returns
double Quantum fidelity measure

◆ getMaxIter()

int OptimProblem::getMaxIter ( )
inline

Retrieves the maximum number of iterations.

Returns
int Maximum iteration limit

◆ getMPIrank_world()

int OptimProblem::getMPIrank_world ( )
inline

Retrieves the MPI rank in the world communicator.

Returns
int MPI rank

◆ getNdesign()

int OptimProblem::getNdesign ( )
inline

Retrieves the number of design variables.

Returns
int Number of optimization parameters

◆ getObjective()

double OptimProblem::getObjective ( )
inline

Retrieves the current objective function value.

Returns
double Total objective function value

◆ getPenaltyDpDm()

double OptimProblem::getPenaltyDpDm ( )
inline

Retrieves the second-order state derivative penalty term.

Returns
double Second-order penalty contribution

◆ getPenaltyEnergy()

double OptimProblem::getPenaltyEnergy ( )
inline

Retrieves the control energy penalty term.

Returns
double Energy penalty contribution

◆ getPenaltyLeakage()

double OptimProblem::getPenaltyLeakage ( )
inline

Retrieves the integral term for leakage.

Returns
double Penalty term contribution

◆ getPenaltyVariation()

double OptimProblem::getPenaltyVariation ( )
inline

Retrieves the control variation penalty term.

Returns
double Control variation penalty contribution

◆ getPenaltyWeightedCost()

double OptimProblem::getPenaltyWeightedCost ( )
inline

Retrieves the integral penalty term for weighted running cost.

Returns
double Penalty term contribution

◆ getRegul()

double OptimProblem::getRegul ( )
inline

Retrieves the Tikhonov regularization term.

Returns
double Tikhonov regularization contribution

◆ getSolution()

void OptimProblem::getSolution ( Vec *  opt)

Retrieves the optimization solution and prints summary information.

This method should be called after TaoSolve() has finished.

Parameters
optPointer to vector to store the optimal solution

◆ getStartingPoint()

void OptimProblem::getStartingPoint ( Vec  x)

Computes initial guess for optimization variables.

Parameters
xVector to store the initial guess

◆ getTolFinalCost()

double OptimProblem::getTolFinalCost ( )
inline

Retrieves the objective function tolerance.

Returns
double Absolute tolerance for objective function convergence

◆ getTolGradAbs()

double OptimProblem::getTolGradAbs ( )
inline

Retrieves the gradient tolerance.

Returns
double Absolute tolerance for gradient norm convergence

◆ getTolInfidelity()

double OptimProblem::getTolInfidelity ( )
inline

Retrieves the infidelity tolerance.

Returns
double Tolerance for infidelity convergence

◆ solve()

void OptimProblem::solve ( Vec  xinit)

Runs the optimization solver.

Parameters
xinitInitial guess for design variables

Member Data Documentation

◆ comm_init

MPI_Comm OptimProblem::comm_init
protected

MPI communicator for initial condition parallelization.

◆ comm_optim

MPI_Comm OptimProblem::comm_optim
protected

MPI communicator for optimization parallelization, currently not used (size 1)

◆ fidelity

double OptimProblem::fidelity
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.

◆ gamma_penalty_dpdm

double OptimProblem::gamma_penalty_dpdm
protected

Parameter multiplying integral penalty term for 2nd derivative of state variation.

◆ gamma_penalty_energy

double OptimProblem::gamma_penalty_energy
protected

Parameter multiplying energy penalty.

◆ gamma_penalty_leakage

double OptimProblem::gamma_penalty_leakage
protected

Parameter multiplying integral leakage term.

◆ gamma_penalty_variation

double OptimProblem::gamma_penalty_variation
protected

Parameter multiplying finite-difference squared regularization term.

◆ gamma_penalty_weightedcost

double OptimProblem::gamma_penalty_weightedcost
protected

Parameter multiplying integral weighted cost function.

◆ gamma_tikhonov

double OptimProblem::gamma_tikhonov
protected

Parameter for Tikhonov regularization.

◆ gnorm

double OptimProblem::gnorm
protected

Current norm of gradient.

◆ maxiter

int OptimProblem::maxiter
protected

Stopping criterion based on maximum number of iterations.

◆ mpirank_init

int OptimProblem::mpirank_init
protected

◆ mpirank_optim

int OptimProblem::mpirank_optim
protected

◆ mpirank_petsc

int OptimProblem::mpirank_petsc
protected

◆ mpirank_world

int OptimProblem::mpirank_world
protected

◆ mpisize_init

int OptimProblem::mpisize_init
protected

MPI rank and size for initial condition communicator.

◆ mpisize_optim

int OptimProblem::mpisize_optim
protected

MPI rank and size for optimization communicator.

◆ mpisize_petsc

int OptimProblem::mpisize_petsc
protected

MPI rank and size for spatial parallelization (PETSc)

◆ mpisize_world

int OptimProblem::mpisize_world
protected

MPI rank and size for global communicator.

◆ mygrad

double* OptimProblem::mygrad
protected

Auxiliary gradient storage.

◆ ndesign

int OptimProblem::ndesign
protected

Number of global design (optimization) parameters.

◆ ninit

size_t OptimProblem::ninit
protected

Number of initial conditions to be considered (N^2, N, or 1)

◆ ninit_local

int OptimProblem::ninit_local
protected

Local number of initial conditions on this processor.

◆ obj_cost

double OptimProblem::obj_cost
protected

Final-time measure J(T) in objective.

◆ obj_penal_dpdm

double OptimProblem::obj_penal_dpdm
protected

Penalty term second-order state derivatives (penalizes variations of the state evolution)

◆ obj_penal_energy

double OptimProblem::obj_penal_energy
protected

Energy penalty term in objective.

◆ obj_penal_leakage

double OptimProblem::obj_penal_leakage
protected

Penalty term for leakage into guard levels.

◆ obj_penal_variation

double OptimProblem::obj_penal_variation
protected

Penalty term for variation of control parameters.

◆ obj_penal_weightedcost

double OptimProblem::obj_penal_weightedcost
protected

Penalty term for weighted running cost.

◆ obj_regul

double OptimProblem::obj_regul
protected

Regularization term in objective.

◆ obj_weights

std::vector<double> OptimProblem::obj_weights
protected

Weights for averaging objective over initial conditions.

◆ objective

double OptimProblem::objective
protected

Current objective function value (sum over final-time cost, regularization terms and penalty terms)

◆ optim_target

OptimTarget* OptimProblem::optim_target
protected

Pointer to the optimization target (gate or state)

◆ output

Output* OptimProblem::output

Pointer to output handler.

◆ quietmode

bool OptimProblem::quietmode
protected

Flag for quiet mode operation.

◆ rho_t0

Vec OptimProblem::rho_t0
protected

Storage for initial condition of the ODE.

◆ rho_t0_bar

Vec OptimProblem::rho_t0_bar
protected

Storage for adjoint initial condition of the adjoint ODE (aka the terminal condition)

◆ store_finalstates

std::vector<Vec> OptimProblem::store_finalstates
protected

Storage for final states for each initial condition.

◆ tao

Tao OptimProblem::tao
protected

PETSc's TAO optimization solver.

◆ tikhonov_use_x0

bool OptimProblem::tikhonov_use_x0
protected

Switch to use ||x - x0||^2 for Tikhonov regularization instead of ||x||^2.

◆ timestepper

TimeStepper* OptimProblem::timestepper

Pointer to time-stepping scheme.

◆ tol_final_cost

double OptimProblem::tol_final_cost
protected

Stopping criterion based on objective function value.

◆ tol_grad_abs

double OptimProblem::tol_grad_abs
protected

Stopping criterion based on absolute gradient norm.

◆ tol_grad_rel

double OptimProblem::tol_grad_rel
protected

Stopping criterion based on relative gradient norm.

◆ tol_infidelity

double OptimProblem::tol_infidelity
protected

Stopping criterion based on infidelity.

◆ xinit

Vec OptimProblem::xinit

Initial design vector.

◆ xlower

Vec OptimProblem::xlower

◆ xprev

Vec OptimProblem::xprev

Design vector at previous iteration.

◆ xtmp

Vec OptimProblem::xtmp
protected

Temporary vector storage.

◆ xupper

Vec OptimProblem::xupper

Lower and upper bounds for optimization variables.


The documentation for this class was generated from the following files: