Library

Constraints

DirectTrajOpt.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
DirectTrajOpt.Constraints.EqualityConstraintMethod
EqualityConstraint(
    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

source
DirectTrajOpt.Constraints.GlobalEqualityConstraintMethod
GlobalEqualityConstraint(
    name::Symbol,
    val::Vector{Float64},
    traj::NamedTrajectory;
    label="equality constraint on global variable [name]"
)::EqualityConstraint

Constructs equality constraint for global variable in NamedTrajectory

source

Integrators

DirectTrajOpt.Integrators.denseMethod
dense(vals, structure, shape)

Convert sparse data to dense matrix.

Arguments

  • vals: vector of values
  • structure: vector of tuples of indices
  • shape: tuple of matrix dimensions
source

Objectives

DirectTrajOpt.Objectives.ObjectiveType
Objective

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

source
DirectTrajOpt.Objectives.GlobalObjectiveMethod
GlobalObjective(
    ℓ::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.

source
DirectTrajOpt.Objectives.KnotPointObjectiveMethod
KnotPointObjective(
    ℓ::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: Parameters p 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.
source
DirectTrajOpt.Objectives.QuadraticRegularizerMethod
QuadraticRegularizer

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

source

Dynamics

DirectTrajOpt.Dynamics.TrajectoryDynamicsType
TrajectoryDynamics

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.
source

Problems

DirectTrajOpt.Problems.DirectTrajOptProblemType
mutable 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
source

Problem Solvers

Problem Solvers

DirectTrajOpt.Solvers.solve!Method

solve!(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.
source