Skip to content

Commit 9ac8953

Browse files
authored
Merge pull request #495 from JuliaControl/foh_updatestate_modelonly
added: FOH discretization for `RungeKutta` in MPC/MHE and in `updatestate!(::SimModel)`
2 parents 1e9aa1a + 2ce9c89 commit 9ac8953

24 files changed

Lines changed: 622 additions & 337 deletions

‎benchmark/1_bench_sim_model.jl‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ UNIT_MODEL["NonLinModel"]["linearize!"] =
2828
## ----------------- CASE STUDIES ---------------------------------------------------------
2929
## ----------------------------------------------------------------------------------------
3030
const CASE_MODEL = SUITE["SimModel"]["CASE STUDIES"]
31-
# TODO: Add case study benchmarks for SimModel
31+
32+
u_pendulum = [0.5]
33+
CASE_MODEL["NonLinModel"]["pendulum"]["updatestate!"] =
34+
@benchmarkable(
35+
updatestate!($pendulum_model, $u_pendulum);
36+
)

‎docs/src/manual/nonlinmpc2.md‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ function simDAE(plant, N; x_0)
215215
Y_data, U_data, D_data, X_data = zeros(ny, N), zeros(nu, N), zeros(nd, N), zeros(nx, N)
216216
c_Ain_0 = plant.p[1]
217217
setstate!(plant, x_0)
218-
x = x_0
218+
x, d = x_0, [10.0]
219219
for i=1:N
220220
u = i ≤ (1N÷4) ? [10.0] : [11.0]
221221
d = i ≤ (2N÷4) ? [10.0] : [12.0]
@@ -226,7 +226,9 @@ function simDAE(plant, N; x_0)
226226
U_data[:, i] = u
227227
D_data[:, i] = d
228228
X_data[:, i] = x
229-
x = updatestate!(plant, u, d)
229+
dnext = i+1 ≤ (2N÷4) ? [10.0] : [12.0]
230+
x = updatestate!(plant, u, d; dnext)
231+
d = dnext
230232
end
231233
plant.p[1] = c_Ain_0
232234
return SimResult(plant, U_data, Y_data, D_data; X_data)
@@ -236,7 +238,10 @@ N = 81
236238
res = simDAE(plant, N; x_0)
237239
```
238240

239-
We can now plot the result:
241+
Providing a `dnext` keyword argument to [`updatestate!`](@ref) allows discretizing the
242+
measured disturbances with first-order hold (FOH), instead of zero-order hold, which is
243+
consistent with the method applied by the [`MovingHorizonEstimator`](@ref). We can now plot
244+
the result:
240245

241246
```@example 1
242247
using Plots
@@ -324,10 +329,9 @@ function simMHE(mhe, plant, N; x_0, x̂_0)
324329
c_Ain_0 = plant.p[1]
325330
setstate!(plant, x_0); setstate!(mhe, x̂_0)
326331
initstate!(mhe, [10], [7], [10])
327-
x = x_0
332+
x, d = x_0, [10.0]
328333
for i=1:N
329334
u = i ≤ (1N÷4) ? [10.0] : [11.0]
330-
d = i ≤ (2N÷4) ? [10.0] : [12.0]
331335
c_Ain = i ≤ (3N÷4) ? c_Ain_0 : (c_Ain_0 - 0.01)
332336
plant.p[1] = c_Ain
333337
y = evaloutput(plant, d)
@@ -342,8 +346,10 @@ function simMHE(mhe, plant, N; x_0, x̂_0)
342346
X_data[3, i] = c_Ain
343347
Ŷ_data[:, i] = ŷ
344348
X̂_data[:, i] = x̂
345-
x = updatestate!(plant, u, d)
349+
dnext = i+1 ≤ (2N÷4) ? [10.0] : [12.0]
350+
x = updatestate!(plant, u, d; dnext)
346351
x̂ = updatestate!(mhe, u, ym, dm)
352+
d = dnext
347353
end
348354
plant.p[1] = c_Ain_0
349355
return SimResult(mhe, U_data, Y_data, D_data; plant, X_data, X̂_data, Ŷ_data)
@@ -399,9 +405,8 @@ function simNMPC(nmpc, plant, N, ry; x_0, x̂_0, noise=false)
399405
c_Ain_0 = plant.p[1]
400406
setstate!(plant, x_0); setstate!(nmpc, x̂_0)
401407
initstate!(nmpc, [10], [7], [10])
402-
x = x_0
408+
x, d = x_0, [10.0]
403409
for i=1:N
404-
d = i ≤ (1N÷3) ? [10.0] : [12.0]
405410
c_Ain = i ≤ (2N÷3) ? c_Ain_0 : (c_Ain_0 + 0.01)
406411
plant.p[1] = c_Ain
407412
y = evaloutput(plant, d)
@@ -418,8 +423,10 @@ function simNMPC(nmpc, plant, N, ry; x_0, x̂_0, noise=false)
418423
X_data[3, i] = c_Ain
419424
Ŷ_data[:, i] = ŷ
420425
X̂_data[:, i] = x̂
421-
x = updatestate!(plant, u, d)
426+
dnext = i+1 ≤ (1N÷3) ? [10.0] : [12.0]
427+
x = updatestate!(plant, u, d; dnext)
422428
x̂ = updatestate!(nmpc, u, ym, dm)
429+
d = dnext
423430
end
424431
plant.p[1] = c_Ain_0
425432
return SimResult(nmpc, U_data, Y_data, D_data; plant, X_data, X̂_data, Ŷ_data, Ry_data)

