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

Optimization target specification for quantum control. More...

#include <optimtarget.hpp>

Collaboration diagram for OptimTarget:
Collaboration graph
[legend]

Public Member Functions

 OptimTarget ()
 
 OptimTarget (const Config &config, MasterEq *mastereq, double total_time, Vec rho_t0, bool quietmode_)
 Constructor with full target specification.
 
 ~OptimTarget ()
 
ObjectiveType getObjectiveType ()
 Retrieves the objective function type.
 
int prepareInitialState (const int iinit, const int ninit, const std::vector< size_t > &nlevels, const std::vector< size_t > &nessential, Vec rho0)
 Prepares the initial condition state.
 
void prepareTargetState (const Vec rho)
 Prepares the target state for gate optimization.
 
void evalJ (const Vec state, double *J_re_ptr, double *J_im_ptr)
 Evaluates the final-time objective function measure \(J(\rho(T))\).
 
void evalJ_diff (const Vec state, Vec statebar, const double J_re_bar, const double J_im_bar)
 Computes derivative of the final-time objective function measure.
 
double finalizeJ (const double obj_cost_re, const double obj_cost_im)
 Finalizes the objective function computation.
 
void finalizeJ_diff (const double obj_cost_re, const double obj_cost_im, double *obj_cost_re_bar, double *obj_cost_im_bar)
 Derivative of objective function finalization.
 
double FrobeniusDistance (const Vec state)
 Computes Frobenius distance between target and current state.
 
void FrobeniusDistance_diff (const Vec state, Vec statebar, const double Jbar)
 Derivative of Frobenius distance computation.
 
void HilbertSchmidtOverlap (const Vec state, const bool scalebypurity, double *HS_re_ptr, double *Hs_im_ptr)
 Computes Hilbert-Schmidt overlap between state and target.
 
void HilbertSchmidtOverlap_diff (Vec statebar, bool scalebypurity, const double HS_re_bar, const double HS_im_bar)
 Derivative of Hilbert-Schmidt overlap computation.
 

Protected Attributes

PetscInt dim
 State dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger.
 
PetscInt dim_rho
 Dimension of Hilbert space = N.
 
PetscInt dim_ess
 Dimension of essential level system = N_e.
 
int noscillators
 Number of oscillators in the system.
 
TargetType target_type
 Type of optimization target (product state preparation or gate optimization)
 
ObjectiveType objective_type
 Type of objective function measure (Frobenius, trace, product-state measure)
 
Gatetargetgate
 Pointer to target gate (if gate optimization)
 
double purity_rho0
 Purity of initial state Tr(rho(0)^2)
 
PetscInt purestateID
 For product state preparation: integer m for preparing the target state \( e_m e_m^{\dagger}\).
 
Vec targetstate
 Storage for the target state vector (NULL for product states, \(V\rho V^\dagger\) for gates, density matrix from file)
 
InitialConditionSettings initcond
 Initial conditions.
 
DecoherenceType decoherence_type
 Type of Lindblad decoherence operators, or NONE for Schroedinger solver.
 
int mpisize_petsc
 Size of PETSc communicator.
 
int mpirank_petsc
 Rank of PETSc communicator.
 
PetscInt localsize_u
 Size of local sub vector u or v in state x=[u,v].
 
PetscInt ilow
 First index of the local sub vector u,v.
 
PetscInt iupp
 Last index (+1) of the local sub vector u,v.
 
Vec aux
 Auxiliary vector for gate optimization objective computation.
 
bool quietmode
 Flag for quiet mode operation.
 

Detailed Description

Optimization target specification for quantum control.

This class manages the target specification for quantum optimal control problems, including gate optimization and product state preparation. It handles target and initial state preparation and the evaluation of the final-time objective function measure.

Main functionality:

This class contains references to:

Constructor & Destructor Documentation

◆ OptimTarget() [1/2]

OptimTarget::OptimTarget ( )

◆ OptimTarget() [2/2]

OptimTarget::OptimTarget ( const Config config,
MasterEq mastereq,
double  total_time,
Vec  rho_t0,
bool  quietmode_ 
)

Constructor with full target specification.

Parameters
configConfiguration parameters
mastereqPointer to master equation solver
total_timeTotal evolution time
rho_t0Initial state vector
quietmode_Flag for quiet operation

◆ ~OptimTarget()

OptimTarget::~OptimTarget ( )

Member Function Documentation

◆ evalJ()

void OptimTarget::evalJ ( const Vec  state,
double *  J_re_ptr,
double *  J_im_ptr 
)

Evaluates the final-time objective function measure \(J(\rho(T))\).

The target state must be prepared and stored before calling this function. Returns both real and imaginary parts of the final-time measure. The imaginary part is generally zero except for Schroedinger solver with the trace objective function measure.

Parameters
[in]stateCurrent state vector
[out]J_re_ptrPointer to store real part of objective
[out]J_im_ptrPointer to store imaginary part of objective

◆ evalJ_diff()

void OptimTarget::evalJ_diff ( const Vec  state,
Vec  statebar,
const double  J_re_bar,
const double  J_im_bar 
)

Computes derivative of the final-time objective function measure.

Updates the adjoint state vector for gradient computation.

Parameters
stateFinal-time state vector
statebarAdjoint state vector to update
J_re_barAdjoint of real part of objective
J_im_barAdjoint of imaginary part of objective

◆ finalizeJ()

double OptimTarget::finalizeJ ( const double  obj_cost_re,
const double  obj_cost_im 
)

Finalizes the objective function computation.

Compute the infidelity (1-fidelity).

Parameters
obj_cost_reReal part of objective cost
obj_cost_imImaginary part of objective cost
Returns
double Final objective function value

