Skip to content

Commit 5a2e50b

Browse files
SebastianM-Cclaude
andcommitted
Document function-valued initial trajectories
Add a tutorial section covering the `initial_trajectory` keyword: the map-from-states-to-functions form, that unlisted states keep their constant `u0map` seed, backend support (JuMP, InfiniteOpt, CasADi), and the normalized `[0, 1]` time base used for free final time problems. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 509a9fe commit 5a2e50b

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

docs/src/tutorials/dynamic_optimization.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,33 @@ axislegend(ax2)
6868
fig
6969
```
7070

71+
### Providing an initial trajectory
72+
73+
By default every state variable is seeded with its constant value from `u0map` at
74+
each collocation point. When that starting point is a poor one, the solver can be
75+
given a guess of the whole trajectory instead. The `initial_trajectory` keyword
76+
takes a map from states to functions of time:
77+
78+
```@example dynamic_opt
79+
jprob_guess = JuMPDynamicOptProblem(rocket, [u0map; pmap], (ts, te); dt = 0.001,
80+
initial_trajectory = Dict(h(t) => τ -> 1 + τ, v(t) => τ -> 1.0))
81+
jsol_guess = solve(jprob_guess, JuMPCollocation(Ipopt.Optimizer));
82+
```
83+
84+
Each function is evaluated at the collocation points to produce the start values
85+
handed to the optimizer. Only the states listed are affected — the rest keep their
86+
constant seed. This changes where the solve starts from, not the optimum it
87+
converges to.
88+
89+
`initial_trajectory` is supported by the JuMP, InfiniteOpt, and CasADi backends.
90+
Passing a non-empty map to Pyomo raises an `ArgumentError`.
91+
92+
!!! note
93+
94+
For free final time problems (see below) the collocation grid is normalized to
95+
`[0, 1]`, so the trajectory functions receive normalized time rather than
96+
physical time.
97+
7198
### Free final time problems
7299

73100
There are additionally a class of dynamic optimization problems where we would like to know how to control our system to achieve something in the least time. Such problems are called free final time problems, since the final time is unknown. To model these problems in ModelingToolkit, we declare the final time as a parameter.

0 commit comments

Comments
 (0)