From 8b77906b93c29b44e2f35dea8a3bbe111f3afedc Mon Sep 17 00:00:00 2001 From: HediChennoufi Date: Wed, 14 Jan 2026 19:13:32 +0100 Subject: [PATCH 1/3] test new inits --- ext/OptimalControlModels/robot.jl | 2 +- ext/OptimalControlModels/space_shuttle.jl | 2 +- ext/OptimalControlModels/steering.jl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/OptimalControlModels/robot.jl b/ext/OptimalControlModels/robot.jl index 1bfe831a..72859325 100644 --- a/ext/OptimalControlModels/robot.jl +++ b/ext/OptimalControlModels/robot.jl @@ -117,7 +117,7 @@ function OptimalControlProblems.robot( end # initial guess - tf = 1 + tf = 9.1 xinit = t -> [ ρ_t0, diff --git a/ext/OptimalControlModels/space_shuttle.jl b/ext/OptimalControlModels/space_shuttle.jl index 2d6e6d25..c080a1bf 100644 --- a/ext/OptimalControlModels/space_shuttle.jl +++ b/ext/OptimalControlModels/space_shuttle.jl @@ -175,7 +175,7 @@ function OptimalControlProblems.space_shuttle( # initial guess: linear interpolation for h, v, gamma (NB. t0 = 0), constant for the rest # variable time step seems to be initialized at 1 in jump # note that ipopt will project the initial guess inside the bounds anyway. - tf_init = (tf_l+tf_u)/2 + tf_init = 2000.0 x_init = t -> [ h_t0 + (t - t0) / (tf_init - t0) * (h_tf - h_t0), diff --git a/ext/OptimalControlModels/steering.jl b/ext/OptimalControlModels/steering.jl index 36aeabff..a1539e56 100644 --- a/ext/OptimalControlModels/steering.jl +++ b/ext/OptimalControlModels/steering.jl @@ -85,7 +85,7 @@ function OptimalControlProblems.steering( end end xinit = t -> [gen_x0(t, i) for i in 1:4] - init = (state=xinit, control=0, variable=1) + init = (state=xinit, control=0, variable=0.6) # discretise the optimal control problem docp = direct_transcription( From 7c85b59422a0aa9629e0c31b4b24905ea5a5dfde Mon Sep 17 00:00:00 2001 From: HediChennoufi Date: Wed, 21 Jan 2026 22:10:43 +0100 Subject: [PATCH 2/3] test2 inits sshuttle steering robot glider --- ext/JuMPModels/glider.jl | 2 +- ext/JuMPModels/robot.jl | 2 +- ext/JuMPModels/space_shuttle.jl | 2 +- ext/JuMPModels/steering.jl | 2 +- ext/OptimalControlModels/glider.jl | 13 ++++++++----- ext/OptimalControlModels/space_shuttle.jl | 2 +- ext/OptimalControlModels_s/glider_s.jl | 12 ++++++++---- ext/OptimalControlModels_s/robot_s.jl | 2 +- ext/OptimalControlModels_s/space_shuttle_s.jl | 2 +- ext/OptimalControlModels_s/steering_s.jl | 2 +- 10 files changed, 24 insertions(+), 17 deletions(-) diff --git a/ext/JuMPModels/glider.jl b/ext/JuMPModels/glider.jl index 164600a7..c4b9bab5 100644 --- a/ext/JuMPModels/glider.jl +++ b/ext/JuMPModels/glider.jl @@ -76,7 +76,7 @@ function OptimalControlProblems.glider( @variables( model, begin - tf ≥ tf_l, (start = 1) + tf ≥ tf_l, (start = 60) x[k = 0:N] ≥ x_l, (start = x_t0 + vx_t0 * k / N) y[k = 0:N], (start = y_t0 + (k / N) * (y_tf - y_t0)) vx[k = 0:N] ≥ vx_l, (start = vx_t0) diff --git a/ext/JuMPModels/robot.jl b/ext/JuMPModels/robot.jl index 79bfadc0..a77ffe80 100644 --- a/ext/JuMPModels/robot.jl +++ b/ext/JuMPModels/robot.jl @@ -104,7 +104,7 @@ function OptimalControlProblems.robot( uθ_l ≤ uθ[0:N] ≤ uθ_u, (start = 0) uϕ_l ≤ uϕ[0:N] ≤ uϕ_u, (start = 0) - tf ≥ tf_l, (start = 1) + tf ≥ tf_l, (start = 9.1) end ) diff --git a/ext/JuMPModels/space_shuttle.jl b/ext/JuMPModels/space_shuttle.jl index 0479eebf..17a16cd5 100644 --- a/ext/JuMPModels/space_shuttle.jl +++ b/ext/JuMPModels/space_shuttle.jl @@ -184,7 +184,7 @@ function OptimalControlProblems.space_shuttle( set_start_value.(model[:ψ], vec(initial_guess[:, 6])) set_start_value.(model[:α], vec(initial_guess[:, 7])) set_start_value.(model[:β], vec(initial_guess[:, 8])) - set_start_value.(model[:tf], (tf_l+tf_u)/2) + set_start_value.(model[:tf], 0.5) ####### # Functions to restore `h` and `v` to their true scale @expression(model, h[j = 0:N], scaled_h[j] * scaling_h) diff --git a/ext/JuMPModels/steering.jl b/ext/JuMPModels/steering.jl index cd40af69..8554cc42 100644 --- a/ext/JuMPModels/steering.jl +++ b/ext/JuMPModels/steering.jl @@ -51,7 +51,7 @@ function OptimalControlProblems.steering( x₄_tf = params[:x₄_tf] # - tf_start = 1 + tf_start = 0.6 function gen_x0(k, i) if i == 1 || i == 4 return 0.0 diff --git a/ext/OptimalControlModels/glider.jl b/ext/OptimalControlModels/glider.jl index d91059be..c0836c2f 100644 --- a/ext/OptimalControlModels/glider.jl +++ b/ext/OptimalControlModels/glider.jl @@ -110,11 +110,14 @@ function OptimalControlProblems.glider( end # initial guess - tfinit = 1 - xinit = - t -> [x_t0 + vx_t0 * t / tfinit, y_t0 + t / tfinit * (y_tf - y_t0), vx_t0, vy_t0] - uinit = cL_max / 2 - init = (state=xinit, control=uinit, variable=tfinit) + tfinit = 60.0 + xinit = t -> [ + x_t0 + vx_t0 * t, + y_t0 + (t / tfinit) * (y_tf - y_t0), + vx_t0 + (t / tfinit) * (vx_tf - vx_t0), + vy_t0 + (t / tfinit) * (vy_tf - vy_t0) + ] + uinit = (cL_min + cL_max) / 2 # discretise the optimal control problem docp = direct_transcription( diff --git a/ext/OptimalControlModels/space_shuttle.jl b/ext/OptimalControlModels/space_shuttle.jl index c080a1bf..08bcb59b 100644 --- a/ext/OptimalControlModels/space_shuttle.jl +++ b/ext/OptimalControlModels/space_shuttle.jl @@ -175,7 +175,7 @@ function OptimalControlProblems.space_shuttle( # initial guess: linear interpolation for h, v, gamma (NB. t0 = 0), constant for the rest # variable time step seems to be initialized at 1 in jump # note that ipopt will project the initial guess inside the bounds anyway. - tf_init = 2000.0 + tf_init = 0.5 x_init = t -> [ h_t0 + (t - t0) / (tf_init - t0) * (h_tf - h_t0), diff --git a/ext/OptimalControlModels_s/glider_s.jl b/ext/OptimalControlModels_s/glider_s.jl index 59cd87e7..159a0a0d 100644 --- a/ext/OptimalControlModels_s/glider_s.jl +++ b/ext/OptimalControlModels_s/glider_s.jl @@ -104,10 +104,14 @@ function OptimalControlProblems.glider_s( end # initial guess - tfinit = 1 - xinit = - t -> [x_t0 + vx_t0 * t / tfinit, y_t0 + t / tfinit * (y_tf - y_t0), vx_t0, vy_t0] - uinit = cL_max / 2 + tfinit = 60.0 + xinit = t -> [ + x_t0 + vx_t0 * t, + y_t0 + (t / tfinit) * (y_tf - y_t0), + vx_t0 + (t / tfinit) * (vx_tf - vx_t0), + vy_t0 + (t / tfinit) * (vy_tf - vy_t0) + ] + uinit = (cL_min + cL_max) / 2 init = (state=xinit, control=uinit, variable=tfinit) # discretise the optimal control problem diff --git a/ext/OptimalControlModels_s/robot_s.jl b/ext/OptimalControlModels_s/robot_s.jl index 2756c18b..c7b2fbda 100644 --- a/ext/OptimalControlModels_s/robot_s.jl +++ b/ext/OptimalControlModels_s/robot_s.jl @@ -122,7 +122,7 @@ function OptimalControlProblems.robot_s( end # initial guess - tf = 1 + tf = 9.1 xinit = t -> [ ρ_t0, diff --git a/ext/OptimalControlModels_s/space_shuttle_s.jl b/ext/OptimalControlModels_s/space_shuttle_s.jl index f1469e0a..14951a91 100644 --- a/ext/OptimalControlModels_s/space_shuttle_s.jl +++ b/ext/OptimalControlModels_s/space_shuttle_s.jl @@ -164,7 +164,7 @@ function OptimalControlProblems.space_shuttle_s( # initial guess: linear interpolation for h, v, gamma (NB. t0 = 0), constant for the rest # variable time step seems to be initialized at 1 in jump # note that ipopt will project the initial guess inside the bounds anyway. - tf_init = (tf_l+tf_u)/2 + tf_init = 0.5 x_init = t -> [ h_t0 + (t - t0) / (tf_init - t0) * (h_tf - h_t0), diff --git a/ext/OptimalControlModels_s/steering_s.jl b/ext/OptimalControlModels_s/steering_s.jl index c78da787..047c2efe 100644 --- a/ext/OptimalControlModels_s/steering_s.jl +++ b/ext/OptimalControlModels_s/steering_s.jl @@ -85,7 +85,7 @@ function OptimalControlProblems.steering_s( end end xinit = t -> [gen_x0(t, i) for i in 1:4] - init = (state=xinit, control=0, variable=1) + init = (state=xinit, control=0, variable=0.6) # discretise the optimal control problem docp = direct_transcription( From a9c5670050bdcbc9c5e7debb4b4fd58e3ed06b43 Mon Sep 17 00:00:00 2001 From: HediChennoufi Date: Wed, 21 Jan 2026 22:23:07 +0100 Subject: [PATCH 3/3] modif --- ext/OptimalControlModels/glider.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/OptimalControlModels/glider.jl b/ext/OptimalControlModels/glider.jl index c0836c2f..592d5591 100644 --- a/ext/OptimalControlModels/glider.jl +++ b/ext/OptimalControlModels/glider.jl @@ -117,7 +117,8 @@ function OptimalControlProblems.glider( vx_t0 + (t / tfinit) * (vx_tf - vx_t0), vy_t0 + (t / tfinit) * (vy_tf - vy_t0) ] - uinit = (cL_min + cL_max) / 2 + uinit = (cL_min + cL_max) / 2 + init = (state=xinit, control=uinit, variable=tfinit) # discretise the optimal control problem docp = direct_transcription(