API Reference

Corleone.ControlParameterType
struct ControlParameter{T, C, B}

Implements a piecewise constant control discretization.

Fields

  • name: The name of the control

  • t: The timepoints at which discretized variables are introduced

  • controls: The initial values for the controls. Either a vector or a function (rng,t,bounds) -> u

  • bounds: The bounds as a tuple

Corleone.ControlParameterMethod
ControlParameter(t; name, controls, bounds)

Constructs a ControlParameter with piecewise constant discretizations introduced at timepoints t. Optionally

julia> ControlParameter(0:1.0:4.0, name=:c)
ControlParameter{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, typeof(Corleone.default_u), typeof(Corleone.default_bounds)}(:c, 0.0:1.0:10.0, Corleone.default_u, Corleone.default_bounds)
julia> ControlParameter(0.0:1.0:4.0, name=:c, controls = zeros(5))
ControlParameter{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Vector{Float64}, typeof(Corleone.default_bounds)}(:c, 0.0:1.0:4.0, [0.0, 0.0, 0.0, 0.0, 0.0], Corleone.default_bounds)
julia> ControlParameter(0:1.0:9.0, name=:c1, controls=zeros(5), bounds=(0.0,1.0))
ControlParameter{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Vector{Float64}, Tuple{Float64, Float64}}(:c1, 0.0:1.0:9.0, [0.0, 0.0, 0.0, 0.0, 0.0], (0.0, 1.0))

The latter is functionally equivalent to the following example, specifying all bounds individually:

julia> ControlParameter(0:1.0:9.0, name=:c1, controls=zeros(5), bounds=(zeros(5),ones(5)))
ControlParameter{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Vector{Float64}, Tuple{Vector{Float64}, Vector{Float64}}}(:c1, 0.0:1.0:9.0, [0.0, 0.0, 0.0, 0.0, 0.0], ([0.0, 0.0, 0.0, 0.0, 0.0], [1.0, 1.0, 1.0, 1.0, 1.0]))
Corleone.CorleoneDynamicOptProblemType
struct CorleoneDynamicOptProblem{L, G, O, C, CB}

A struct for capturing the internal definition of a dynamic optimization problem.

Fields

  • layer: The resulting layer for the problem

  • getters: The getters which return the values of the trajectory

  • objective: The objective function

  • constraints: The constraint function

  • lcons: Lower bounds for the constraints

  • ucons: Upper bounds for the constraints

Corleone.MultipleShootingLayerType
struct MultipleShootingLayer{L, I, E, Z} <: LuxCore.AbstractLuxWrapperLayer{:layer}

Defines a callable layer that integrates a differential equation using multiple shooting, i.e., the problem is lifted and integration is decoupled on disjunct time intervals given in shooting_intervals. Initial conditions on the shooting_intervals are degrees of freedom (except perhaps for the first layer), for which the initialization scheme initialization provides initial values. Parallelization is integration is possible, for which a suitable EnsembleAlgorithm can be specified with ensemble_alg.

Fields

  • layer: The original layer

  • shooting_intervals: The shooting intervals

  • ensemble_alg: The ensemble algorithm

  • initialization: The initialization scheme

Corleone.SingleShootingLayerType
struct SingleShootingLayer{P, A, C, B, PB, SI, PI} <: LuxCore.AbstractLuxLayer

Defines a callable layer that integrates the AbstractDEProblem problem using the specified algorithm. Controls are assumed to impact differential equation via its parameters problem.p at the positions indicated via control_indices and are itself specified via controls. Moreover, initial conditions problem.u0 that are degrees of freedom to be optimized can be specified by their indices via tunable_ic along with their upper and lower bounds via bounds_ic.

Fields

  • problem: The underlying differential equation problem

  • algorithm: The algorithm with which problem is integrated.

  • control_indices: Indices in parameters of prob corresponding to controls

  • controls: The controls

  • tunable_ic: Indices of prob.u0 which are degrees of freedom

  • bounds_ic: Bounds on the tunable initial conditions of the problem

  • state_initialization: Initialization of u

  • tunable_p: Indices of prob.p which are degrees of freedom. This is derived from control_indices!

  • bounds_p: Bounds on the tunable parameters of the problem

  • parameter_initialization: Initialization of p

  • quadrature_indices: Indices of differential states that are quadratures, i.e. they do not enter into the right hand side of problem

Note: The orders of both controls and control_indices, and bounds_ic and tunable_ic are assumed to be identical!

Corleone.SingleShootingLayerMethod
SingleShootingLayer(
    prob,
    alg;
    controls,
    tunable_ic,
    bounds_ic,
    state_initialization,
    bounds_p,
    parameter_initialization,
    quadrature_indices,
    kwargs...
)

Constructs a SingleShootingLayer from an AbstractDEProblem and a suitable AbstractDEAlgorithm alg.

Arguments

- `control_indices` : Vector of indices of `prob.p` that denote controls
- `controls`: Tuple of `ControlParameter` specifying the controls
- `tunable_ic`: Vector of indices of `prob.u0` that is tunable, i.e., a degree of freedom
- `bounds_ic` : Vector of tuples of lower and upper bounds of tunable initial conditions
Corleone.TrajectoryType
struct Trajectory{S, U, P, T, SH}

