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.6548311286739178 0.30127482747248335 … 0.6776499955465715 0.5497236072695821; 0.6017454050003911 0.763092103916096 … 0.9072080462785488 0.6059396636330069; 0.9413062951441107 0.9904189627131713 … 0.14298468607896975 0.2699572296170236], u = [0.3062738905817741 0.18296584375899072 … 0.667870121789522 0.3364414900128587; 0.8339978461603134 0.12091454969325555 … 0.015000619656727165 0.2448750774019468], Δ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.6095457025966936], β = [0.6696548278288094])

we can now create a NamedTrajectory object with parameters specification.

traj = NamedTrajectory(components; timestep=timestep, controls=control, global_data=params)
NamedTrajectory{Float64}([0.6548311286739178 0.30127482747248335 … 0.6776499955465715 0.5497236072695821; 0.6017454050003911 0.763092103916096 … 0.9072080462785488 0.6059396636330069; … ; 0.8339978461603134 0.12091454969325555 … 0.015000619656727165 0.2448750774019468; 0.1 0.1 … 0.1 0.1], [0.6548311286739178, 0.6017454050003911, 0.9413062951441107, 0.3062738905817741, 0.8339978461603134, 0.1, 0.30127482747248335, 0.763092103916096, 0.9904189627131713, 0.18296584375899072  …  0.14298468607896975, 0.667870121789522, 0.015000619656727165, 0.1, 0.5497236072695821, 0.6059396636330069, 0.2699572296170236, 0.3364414900128587, 0.2448750774019468, 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.6095457025966936], β = [0.6696548278288094]), 2, (α = 1, β = 1), (α = 61:61, β = 62:62), (:x, :u, :Δt), (:x, :Δt), (:u,))

This page was generated using Literate.jl.