‎src/controller/execute.jl‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
156156
Ue, Ŷe = Vector{NT}(undef, nUe), Vector{NT}(undef, nŶe)
157157
U0, Ŷ0 = similar(mpc.Uop), similar(mpc.Yop)
158158
Û0, X̂0 = Vector{NT}(undef, nÛ0), Vector{NT}(undef, nX̂0)
159+
Ûi = Vector{NT}(undef, nÛ0)
159160
U, Ŷ = buffer.U, buffer.Ŷ
160161
D̂ = buffer.D̂
161162
U0 = getU0!(U0, mpc, Z̃)
162163
ΔŨ = getΔŨ!(ΔŨ, mpc, transcription, Z̃)
163-
Ŷ0, x̂0end = predict!(Ŷ0, x̂0end, X̂0, Û0, K, mpc, model, transcription, U0, Z̃)
164+
Ŷ0, x̂0end = predict!(Ŷ0, x̂0end, X̂0, Û0, Ûi, K, mpc, model, transcription, U0, Z̃)
164165
Ue, Ŷe = extended_vectors!(Ue, Ŷe, mpc, U0, Ŷ0)
165166
U .= U0 .+ mpc.Uop
166167
Ŷ .= Ŷ0 .+ mpc.Yop
@@ -464,7 +465,7 @@ If first warm-starts the solver with [`set_warmstart!`](@ref). It then calls
464465
`@error` log in the REPL and returns the warm-start value. A failed optimization also prints
465466
[`getinfo`](@ref) results in the debug log [if activated](https://docs.julialang.org/en/v1/stdlib/Logging/#Example:-Enable-debug-level-messages).
466467
"""
467-
function optim_objective!(mpc::PredictiveController{NT}) where {NT<:Real}
468+
function optim_objective!(mpc::PredictiveController)
468469
model, optim = mpc.estim.model, mpc.optim
469470
Z̃var::Vector{JuMP.VariableRef} = optim[:Z̃var]
470471
Z̃s = set_warmstart!(mpc, mpc.transcription, Z̃var)

‎src/controller/explicitmpc.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ optim_objective!(mpc::ExplicitMPC) = lmul!(-1, ldiv!(mpc.Z̃, mpc.H̃_chol, mpc.
210210

211211
"Compute the predictions but not the terminal states if `mpc` is an [`ExplicitMPC`](@ref)."
212212
function predict!(
213-
Ŷ0, x̂0end, _ , _ , _ , mpc::ExplicitMPC, ::LinModel, ::TranscriptionMethod, _ , Z̃
213+
Ŷ0, x̂0end, _ , _ , _ , _ , mpc::ExplicitMPC, ::LinModel, ::TranscriptionMethod, _ , Z̃
214214
)
215215
# in-place operations to reduce allocations :
216216
Ŷ0 .= mul!(Ŷ0, mpc.Ẽ, Z̃) .+ mpc.F

‎src/controller/nonlinmpc.jl‎

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -606,15 +606,16 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
606606
Ue, Ŷe = zeros(NT, nUe), zeros(NT, nŶe)
607607
U0, Ŷ0 = zeros(NT, nU), zeros(NT, nŶ)
608608
Û0, X̂0 = zeros(NT, nU), zeros(NT, nX̂)
609+
Ûi = zeros(NT, nU)
609610
gc, g = zeros(NT, nc), zeros(NT, ng)
610611
gi, geq = zeros(NT, ngi), zeros(NT, neq)
611612
J_cache = (
612613
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
613-
Cache(Û0), Cache(K), Cache(X̂0),
614+
Cache(Û0), Cache(Ûi), Cache(K), Cache(X̂0),
614615
Cache(gc), Cache(g), Cache(geq),
615616
)
616-
function J!(Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, g, geq)
617-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, g, geq, mpc, Z̃)
617+
function J!(Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq)
618+
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq, mpc, Z̃)
618619
return obj_nonlinprog!(Ŷ0, U0, mpc, Ue, Ŷe, ΔŨ)
619620
end
620621
if !isnothing(hess)
@@ -629,11 +630,11 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
629630
# --- inequality constraint derivatives ---
630631
∇g_cache = (
631632
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
632-
Cache(Û0), Cache(K), Cache(X̂0),
633+
Cache(Û0), Cache(Ûi), Cache(K), Cache(X̂0),
633634
Cache(gc), Cache(geq), Cache(g)
634635
)
635-
function gi!(gi, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, geq, g)
636-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, g, geq, mpc, Z̃)
636+
function gi!(gi, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K, X̂0, gc, geq, g)
637+
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K, X̂0, gc, g, geq, mpc, Z̃)
637638
gi .= @views g[i_g]
638639
return nothing
639640
end
@@ -657,11 +658,13 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
657658
end
658659
∇²g_cache = (
659660
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
660-
Cache(Û0), Cache(K), Cache(X̂0),
661+
Cache(Û0), Cache(Ûi), Cache(K), Cache(X̂0),
661662
Cache(gc), Cache(geq), Cache(g), Cache(gi)
662663
)
663-
function ℓ_gi(Z̃, λi, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, geq, g, gi)
664-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, g, geq, mpc, Z̃)
664+
function ℓ_gi(Z̃, λi, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, geq, g, gi)
665+
update_predictions!(
666+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq, mpc, Z̃
667+
)
665668
gi .= @views g[i_g]
666669
return dot(λi, gi)
667670
end
@@ -674,11 +677,13 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
674677
# --- equality constraint derivatives ---
675678
geq_cache = (
676679
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
677-
Cache(Û0), Cache(K), Cache(X̂0),
680+
Cache(Û0), Cache(Ûi), Cache(K), Cache(X̂0),
678681
Cache(gc), Cache(g)
679682
)
680-
function geq!(geq, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, g)
681-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, g, geq, mpc, Z̃)
683+
function geq!(geq, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g)
684+
update_predictions!(
685+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq, mpc, Z̃
686+
)
682687
return nothing
683688
end
684689
∇geq_prep = prepare_jacobian(geq!, geq, mpc.jacobian, mpc.Z̃, geq_cache...)
@@ -701,11 +706,13 @@ function addinfo!(info, mpc::NonLinMPC{NT}) where NT<:Real
701706
end
702707
∇²geq_cache = (
703708
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
704-
Cache(Û0), Cache(K), Cache(X̂0),
709+
Cache(Û0), Cache(Ûi), Cache(K), Cache(X̂0),
705710
Cache(gc), Cache(geq), Cache(g)
706711
)
707-
function ℓ_geq(Z̃, λeq, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, geq, g)
708-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K, X̂0, gc, g, geq, mpc, Z̃)
712+
function ℓ_geq(Z̃, λeq, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, geq, g)
713+
update_predictions!(
714+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq, mpc, Z̃
715+
)
709716
return dot(λeq, geq)
710717
end
711718
∇²ℓgeq_prep = prepare_hessian(ℓ_geq, hess, mpc.Z̃, Constant(λeq), ∇²geq_cache...)
@@ -846,16 +853,17 @@ function get_nonlinobj_op(mpc::NonLinMPC, optim::JuMP.GenericModel{JNT}) where J
846853
Ue::Vector{JNT}, Ŷe::Vector{JNT} = zeros(JNT, nUe), zeros(JNT, nŶe)
847854
U0::Vector{JNT}, Ŷ0::Vector{JNT} = zeros(JNT, nU), zeros(JNT, nŶ)
848855
Û0::Vector{JNT}, X̂0::Vector{JNT} = zeros(JNT, nU), zeros(JNT, nX̂)
856+
Ûi::Vector{JNT} = zeros(JNT, nU)
849857
gc::Vector{JNT}, g::Vector{JNT} = zeros(JNT, nc), zeros(JNT, ng)
850858
geq::Vector{JNT} = zeros(JNT, neq)
851-
function J!(Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, g, geq)
852-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, g, geq, mpc, Z̃)
859+
function J!(Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq)
860+
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq, mpc, Z̃)
853861
return obj_nonlinprog!(Ŷ0, U0, mpc, Ue, Ŷe, ΔŨ)
854862
end
855863
Z̃_J = zeros(JNT, nZ̃)
856864
J_cache = (
857865
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
858-
Cache(Û0), Cache(K̄), Cache(X̂0),
866+
Cache(Û0), Cache(Ûi), Cache(K̄), Cache(X̂0),
859867
Cache(gc), Cache(g), Cache(geq),
860868
)
861869
∇J_prep = prepare_gradient(J!, grad, Z̃_J, J_cache...; strict)
@@ -974,24 +982,25 @@ function get_nonlincon_oracle(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JN
974982
Ue::Vector{JNT}, Ŷe::Vector{JNT} = zeros(JNT, nUe), zeros(JNT, nŶe)
975983
U0::Vector{JNT}, Ŷ0::Vector{JNT} = zeros(JNT, nU), zeros(JNT, nŶ)
976984
Û0::Vector{JNT}, X̂0::Vector{JNT} = zeros(JNT, nU), zeros(JNT, nX̂)
985+
Ûi::Vector{JNT} = zeros(JNT, nU)
977986
gc::Vector{JNT}, g::Vector{JNT} = zeros(JNT, nc), zeros(JNT, ng)
978987
gi::Vector{JNT}, geq::Vector{JNT} = zeros(JNT, ngi), zeros(JNT, neq)
979988
λi::Vector{JNT}, λeq::Vector{JNT} = rand(JNT, ngi), rand(JNT, neq)
980989
# -------------- inequality constraint: nonlinear oracle -----------------------------
981-
function gi!(gi, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, geq, g)
982-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, g, geq, mpc, Z̃)
990+
function gi!(gi, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, geq, g)
991+
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq, mpc, Z̃)
983992
gi .= @views g[i_g]
984993
return nothing
985994
end
986-
function ℓ_gi(Z̃, λi, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, geq, g, gi)
987-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, g, geq, mpc, Z̃)
995+
function ℓ_gi(Z̃, λi, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, geq, g, gi)
996+
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq, mpc, Z̃)
988997
gi .= @views g[i_g]
989998
return dot(λi, gi)
990999
end
9911000
Z̃_∇gi = zeros(JNT, nZ̃)
9921001
∇gi_cache = (
9931002
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
994-
Cache(Û0), Cache(K̄), Cache(X̂0),
1003+
Cache(Û0), Cache(Ûi), Cache(K̄), Cache(X̂0),
9951004
Cache(gc), Cache(geq), Cache(g)
9961005
)
9971006
∇gi_prep = prepare_jacobian(gi!, gi, jac, Z̃_∇gi, ∇gi_cache...; strict)
@@ -1000,7 +1009,7 @@ function get_nonlincon_oracle(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JN
10001009
if !isnothing(hess)
10011010
∇²gi_cache = (
10021011
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
1003-
Cache(Û0), Cache(K̄), Cache(X̂0),
1012+
Cache(Û0), Cache(Ûi), Cache(K̄), Cache(X̂0),
10041013
Cache(gc), Cache(geq), Cache(g), Cache(gi)
10051014
)
10061015
∇²gi_prep = prepare_hessian(
@@ -1044,18 +1053,18 @@ function get_nonlincon_oracle(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JN
10441053
eval_hessian_lagrangian = isnothing(hess) ? nothing : ∇²gi_func!
10451054
)
10461055
# ------------- equality constraints : nonlinear oracle ------------------------------
1047-
function geq!(geq, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, g)
1048-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, g, geq, mpc, Z̃)
1056+
function geq!(geq, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g)
1057+
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq, mpc, Z̃)
10491058
return nothing
10501059
end
1051-
function ℓ_geq(Z̃, λeq, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, geq, g)
1052-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, g, geq, mpc, Z̃)
1060+
function ℓ_geq(Z̃, λeq, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, geq, g)
1061+
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq, mpc, Z̃)
10531062
return dot(λeq, geq)
10541063
end
10551064
Z̃_∇geq = zeros(JNT, nZ̃)
10561065
∇geq_cache = (
10571066
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
1058-
Cache(Û0), Cache(K̄), Cache(X̂0),
1067+
Cache(Û0), Cache(Ûi), Cache(K̄), Cache(X̂0),
10591068
Cache(gc), Cache(g)
10601069
)
10611070
∇geq_prep = prepare_jacobian(geq!, geq, jac, Z̃_∇geq, ∇geq_cache...; strict)
@@ -1064,7 +1073,7 @@ function get_nonlincon_oracle(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JN
10641073
if !isnothing(hess)
10651074
∇²geq_cache = (
10661075
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
1067-
Cache(Û0), Cache(K̄), Cache(X̂0),
1076+
Cache(Û0), Cache(Ûi), Cache(K̄), Cache(X̂0),
10681077
Cache(gc), Cache(geq), Cache(g)
10691078
)
10701079
∇²geq_prep = prepare_hessian(
@@ -1119,7 +1128,7 @@ end
11191128

11201129
"""
11211130
update_predictions!(
1122-
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, g, geq,
1131+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq,
11231132
mpc::PredictiveController, Z̃
11241133
) -> nothing
11251134
@@ -1128,18 +1137,18 @@ Update in-place all vectors for the predictions of `mpc` controller at decision
11281137
The method mutates all the arguments before the `mpc` argument.
11291138
"""
11301139
function update_predictions!(
1131-
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K̄, X̂0, gc, g, geq,
1140+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, Ûi, K̄, X̂0, gc, g, geq,
11321141
mpc::PredictiveController, Z̃
11331142
)
11341143
model, transcription = mpc.estim.model, mpc.transcription
11351144
U0 = getU0!(U0, mpc, Z̃)
11361145
ΔŨ = getΔŨ!(ΔŨ, mpc, transcription, Z̃)
1137-
Ŷ0, x̂0end = predict!(Ŷ0, x̂0end, X̂0, Û0, K̄, mpc, model, transcription, U0, Z̃)
1146+
Ŷ0, x̂0end = predict!(Ŷ0, x̂0end, X̂0, Û0, Ûi, K̄, mpc, model, transcription, U0, Z̃)
11381147
Ue, Ŷe = extended_vectors!(Ue, Ŷe, mpc, U0, Ŷ0)
11391148
ϵ = getslack(mpc, Z̃)
11401149
gc = con_custom!(gc, mpc, Ue, Ŷe, ϵ)
11411150
g = con_nonlinprog!(g, mpc, model, transcription, x̂0end, Ŷ0, gc, ϵ)
1142-
geq = con_nonlinprogeq!(geq, X̂0, Û0, K̄, mpc, model, transcription, U0, Z̃)
1151+
geq = con_nonlinprogeq!(geq, X̂0, Û0, Ûi, K̄, mpc, model, transcription, U0, Z̃)
11431152
return nothing
11441153
end
11451154

0 commit comments

Comments
 (0)