Parameters

NamedTrajectory.jl support passing parameters as a Tuple when construct a NamedTrajectory.

using NamedTrajectories

First we need to define number of timesteps and timestep

T = 10
dt = 0.1
0.1

then build named tuple of components and data matrices.

components = (
    x = rand(3, T),
    u = rand(2, T),
    Δt = fill(dt, 1, T),
)
(x = [0.9652913874095956 0.0035916419957325862 … 0.12376367587700454 0.03136136566663039; 0.1474343170345066 0.2971764965707071 … 0.423740634414848 0.5411570158796596; 0.6361910643057109 0.7821104096872857 … 0.09193525091987298 0.8595056463202243], u = [0.9037020603777506 0.41125793587075776 … 0.15117883247265196 0.8656703475186233; 0.8738294455051968 0.14042703194907025 … 0.9970351018377838 0.658718317644453], Δt = [0.1 0.1 … 0.1 0.1])

we must specify a timestep and control variable for the trajectory.

timestep = 0.1
control = :u
:u

some global params as a NamedTuple

params = (
    α = rand(1),
    β = rand(1)
)
(α = [0.13353909294239386], β = [0.5751730682588971])

we can now create a NamedTrajectory object with parameters specification.

traj = NamedTrajectory(components; timestep=timestep, controls=control, global_data=params)
NamedTrajectory{Float64}([0.9652913874095956 0.0035916419957325862 … 0.12376367587700454 0.03136136566663039; 0.1474343170345066 0.2971764965707071 … 0.423740634414848 0.5411570158796596; … ; 0.8738294455051968 0.14042703194907025 … 0.9970351018377838 0.658718317644453; 0.1 0.1 … 0.1 0.1], [0.9652913874095956, 0.1474343170345066, 0.6361910643057109, 0.9037020603777506, 0.8738294455051968, 0.1, 0.0035916419957325862, 0.2971764965707071, 0.7821104096872857, 0.41125793587075776  …  0.09193525091987298, 0.15117883247265196, 0.9970351018377838, 0.1, 0.03136136566663039, 0.5411570158796596, 0.8595056463202243, 0.8656703475186233, 0.658718317644453, 0.1], 10, 0.1, 6, (x = 3, u = 2, Δt = 1, states = 4, controls = 2), NamedTuple(), NamedTuple(), NamedTuple(), NamedTuple(), (x = 1:3, u = 4:5, Δt = 6:6, states = [1, 2, 3, 6], controls = [4, 5]), (α = [0.13353909294239386], β = [0.5751730682588971]), 2, (α = 1, β = 1), (α = 61:61, β = 62:62), (:x, :u, :Δt), (:x, :Δt), (:u,))

This page was generated using Literate.jl.