Library

Constraints

QuantumCollocationCore.Constraints.EqualityConstraintType
struct EqualityConstraint

Represents a linear equality constraint.

Fields

  • ts::AbstractArray{Int}: the time steps at which the constraint is applied
  • js::AbstractArray{Int}: the components of the trajectory at which the constraint is applied
  • vals::Vector{R}: the values of the constraint
  • vardim::Int: the dimension of a single time step of the trajectory
  • label::String: a label for the constraint
source
QuantumCollocationCore.Constraints.NonlinearEqualityConstraintType
struct NonlinearEqualityConstraint

Represents a nonlinear equality constraint.

Fields

  • g::Function: the constraint function
  • ∂g::Function: the Jacobian of the constraint function
  • ∂g_structure::Vector{Tuple{Int, Int}}: the structure of the Jacobian i.e. all non-zero entries
  • μ∂²g::Function: the Hessian of the constraint function
  • μ∂²g_structure::Vector{Tuple{Int, Int}}: the structure of the Hessian
  • dim::Int: the dimension of the constraint function
  • params::Dict{Symbol, Any}: a dictionary of parameters
source
QuantumCollocationCore.Constraints.NonlinearInequalityConstraintType
struct NonlinearInequalityConstraint

Represents a nonlinear inequality constraint.

Fields

  • g::Function: the constraint function
  • ∂g::Function: the Jacobian of the constraint function
  • ∂g_structure::Vector{Tuple{Int, Int}}: the structure of the Jacobian i.e. all non-zero entries
  • μ∂²g::Function: the Hessian of the constraint function
  • μ∂²g_structure::Vector{Tuple{Int, Int}}: the structure of the Hessian
  • dim::Int: the dimension of the constraint function
  • params::Dict{Symbol, Any}: a dictionary of parameters containing additional information about the constraint
source
QuantumCollocationCore.Constraints.ComplexModulusContraintMethod
ComplexModulusContraint(<keyword arguments>)

Returns a NonlinearInequalityConstraint on the complex modulus of a complex control

TODO: Changed zdim -> dim. Constraint should be tested for global params.

Arguments

  • R::Union{Float64,Nothing}=nothing: the maximum allowed complex modulus
  • comps::Union{AbstractVector{Int},Nothing}=nothing: the components of the complex control, both the real and imaginary parts
  • times::Union{AbstractVector{Int},Nothing}=nothing: the times at which the constraint is applied
  • dim::Union{Int,Nothing}=nothing: the dimension of a single time step of the trajectory
  • T::Union{Int,Nothing}=nothing: the number of time steps
source
QuantumCollocationCore.Constraints.FinalFidelityConstraintMethod
FinalFidelityConstraint(<keyword arguments>)

Returns a NonlinearInequalityConstraint representing a constraint on the minimum allowed fidelity.

Arguments

  • fidelity_function::Union{Function,Nothing}=nothing: the fidelity function
  • value::Union{Float64,Nothing}=nothing: the minimum fidelity value allowed by the constraint
  • comps::Union{AbstractVector{Int},Nothing}=nothing: the components of the state to which the fidelity function is applied
  • goal::Union{AbstractVector{Float64},Nothing}=nothing: the goal state
  • statedim::Union{Int,Nothing}=nothing: the dimension of the state
  • zdim::Union{Int,Nothing}=nothing: the dimension of a single time step of the trajectory
  • T::Union{Int,Nothing}=nothing: the number of time steps
  • subspace::Union{AbstractVector{<:Integer}, Nothing}=nothing: the subspace indices of the fidelity
source
QuantumCollocationCore.Constraints.constrain!Method
constrain!(opt::Ipopt.Optimizer, vars::Vector{MOI.VariableIndex}, cons::Vector{LinearConstraint}, traj::NamedTrajectory; verbose=false)

Supplies a set of LinearConstraints to IPOPT using MathOptInterface

source

Integrators

QuantumCollocationCore.Integrators.UnitaryPadeIntegratorMethod
UnitaryPadeIntegrator(
    unitary_name::Symbol,
    drive_name::Union{Symbol,Tuple{Vararg{Symbol}}},
    G::Function,
    ∂G::Function,
    traj::NamedTrajectory;
    order::Int=4,
    calculate_pade_operators_structure::Bool=true,
    autodiff::Bool=false
)

Construct a UnitaryPadeIntegrator which computes

\[\text{isovec}\qty(B^{(n)}(a_t) U_{t+1} - F^{(n)}(a_t) U_t)\]

where U_t is the unitary at time t, a_t is the control at time t, and B^{(n)}(a_t) and F^{(n)}(a_t) are the nth order Pade operators of the exponential of the drift operator G(a_t).

Arguments

  • unitary_name::Symbol: the name of the unitary in the trajectory
  • drive_name::Union{Symbol,Tuple{Vararg{Symbol}}}: the name of the drive(s) in the trajectory
  • G::Function: a function which takes the control vector a_t and returns the drive G(a_t), $G(a_t) = \text{iso}(-i H(a_t))$
  • ∂G::Function: a function which takes the control vector a_t and returns a vector of matrices $\qty(\ldots, \pdv{G}{a^j_t}, \ldots)$
  • traj::NamedTrajectory: the trajectory

