# Setting up free final time in JuMP optimization

**URL:** <https://discourse.julialang.org/t/setting-up-free-final-time-in-jump-optimization/107302>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [December 7, 2023, 8:59pm UTC](https://discourse.julialang.org/t/setting-up-free-final-time-in-jump-optimization/107302 "2023-12-07T20:59:54Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![A\_C](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@A\_C](https://discourse.julialang.org/u/A_C)\
**Post date:** [December 8, 2023, 3:44am UTC](https://discourse.julialang.org/t/setting-up-free-final-time-in-jump-optimization/107302/3 "2023-12-08T03:44:03Z")

</div>

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

```julia
@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:

```julia
@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:

```julia
@objective(model, Min, Δt)

```

You can also have a look at the RK4 code over [here](https://discourse.julialang.org/t/jump-user-defined-functions-with-vector-inputs-and-outputs/106025). 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.

---

_[View the full topic](https://discourse.julialang.org/t/setting-up-free-final-time-in-jump-optimization/107302)._
