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..592d5591 100644 --- a/ext/OptimalControlModels/glider.jl +++ b/ext/OptimalControlModels/glider.jl @@ -110,11 +110,15 @@ 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 + init = (state=xinit, control=uinit, variable=tfinit) # discretise the optimal control problem docp = direct_transcription( 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..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 = (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/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( 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(