Keyword Arguments

  • order::Int=4: the order of the Pade approximation. Must be in [4, 6, 8, 10, 12, 14, 16, 18, 20].
source

Losses

QuantumCollocationCore.Losses.iso_vec_unitary_fidelityMethod
iso_vec_unitary_fidelity(Ũ⃗::AbstractVector, Ũ⃗_goal::AbstractVector)

Returns the fidelity between the isomorphic unitary vector $\vec{\widetilde{U}} \sim U \in SU(n)$ and the isomorphic goal unitary vector $\vec{\widetilde{U}}_{\text{goal}}$.

\[\begin{aligned} \mathcal{F}(\vec{\widetilde{U}}, \vec{\widetilde{U}}_{\text{goal}}) &= \frac{1}{n} \abs{\tr \qty(U_{\text{goal}}^\dagger U)} \\ &= \frac{1}{n} \sqrt{T_R^{2} + T_I^{2}} \end{aligned}\]

where $T_R = \langle \vec{\widetilde{U}}_{\text{goal}, R}, \vec{\widetilde{U}}_R \rangle + \langle \vec{\widetilde{U}}_{\text{goal}, I}, \vec{\widetilde{U}}_I \rangle$ and $T_I = \langle \vec{\widetilde{U}}_{\text{goal}, R}, \vec{\widetilde{U}}_I \rangle - \langle \vec{\widetilde{U}}_{\text{goal}, I}, \vec{\widetilde{U}}_R \rangle$.

source
QuantumCollocationCore.Losses.unitary_fidelityMethod
unitary_fidelity(U::Matrix, U_goal::Matrix; kwargs...)
unitary_fidelity(Ũ⃗::AbstractVector, Ũ⃗_goal::AbstractVector; kwargs...)

Calculate the fidelity between two unitary operators U and U_goal.

\[\mathcal{F}(U, U_{\text{goal}}) = \frac{1}{n} \abs{\tr \qty(U_{\text{goal}}^\dagger U)}\]

where $n$ is the dimension of the unitary operators.

Keyword Arguments

  • subspace::AbstractVector{Int}: The subspace to calculate the fidelity over.
source

Objectives

QuantumCollocationCore.Objectives.ObjectiveType
Objective

A structure for defining objective functions.

The terms field contains all the arguments needed to construct the objective function.

Fields: L: the objective function ∇L: the gradient of the objective function ∂²L: the Hessian of the objective function ∂²L_structure: the structure of the Hessian of the objective function terms: a vector of dictionaries containing the terms of the objective function

source
QuantumCollocationCore.Objectives.L1RegularizerMethod
L1Regularizer

Create an L1 regularizer for the trajectory component. The regularizer is defined as

\[J_{L1}(u) = \sum_t \abs{R \cdot u_t}\]

where (R) is the regularization matrix and (u_t) is the trajectory component at time (t).

source
QuantumCollocationCore.Objectives.PairwiseQuadraticRegularizerMethod
PairwiseQuadraticRegularizer

Create a pairwise quadratic regularizer for the trajectory component name with regularization strength R. The regularizer is defined as

\[ J_{v⃗}(u) = \sum_t \frac{1}{2} \Delta t_t^2 (v⃗_{1,t} - v⃗_{2,t})^T R (v⃗_{1,t} - v⃗_{2,t})\]

where $v⃗_{1}$ and $v⃗_{2}$ are selected by name1 and name2. The indices specify the appropriate block diagonal components of the direct sum vector v⃗.

TODO: Hessian not implemented

Fields: R: the regularization strength times: the time steps to apply the regularizer name1: the first name name2: the second name timestep_name: the symbol for the timestep eval_hessian: whether to evaluate the Hessian

source
QuantumCollocationCore.Objectives.PairwiseUnitaryRobustnessObjectiveMethod
PairwiseUnitaryRobustnessObjective(;
    H1::Union{AbstractPiccoloOperator, Nothing}=nothing,
    H2_error::Union{AbstractPiccoloOperator, Nothing}=nothing,
    symb1::Symbol=:Ũ⃗1,
    symb2::Symbol=:Ũ⃗2,
    eval_hessian::Bool=false,
)

Create a control objective which penalizes the sensitivity of the infidelity to the provided operators defined in the subspaces of the control dynamics, thereby realizing robust control.

source
QuantumCollocationCore.Objectives.QuadraticRegularizerMethod
QuadraticRegularizer

A quadratic regularizer for a trajectory component.

Fields: name: the name of the trajectory component to regularize times: the times at which to evaluate the regularizer dim: the dimension of the trajectory component R: the regularization matrix baseline: the baseline values for the trajectory component eval_hessian: whether to evaluate the Hessian of the regularizer timestep_name: the symbol for the timestep variable

source
QuantumCollocationCore.Objectives.QuadraticSmoothnessRegularizerMethod
QuadraticSmoothnessRegularizer

A quadratic smoothness regularizer for a trajectory component.

