Setting up free final time in JuMP optimization

Instead of defining Δt = 0.2 / T you can define Δt as a variable.

@variable(model, eps() <= Δt)

Note that the final time is tf = T*Δt
Since you want a specific final altitude this can be added as a constraint:

@constraint(model, x_h[T] == specific_altitude)

The objective to maximize thrust is a bit unclear. Since thrust is a trajectory what do you want to maximize? The 2 norm? Maybe what you want is to reach the specific_altitude in minimum time. In that case the objective function becomes:

@objective(model,  Min, Δt)

You can also have a look at the RK4 code over here. Note that it uses function tracing and solves the problem of Dubins vehicle travelling from one orientation to another in minimum time. With function tracing JuMP is nearly as powerful as CasADi to solve optimal control problems.

2 Likes