The solution to an optimal control problem.

Fields

  • sys: The symbolic system used for SymbolicIndexingInterface

  • u: The state trajectory

  • p: The parameter values

  • t: The timepoints

  • shooting: The shooting values

  • shooting_indices: The shooting indices

Note

If present, shooting_points contains a list of Tuples (timeseries_index, last_shooting_point).

Corleone.constant_initializationMethod
constant_initialization(rng, shooting; ps, u0, kwargs...)

Initializes all shooting nodes with user-provided value. The variable indices are interpreted depending on the passed value

  • AbstractArray just sets the initial condition with the provided value. This assumes equal dimensionality.
  • Dict assumes the keys represent indices of the initial condition.
  • A Vector or Tuple of Pairs assumes the first value represents an index of the initial condition.

Other options simply skip the corresponding interval.

Arguments

  • rng::Random.AbstractRNG a random number generator
  • shooting::MultipleShootingLayer a shooting layer

Keyworded Arguments

  • ps the default parameters of the shooting layer.
  • u0 the initial condition.

Example

# Assumes a shooting layer with 3 intervals
# Sets the first index of all intervals to 3.0
constant_initialization(rng, shooting, u0 = Dict(1 => 3.0))
constant_initialization(rng, shooting, u0 = (1 => 3.0,))
# Set the initial condition to the given vector
constant_initialization(rng, shooting, u0 = [1., 2., 4.])
Corleone.custom_initializationMethod
custom_initialization(rng, shooting; ps, u0s, kwargs...)

Initializes all shooting nodes with user-provided values. Initial values are given as an iterable collection of AbstractArrays, Dicts, or a vector of Pairs. The variable indices are interpreted depending on the passed value

  • AbstractArray just sets the initial condition with the provided value. This assumes equal dimensionality.
  • Dict assumes the keys represent indices of the initial condition.
  • A Vector or Tuple of Pairs assumes the first value represents an index of the initial condition.

Other options simply skip the corresponding interval.

Arguments

  • rng::Random.AbstractRNG a random number generator
  • shooting::MultipleShootingLayer a shooting layer

Keyworded Arguments

  • ps the default parameters of the shooting layer.
  • u0s the collection of initial conditions.

Example

# Assumes a shooting layer with 3 intervals
# Skips the first interval
# Sets the first index of the second interval to 3.0
# Sets the second index of the third interval to 5.0 and the 5th index to -1.0
custom_initialization(rng, shooting, u0s = [nothing, Dict(1 => 3.0), (2 => 5.0, 5 => -1.0)])
Corleone.default_initializationMethod

default_initialization

Initializes all shooting nodes with their default value, i.e., their initial value in the underlying problem.

Corleone.forward_initializationMethod
forward_initialization(
    rng,
    shooting;
    ps,
    fixed_indices,
    kwargs...
)

Initializes the problem using a forward solve of the problem. This results in a continuous trajectory.

Arguments

  • rng::Random.AbstractRNG a random number generator
  • shooting::MultipleShootingLayer a shooting layer

Keyworded Arguments

  • ps the default parameters of the shooting layer.
Corleone.get_block_structureFunction
get_block_structure(layer)
get_block_structure(layer, tspan, kwargs)

Compute the block structure of the hessian of the Lagrangian of an optimal control problem. As this is a SingleShootingLayer, this hessian is dense. See also $MultipleShootingLayer$.

Corleone.get_block_structureMethod
get_block_structure(mslayer)

Compute the block structure of the hessian of the Lagrangian of an optimal control problem as specified via the shooting_intervals of the MultipleShootingLayer. Note: Constraints other than the matching conditions of the multiple shooting approach are not considered here and might alter the block structure.

Corleone.hybrid_initializationMethod
hybrid_initialization(rng, shooting, f; ps, kwargs...)

Initializes the shooting nodes in a hybrid method by applying the provided methods and indices f sequentially. Here we assume the structure interval => method for the initialization.

Arguments

  • rng::Random.AbstractRNG a random number generator
  • shooting::MultipleShootingLayer a shooting layer
  • f::Pairs of the interval index and applied method

Keyworded Arguments

  • ps the default parameters of the shooting layer.

All other keyworded arguments are passed on to the functions below.

Corleone.linear_initializationMethod
linear_initialization(
    rng,
    shooting;
    ps,
    u_infinity,
    kwargs...
)

Linearly interpolates u0 and u_inf for t with tspan[1] < t < tspan[2].

Arguments

  • rng::Random.AbstractRNG a random number generator
  • shooting::MultipleShootingLayer a shooting layer

Keyworded Arguments

  • ps the default parameters of the shooting layer.
  • u_infinity::AbstractArray the value at the last timepoint for all states.
Corleone.random_initializationMethod
random_initialization(rng, shooting; ps, kwargs...)

Initializes all shooting nodes with random values.

Arguments

  • rng::Random.AbstractRNG a random number generator
  • shooting::MultipleShootingLayer a shooting layer

Keyworded Arguments

  • ps the default parameters of the shooting layer.
Corleone.shooting_constraintsMethod
shooting_constraints(traj)

Returns the shooting violations sorted by states - parameters - controls and per-kind sorted by shooting-stage.