Fields: name: the name of the trajectory component to regularize times: the times at which to evaluate the regularizer R: the regularization matrix eval_hessian: whether to evaluate the Hessian of the regularizer

source
QuantumCollocationCore.Objectives.UnitaryFreePhaseInfidelityObjectiveMethod
UnitaryFreePhaseInfidelityObjective

A type of objective that measures the infidelity of a unitary operator to a target unitary operator, where the target unitary operator is allowed to have phases on qubit subspaces.

Fields: name: the name of the unitary operator in the trajectory global_name: the name of the global phase in the trajectory goal: the target unitary operator Q: a scaling factor eval_hessian: whether to evaluate the Hessian subspace: the subspace in which to evaluate the objective

source
QuantumCollocationCore.Objectives.UnitaryInfidelityObjectiveMethod
UnitaryInfidelityObjective

A type of objective that measures the infidelity of a unitary operator to a target unitary operator.

Fields: name: the name of the unitary operator in the trajectory goal: the target unitary operator Q: a scaling factor eval_hessian: whether to evaluate the Hessian subspace: the subspace in which to evaluate the objective

source
QuantumCollocationCore.Objectives.UnitaryRobustnessObjectiveMethod

UnitaryRobustnessObjective(; H::::Union{AbstractPiccoloOperator, Nothing}=nothing, eval_hessian::Bool=false, symb::Symbol=:Ũ⃗ )

Create a control objective which penalizes the sensitivity of the infidelity to the provided operator defined in the subspace of the control dynamics, thereby realizing robust control.

The control dynamics are

\[U_C(a)= \prod_t \exp{-i H_C(a_t)}\]

In the control frame, the H operator is (proportional to)

\[R_{Robust}(a) = \frac{1}{T \norm{H_e}_2} \sum_t U_C(a_t)^\dag H_e U_C(a_t) \Delta t\]

where we have adjusted to a unitless expression of the operator.

The robustness objective is

\[R_{Robust}(a) = \frac{1}{N} \norm{R}^2_F\]

where N is the dimension of the Hilbert space.

source

Dynamics

Options

QuantumCollocationCore.Options.PiccoloOptionsType
PiccoloOptions

Options for the Piccolo quantum optimal control library.

Fields

  • verbose::Bool = true: Print verbose output
  • verbose_evaluator::Bool = false: Print verbose output from the evaluator
  • free_time::Bool = true: Allow free time optimization
  • timesteps_all_equal::Bool = true: Use equal timesteps
  • integrator::Symbol = :pade: Integrator to use
  • pade_order::Int = 4: Order of the Pade approximation
  • rollout_integrator::Function = expv: Integrator to use for rollout
  • eval_hessian::Bool = false: Evaluate the Hessian
  • geodesic = true: Use the geodesic to initialize the optimization.
  • blas_multithreading::Bool = true: Use BLAS multithreading.
  • build_trajectory_constraints::Bool = true: Build trajectory constraints.
  • complex_control_norm_constraint_name::Union{Nothing, Symbol} = nothing: Name of the complex control norm constraint.
  • complex_control_norm_constraint_radius::Float64 = 1.0: Radius of the complex control norm constraint.
  • bound_state::Bool = false: Bound the state.
  • leakage_suppression::Bool = false: Suppress leakage.
  • R_leakage::Float64 = 1.0: Leakage suppression parameter.
  • free_phase_infidelity::Bool = false: Free phase infidelity.
  • phase_operators::Union{Nothing, AbstractVector{<:AbstractMatrix{<:Complex}}} = nothing: Phase operators.
  • phase_name::Symbol = :ϕ: Name of the phase.
source

Problem Solvers

QuantumCollocationCore.ProblemSolvers.solve!Method

solve!(prob::QuantumControlProblem; inittraj=nothing, savepath=nothing, maxiter=prob.ipoptoptions.maxiter, linearsolver=prob.ipoptoptions.linearsolver, printlevel=prob.ipoptoptions.printlevel, removeslackvariables=false, callback=nothing # statetype=:unitary, # print_fidelity=false, )

Call optimization solver to solve the quantum control problem with parameters and callbacks.

Arguments

  • prob::QuantumControlProblem: The quantum control problem to solve.
  • init_traj::NamedTrajectory: Initial guess for the control trajectory. If not provided, a random guess will be generated.
  • save_path::String: Path to save the problem after optimization.
  • max_iter::Int: Maximum number of iterations for the optimization solver.
  • linear_solver::String: Linear solver to use for the optimization solver (e.g., "mumps", "paradiso", etc).
  • print_level::Int: Verbosity level for the solver.
  • remove_slack_variables::Bool: Remove slack variables from the trajectory after optimization.
  • callback::Function: Callback function to call during optimization steps.
source

Problems

QuantumCollocationCore.Problems.QuantumControlProblemType
mutable struct QuantumControlProblem <: AbstractProblem

Stores all the information needed to set up and solve a QuantumControlProblem as well as the solution after the solver terminates.

Fields

  • optimizer::Ipopt.Optimizer: Ipopt optimizer object
source

Saving and Loading