Library
Constraints
DirectTrajOpt.Constraints.EqualityConstraint
— Typestruct EqualityConstraint
Represents 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
DirectTrajOpt.Constraints.EqualityConstraint
— MethodEqualityConstraint(
name::Symbol,
ts::Vector{Int},
val::Vector{Float64},
traj::NamedTrajectory;
label="equality constraint on trajectory variable [name]"
)
Constructs equality constraint for trajectory variable in NamedTrajectory
DirectTrajOpt.Constraints.GlobalEqualityConstraint
— MethodGlobalEqualityConstraint(
name::Symbol,
val::Vector{Float64},
traj::NamedTrajectory;
label="equality constraint on global variable [name]"
)::EqualityConstraint
Constructs equality constraint for global variable in NamedTrajectory
Integrators
DirectTrajOpt.Integrators.dense
— Methoddense(vals, structure, shape)
Convert sparse data to dense matrix.
Arguments
vals
: vector of valuesstructure
: vector of tuples of indicesshape
: tuple of matrix dimensions
DirectTrajOpt.Integrators.show_diffs
— Methodshow_diffs(A::Matrix, B::Matrix)
Show differences between matrices.
Objectives
DirectTrajOpt.Objectives.Objective
— TypeObjective
A structure for defining objective functions.
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
DirectTrajOpt.Objectives.GlobalObjective
— MethodGlobalObjective(
ℓ::Function,
global_names::AbstractVector{Symbol},
traj::NamedTrajectory;
kwargs...
)
GlobalObjective(
ℓ::Function,
global_name::Symbol,
traj::NamedTrajectory;
kwargs...
)
Create an objective that only involves the global components.
DirectTrajOpt.Objectives.KnotPointObjective
— MethodKnotPointObjective(
ℓ::Function,
names::AbstractVector{Symbol},
traj::NamedTrajectory,
params::AbstractVector;
kwargs...
)
KnotPointObjective(
ℓ::Function,
names::AbstractVector{Symbol},
traj::NamedTrajectory;
kwargs...
)
KnotPointObjective(
ℓ::Function,
name::Symbol,
args...;
kwargs...
)
Create a knot point summed objective function for trajectory optimization, where ℓ(x, p)
on trajectory knot point variables x
with parameters p
. If the parameters argument is omitted, ℓ(x)
is assumed to be a function of x
only.
Arguments
ℓ::Function
: Function that defines the objective, ℓ(x, p) or ℓ(x).names::AbstractVector{Symbol}
: Names of the trajectory variables to be optimized.traj::NamedTrajectory
: The trajectory on which the objective is defined.params::AbstractVector
: Parametersp
for the objective function ℓ, for each time.
Keyword Arguments
times::AbstractVector{Int}=1:traj.T
: Time indices at which the objective is evaluated.Qs::AbstractVector{Float64}=ones(traj.T)
: Weights for the objective function at each time.
DirectTrajOpt.Objectives.MinimumTimeObjective
— MethodMinimumTimeObjective
A type of objective that counts the time taken to complete a task. D
is a scaling factor.
DirectTrajOpt.Objectives.QuadraticRegularizer
— MethodQuadraticRegularizer
A quadratic regularizer for a trajectory component.
Fields: name
: the name of the trajectory component to regularize traj
: the trajectory R
: the regularization matrix diagonal baseline
: the baseline values for the trajectory component times
: the times at which to evaluate the regularizer
Dynamics
DirectTrajOpt.Dynamics.TrajectoryDynamics
— TypeTrajectoryDynamics
A struct for trajectory optimization dynamics, represented by integrators that compute single time step dynamics, and functions for jacobians and hessians.
Fields
integrators::Union{Nothing, Vector{<:AbstractIntegrator}}
: Vector of integrators.F!::Function
: Function to compute trajectory dynamics.∂F!::Function
: Function to compute the Jacobian of the dynamics.∂fs::Vector{SparseMatrixCSC{Float64, Int}}
: Vector of Jacobian matrices.μ∂²F!::Union{Function, Nothing}
: Function to compute the Hessian of the Lagrangian.μ∂²fs::Vector{SparseMatrixCSC{Float64, Int}}
: Vector of Hessian matrices.dim::Int
: Total dimension of the dynamics.
Problems
DirectTrajOpt.Problems.DirectTrajOptProblem
— Typemutable struct DirectTrajOptProblem <: AbstractProblem
Stores all the information needed to set up and solve a DirectTrajOptProblem as well as the solution after the solver terminates.
Fields
optimizer::Ipopt.Optimizer
: Ipopt optimizer object
DirectTrajOpt.Problems.get_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.
Problem Solvers
Problem Solvers
DirectTrajOpt.IpoptSolverExt.IpoptOptions
— TypeSolver options for Ipopt
https://coin-or.github.io/Ipopt/OPTIONS.html#OPT_print_options_documentation
DirectTrajOpt.Solvers.solve!
— Methodsolve!(prob::DirectTrajOptProblem; 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::DirectTrajOptProblem
: 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.callback::Function
: Callback function to call during optimization steps.