Library
Constraints
QuantumCollocationCore.Constraints.EqualityConstraint — Typestruct EqualityConstraintRepresents a linear equality constraint.
Fields
ts::AbstractArray{Int}: the time steps at which the constraint is appliedjs::AbstractArray{Int}: the components of the trajectory at which the constraint is appliedvals::Vector{R}: the values of the constraintvardim::Int: the dimension of a single time step of the trajectorylabel::String: a label for the constraint
QuantumCollocationCore.Constraints.NonlinearEqualityConstraint — Typestruct NonlinearEqualityConstraintRepresents 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 Hessiandim::Int: the dimension of the constraint functionparams::Dict{Symbol, Any}: a dictionary of parameters
QuantumCollocationCore.Constraints.NonlinearInequalityConstraint — Typestruct NonlinearInequalityConstraintRepresents 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 Hessiandim::Int: the dimension of the constraint functionparams::Dict{Symbol, Any}: a dictionary of parameters containing additional information about the constraint
QuantumCollocationCore.Constraints.ComplexModulusContraint — MethodComplexModulusContraint(symb::Symbol, R::Float64, traj::NamedTrajectory)Returns a ComplexModulusContraint for the complex control NamedTrajector symbol where R is the maximum allowed complex modulus.
QuantumCollocationCore.Constraints.ComplexModulusContraint — MethodComplexModulusContraint(<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 moduluscomps::Union{AbstractVector{Int},Nothing}=nothing: the components of the complex control, both the real and imaginary partstimes::Union{AbstractVector{Int},Nothing}=nothing: the times at which the constraint is applieddim::Union{Int,Nothing}=nothing: the dimension of a single time step of the trajectoryT::Union{Int,Nothing}=nothing: the number of time steps
QuantumCollocationCore.Constraints.FinalFidelityConstraint — MethodFinalFidelityConstraint(<keyword arguments>)Returns a NonlinearInequalityConstraint representing a constraint on the minimum allowed fidelity.
Arguments
fidelity_function::Union{Function,Nothing}=nothing: the fidelity functionvalue::Union{Float64,Nothing}=nothing: the minimum fidelity value allowed by the constraintcomps::Union{AbstractVector{Int},Nothing}=nothing: the components of the state to which the fidelity function is appliedgoal::Union{AbstractVector{Float64},Nothing}=nothing: the goal statestatedim::Union{Int,Nothing}=nothing: the dimension of the statezdim::Union{Int,Nothing}=nothing: the dimension of a single time step of the trajectoryT::Union{Int,Nothing}=nothing: the number of time stepssubspace::Union{AbstractVector{<:Integer}, Nothing}=nothing: the subspace indices of the fidelity
QuantumCollocationCore.Constraints.FinalQuantumStateFidelityConstraint — MethodFinalQuantumStateFidelityConstraint(statesymb::Symbol, val::Float64, traj::NamedTrajectory)Returns a FinalFidelityConstraint for the unitary fidelity function where statesymb is the NamedTrajectory symbol representing the unitary.
QuantumCollocationCore.Constraints.FinalUnitaryFidelityConstraint — MethodFinalUnitaryFidelityConstraint(statesymb::Symbol, val::Float64, traj::NamedTrajectory)Returns a FinalFidelityConstraint for the unitary fidelity function where statesymb is the NamedTrajectory symbol representing the unitary.
QuantumCollocationCore.Constraints.FinalUnitaryFreePhaseFidelityConstraint — MethodFinalUnitaryFreePhaseFidelityConstraintReturns a NonlinearInequalityConstraint representing a constraint on the minimum allowed fidelity for a free phase unitary.
QuantumCollocationCore.Constraints.constrain! — Methodconstrain!(opt::Ipopt.Optimizer, vars::Vector{MOI.VariableIndex}, cons::Vector{LinearConstraint}, traj::NamedTrajectory; verbose=false)Supplies a set of LinearConstraints to IPOPT using MathOptInterface
QuantumCollocationCore.Constraints.trajectory_constraints — Methodtrajectory_constraints(traj::NamedTrajectory)Implements the initial and final value constraints and bounds constraints on the controls and states as specified by traj.
Integrators
QuantumCollocationCore.Integrators.UnitaryPadeIntegrator — TypeQuantumCollocationCore.Integrators.UnitaryPadeIntegrator — MethodUnitaryPadeIntegrator(
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 trajectorydrive_name::Union{Symbol,Tuple{Vararg{Symbol}}}: the name of the drive(s) in the trajectoryG::Function: a function which takes the control vectora_tand returns the driveG(a_t), $G(a_t) = \text{iso}(-i H(a_t))$∂G::Function: a function which takes the control vectora_tand 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].
Losses
QuantumCollocationCore.Losses.iso_fidelity — Methodiso_fidelity(ψ̃, ψ̃_goal)Calculate the fidelity between two quantum states ψ and ψ_goal.
QuantumCollocationCore.Losses.iso_infidelity — Functioniso_infidelity(ψ̃, ψ̃goal)Returns the iso_infidelity between two quantum statevectors specified in the $\mathbb{C}^n \to \mathbb{R}^{2n}$ isomorphism space.
QuantumCollocationCore.Losses.iso_vec_unitary_fidelity — Methodiso_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$.
QuantumCollocationCore.Losses.unitary_fidelity — Methodunitary_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.
Objectives
QuantumCollocationCore.Objectives.Objective — TypeObjectiveA 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
QuantumCollocationCore.Objectives.L1Regularizer — MethodL1RegularizerCreate 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).
QuantumCollocationCore.Objectives.MinimumTimeObjective — MethodMinimumTimeObjectiveA type of objective that counts the time taken to complete a task.
Fields: D: a scaling factor Δt_indices: the indices of the time steps eval_hessian: whether to evaluate the Hessian
QuantumCollocationCore.Objectives.PairwiseQuadraticRegularizer — MethodPairwiseQuadraticRegularizerCreate 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
QuantumCollocationCore.Objectives.PairwiseQuadraticRegularizer — MethodPairwiseQuadraticRegularizerA convenience constructor for creating a PairwiseQuadraticRegularizer for the trajectory component name with regularization strength Rs over the graph graph.
QuantumCollocationCore.Objectives.PairwiseUnitaryRobustnessObjective — MethodPairwiseUnitaryRobustnessObjective(;
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.
QuantumCollocationCore.Objectives.QuadraticRegularizer — MethodQuadraticRegularizerA 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
QuantumCollocationCore.Objectives.QuadraticSmoothnessRegularizer — MethodQuadraticSmoothnessRegularizerA 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
QuantumCollocationCore.Objectives.QuantumObjective — MethodQuantumObjective
A generic objective function for quantum trajectories that use a loss.QuantumCollocationCore.Objectives.UnitaryFreePhaseInfidelityObjective — MethodUnitaryFreePhaseInfidelityObjectiveA 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
QuantumCollocationCore.Objectives.UnitaryInfidelityObjective — MethodUnitaryInfidelityObjectiveA 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
QuantumCollocationCore.Objectives.UnitaryRobustnessObjective — MethodUnitaryRobustnessObjective(; 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.
QuantumCollocationCore.Objectives.sparse_to_moi — Methodsparse_to_moi(A::SparseMatrixCSC)Converts a sparse matrix to tuple of vector of nonzero indices and vector of nonzero values
Dynamics
QuantumCollocationCore.Dynamics.QuantumDynamics — TypeQuantumDynamics <: AbstractDynamicsOptions
QuantumCollocationCore.Options.IpoptOptions — TypeSolver options for Ipopt
https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_print_options_documentationQuantumCollocationCore.Options.PiccoloOptions — TypePiccoloOptionsOptions for the Piccolo quantum optimal control library.
Fields
verbose::Bool = true: Print verbose outputverbose_evaluator::Bool = false: Print verbose output from the evaluatorfree_time::Bool = true: Allow free time optimizationtimesteps_all_equal::Bool = true: Use equal timestepsintegrator::Symbol = :pade: Integrator to usepade_order::Int = 4: Order of the Pade approximationrollout_integrator::Function = expv: Integrator to use for rollouteval_hessian::Bool = false: Evaluate the Hessiangeodesic = 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.
Problem Solvers
QuantumCollocationCore.ProblemSolvers.solve! — Methodsolve!(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.
Problems
QuantumCollocationCore.Problems.QuantumControlProblem — Typemutable struct QuantumControlProblem <: AbstractProblemStores 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
QuantumCollocationCore.Problems.get_constraints — Methodget_constraints(prob::QuantumControlProblem)Return the constraints of the prob::QuantumControlProblem.
QuantumCollocationCore.Problems.get_objective — Methodget_objective(prob::QuantumControlProblem)Return the objective function of the prob::QuantumControlProblem.