◆ finalizeJ_diff()

void OptimTarget::finalizeJ_diff ( const double  obj_cost_re,
const double  obj_cost_im,
double *  obj_cost_re_bar,
double *  obj_cost_im_bar 
)

Derivative of objective function finalization.

Parameters
[in]obj_cost_reReal part of objective cost
[in]obj_cost_imImaginary part of objective cost
[out]obj_cost_re_barPointer to store adjoint of real part
[out]obj_cost_im_barPointer to store adjoint of imaginary part

◆ FrobeniusDistance()

double OptimTarget::FrobeniusDistance ( const Vec  state)

Computes Frobenius distance between target and current state.

Calculates \(F = 1/2 || \rho_{target} - \rho||^2_F\)

Parameters
stateCurrent state vector
Returns
double Frobenius distance

◆ FrobeniusDistance_diff()

void OptimTarget::FrobeniusDistance_diff ( const Vec  state,
Vec  statebar,
const double  Jbar 
)

Derivative of Frobenius distance computation.

Parameters
stateCurrent state vector
statebarAdjoint state vector to update
JbarAdjoint seed

◆ getObjectiveType()

ObjectiveType OptimTarget::getObjectiveType ( )
inline

Retrieves the objective function type.

Returns
ObjectiveType Type of objective function

◆ HilbertSchmidtOverlap()

void OptimTarget::HilbertSchmidtOverlap ( const Vec  state,
const bool  scalebypurity,
double *  HS_re_ptr,
double *  Hs_im_ptr 
)

Computes Hilbert-Schmidt overlap between state and target.

Calculates \( Tr(\rho^\dagger \rho_{target})\), optionally scaled by the purity of the target state.

Parameters
stateCurrent state vector
scalebypurityFlag to scale by purity of target state
HS_re_ptrPointer to store real part of overlap
Hs_im_ptrPointer to store imaginary part of overlap

◆ HilbertSchmidtOverlap_diff()

void OptimTarget::HilbertSchmidtOverlap_diff ( Vec  statebar,
bool  scalebypurity,
const double  HS_re_bar,
const double  HS_im_bar 
)

Derivative of Hilbert-Schmidt overlap computation.

Parameters
statebarAdjoint state vector to update
scalebypurityFlag to scale by purity of target state
HS_re_barAdjoint of real part of overlap
HS_im_barAdjoint of imaginary part of overlap

◆ prepareInitialState()

int OptimTarget::prepareInitialState ( const int  iinit,
const int  ninit,
const std::vector< size_t > &  nlevels,
const std::vector< size_t > &  nessential,
Vec  rho0 
)

Prepares the initial condition state.

Parameters
iinitIndex in processor range [rank * ninit_local .. (rank+1) * ninit_local - 1]
ninitTotal number of initial conditions
nlevelsNumber of levels per oscillator
nessentialNumber of essential levels per oscillator
rho0Vector to store the initial condition
Returns
int Identifier for this initial condition (element number in matrix vectorization)

◆ prepareTargetState()

void OptimTarget::prepareTargetState ( const Vec  rho)

Prepares the target state for gate optimization.

For gate optimization, computes the rotated target state \(V \rho V^{\dagger}\) for a given initial state \(\rho\) and stores it locally as a class member. Also stores the purity of \(rho\) needed for scaling the Hilbert-Schmidt overlap in the trace objective function.

Parameters
rhoInitial state vector

Member Data Documentation

◆ aux

Vec OptimTarget::aux
protected

Auxiliary vector for gate optimization objective computation.

◆ decoherence_type

DecoherenceType OptimTarget::decoherence_type
protected

Type of Lindblad decoherence operators, or NONE for Schroedinger solver.

◆ dim

PetscInt OptimTarget::dim
protected

State dimension of full vectorized system: N^2 if Lindblad, N if Schroedinger.

◆ dim_ess

PetscInt OptimTarget::dim_ess
protected

Dimension of essential level system = N_e.

◆ dim_rho

PetscInt OptimTarget::dim_rho
protected

Dimension of Hilbert space = N.

◆ ilow

PetscInt OptimTarget::ilow
protected

First index of the local sub vector u,v.

◆ initcond

InitialConditionSettings OptimTarget::initcond
protected

Initial conditions.

◆ iupp

PetscInt OptimTarget::iupp
protected

Last index (+1) of the local sub vector u,v.

◆ localsize_u

PetscInt OptimTarget::localsize_u
protected

Size of local sub vector u or v in state x=[u,v].

◆ mpirank_petsc

int OptimTarget::mpirank_petsc
protected

Rank of PETSc communicator.

◆ mpisize_petsc

int OptimTarget::mpisize_petsc
protected

Size of PETSc communicator.

◆ noscillators

int OptimTarget::noscillators
protected

Number of oscillators in the system.

◆ objective_type

ObjectiveType OptimTarget::objective_type
protected

Type of objective function measure (Frobenius, trace, product-state measure)

◆ purestateID

PetscInt OptimTarget::purestateID
protected

For product state preparation: integer m for preparing the target state \( e_m e_m^{\dagger}\).

◆ purity_rho0

double OptimTarget::purity_rho0
protected

Purity of initial state Tr(rho(0)^2)

◆ quietmode

bool OptimTarget::quietmode
protected

Flag for quiet mode operation.

◆ target_type

TargetType OptimTarget::target_type
protected

Type of optimization target (product state preparation or gate optimization)

◆ targetgate

Gate* OptimTarget::targetgate
protected

Pointer to target gate (if gate optimization)

◆ targetstate

Vec OptimTarget::targetstate
protected

Storage for the target state vector (NULL for product states, \(V\rho V^\dagger\) for gates, density matrix from file)


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