API Reference
Corleone.ControlParameter — Type
struct ControlParameter{T, C, B}Implements a piecewise constant control discretization.
Fields
name: The name of the controlt: The timepoints at which discretized variables are introducedcontrols: The initial values for the controls. Either a vector or a function (rng,t,bounds) -> ubounds: The bounds as a tuple
Corleone.ControlParameter — Method
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.CorleoneDynamicOptProblem — Type
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 problemgetters: The getters which return the values of the trajectoryobjective: The objective functionconstraints: The constraint functionlcons: Lower bounds for the constraintsucons: Upper bounds for the constraints
Corleone.MultipleShootingLayer — Type
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 layershooting_intervals: The shooting intervalsensemble_alg: The ensemble algorithminitialization: The initialization scheme
Corleone.SingleShootingLayer — Type
struct SingleShootingLayer{P, A, C, B, PB, SI, PI} <: LuxCore.AbstractLuxLayerDefines 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 problemalgorithm: The algorithm with whichproblemis integrated.control_indices: Indices in parameters ofprobcorresponding to controlscontrols: The controlstunable_ic: Indices ofprob.u0which are degrees of freedombounds_ic: Bounds on the tunable initial conditions of the problemstate_initialization: Initialization of utunable_p: Indices ofprob.pwhich are degrees of freedom. This is derived from control_indices!bounds_p: Bounds on the tunable parameters of the problemparameter_initialization: Initialization of pquadrature_indices: Indices of differential states that are quadratures, i.e. they do not enter into the right hand side ofproblem
Note: The orders of both controls and control_indices, and bounds_ic and tunable_ic are assumed to be identical!
Corleone.SingleShootingLayer — Method
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 conditionsCorleone.Trajectory — Type
struct Trajectory{S, U, P, T, SH}The solution to an optimal control problem.
Fields
sys: The symbolic system used for SymbolicIndexingInterfaceu: The state trajectoryp: The parameter valuest: The timepointsshooting: The shooting valuesshooting_indices: The shooting indices
Note
If present, shooting_points contains a list of Tuples (timeseries_index, last_shooting_point).
Corleone.constant_initialization — Method
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
AbstractArrayjust sets the initial condition with the provided value. This assumes equal dimensionality.Dictassumes the keys represent indices of the initial condition.- A
VectororTupleofPairs assumes the first value represents an index of the initial condition.
Other options simply skip the corresponding interval.
Arguments
rng::Random.AbstractRNGa random number generatorshooting::MultipleShootingLayera shooting layer
Keyworded Arguments
psthe default parameters of theshootinglayer.u0the 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_initialization — Method
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
AbstractArrayjust sets the initial condition with the provided value. This assumes equal dimensionality.Dictassumes the keys represent indices of the initial condition.- A
VectororTupleofPairs assumes the first value represents an index of the initial condition.
Other options simply skip the corresponding interval.
Arguments
rng::Random.AbstractRNGa random number generatorshooting::MultipleShootingLayera shooting layer
Keyworded Arguments
psthe default parameters of theshootinglayer.u0sthe 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_initialization — Method
default_initialization
Initializes all shooting nodes with their default value, i.e., their initial value in the underlying problem.
Corleone.forward_initialization — Method
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.AbstractRNGa random number generatorshooting::MultipleShootingLayera shooting layer
Keyworded Arguments
psthe default parameters of theshootinglayer.
Corleone.get_block_structure — Function
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_structure — Method
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_initialization — Method
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.AbstractRNGa random number generatorshooting::MultipleShootingLayera shooting layerf::Pairs of the interval index and applied method
Keyworded Arguments
psthe default parameters of theshootinglayer.
All other keyworded arguments are passed on to the functions below.
Corleone.linear_initialization — Method
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.AbstractRNGa random number generatorshooting::MultipleShootingLayera shooting layer
Keyworded Arguments
psthe default parameters of theshootinglayer.u_infinity::AbstractArraythe value at the last timepoint for all states.
Corleone.random_initialization — Method
random_initialization(rng, shooting; ps, kwargs...)
Initializes all shooting nodes with random values.
Arguments
rng::Random.AbstractRNGa random number generatorshooting::MultipleShootingLayera shooting layer
Keyworded Arguments
psthe default parameters of theshootinglayer.
Corleone.shooting_constraints! — Method
shooting_constraints!(res, traj)
In-place version of shooting_constraints.
Corleone.shooting_constraints — Method
shooting_constraints(traj)
Returns the shooting violations sorted by states - parameters - controls and per-kind sorted by shooting-stage.
Corleone.stage_ordered_shooting_constraints! — Method
stage_ordered_shooting_constraints!(res, traj)
In-place version of stage_ordered_shooting_constraints.
Corleone.stage_ordered_shooting_constraints — Method
stage_ordered_shooting_constraints(traj)Returns the shooting violations sorted by shooting-stage and per-stage sorted by states - parameters - controls