From 006bd03d4c397fb6c552cfc9290841de6da08873 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 15:23:07 -0500 Subject: [PATCH 01/15] changed: `NonLinMPC` defaults to `transcription=MultipleShooting()` Except for `NonLinModelDAE`, in which it defaults to the collocation method defined in `model.transcription`, as it was the case before. --- src/controller/nonlinmpc.jl | 6 +++--- src/model/nonlinmodeldae.jl | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controller/nonlinmpc.jl b/src/controller/nonlinmpc.jl index 71772820c..2c3c21ce6 100644 --- a/src/controller/nonlinmpc.jl +++ b/src/controller/nonlinmpc.jl @@ -232,7 +232,7 @@ This controller allocates memory at each time step for the optimization. - `nc=0` : number of custom nonlinear inequality constraints. - `p=model.p` : ``J_E`` and ``\mathbf{g_c}`` functions parameter ``\mathbf{p}`` (any type). - `transcription=default_transcription(model)` : a [`TranscriptionMethod`](@ref) object, - default to [`SingleShooting`](@ref) or `model.transcription` for [`NonLinModelDAE`](@ref). + default to [`MultipleShooting`](@ref) or `model.transcription` for [`NonLinModelDAE`](@ref). - `optim=JuMP.Model(Ipopt.Optimizer)` : nonlinear optimizer used in the predictive controller, provided as a [`JuMP.Model`](@extref) object (default to [`Ipopt`](https://github.com/jump-dev/Ipopt.jl) optimizer). - `gradient=AutoForwardDiff()` : an `AbstractADType` backend for the gradient of the objective @@ -249,12 +249,12 @@ This controller allocates memory at each time step for the optimization. ```jldoctest julia> model = NonLinModel((x,u,_,_)->0.5x+u, (x,_,_)->x, 5, 1, 1, 1, solver=nothing); -julia> mpc = NonLinMPC(model, Hp=20, Hc=10, transcription=MultipleShooting()) +julia> mpc = NonLinMPC(model, Hp=20, Hc=10, transcription=SingleShooting()) NonLinMPC controller with a sample time Ts = 5.0 s: ├ estimator: UnscentedKalmanFilter ├ model: NonLinModel ├ optimizer: Ipopt -├ transcription: MultipleShooting +├ transcription: SingleShooting ├ gradient: AutoForwardDiff ├ jacobian: AutoSparse (AutoForwardDiff, TracerSparsityDetector, GreedyColoringAlgorithm) ├ hessian: nothing diff --git a/src/model/nonlinmodeldae.jl b/src/model/nonlinmodeldae.jl index bf962f885..dcb1c4e6c 100644 --- a/src/model/nonlinmodeldae.jl +++ b/src/model/nonlinmodeldae.jl @@ -410,8 +410,8 @@ function validate_strictly_proper(NT, fq!, h!, nu, nx, na, ny, nd, p) return iszero_Ha end -"Default to `SingleShooting()`, or `model.transcription` if `model` is a `NonLinModelDAE`." -default_transcription(::SimModel) = SingleShooting() +"Default to `MultipleShooting()`, or `model.transcription` if `model` is a `NonLinModelDAE`." +default_transcription(::SimModel) = MultipleShooting() default_transcription(model::NonLinModelDAE) = model.transcription "Get the number of algebraic variable `na` in `model`." From 181da5f274b68efb6e3d9652722e15f825163651 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 15:40:09 -0500 Subject: [PATCH 02/15] test: new default dimensions with MS --- test/3_test_predictive_control.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/3_test_predictive_control.jl b/test/3_test_predictive_control.jl index 711b2b878..3757545ab 100644 --- a/test/3_test_predictive_control.jl +++ b/test/3_test_predictive_control.jl @@ -810,7 +810,7 @@ end nmpc0 = NonLinMPC(linmodel1, Hp=15) @test isa(nmpc0.estim, SteadyKalmanFilter) nmpc3 = NonLinMPC(linmodel1, Hp=15, Hc=4, Cwt=1e4) - @test size(nmpc3.Ẽ, 2) == 4*linmodel1.nu + 1 + @test size(nmpc3.Ẽ, 2) == 4*linmodel1.nu + 15*linmodel1.nx + 15*linmodel.ny + 1 @test nmpc3.weights.Ñ_Hc[end] == 1e4 nmpc4 = NonLinMPC(linmodel1, Hp=15, Mwt=[1,2]) @test nmpc4.weights.M_Hp ≈ Diagonal(diagm(repeat(Float64[1, 2], 15))) From d271f56401cd93421c5c70b317482d822455fe5d Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 16:31:18 -0500 Subject: [PATCH 03/15] test: replacing MS construction with SS for `NonLinMPC` To improve coverage of `SingleShooting` transcription. --- test/3_test_predictive_control.jl | 63 +++++++++++++++++-------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/test/3_test_predictive_control.jl b/test/3_test_predictive_control.jl index 3757545ab..ba49f0823 100644 --- a/test/3_test_predictive_control.jl +++ b/test/3_test_predictive_control.jl @@ -809,8 +809,11 @@ end linmodel1 = LinModel(sys,Ts,i_d=[3]) nmpc0 = NonLinMPC(linmodel1, Hp=15) @test isa(nmpc0.estim, SteadyKalmanFilter) + @test nmpc0.transcription isa MultipleShooting + @test length(nmpc0.Z̃) == linmodel1.nu*nmpc0.Hc + nmpc0.estim.nx̂*nmpc0.Hp + nmpc0.nϵ + @test size(nmpc0.con.Aeq, 1) == nmpc0.estim.nx̂*nmpc0.Hp nmpc3 = NonLinMPC(linmodel1, Hp=15, Hc=4, Cwt=1e4) - @test size(nmpc3.Ẽ, 2) == 4*linmodel1.nu + 15*linmodel1.nx + 15*linmodel.ny + 1 + @test size(nmpc3.Ẽ, 2) == 4*linmodel1.nu + 15*linmodel1.nx + 15*linmodel1.ny + 1 @test nmpc3.weights.Ñ_Hc[end] == 1e4 nmpc4 = NonLinMPC(linmodel1, Hp=15, Mwt=[1,2]) @test nmpc4.weights.M_Hp ≈ Diagonal(diagm(repeat(Float64[1, 2], 15))) @@ -840,10 +843,10 @@ end LHS = zeros(1) nmpc15.con.gc!(LHS,[1,2],[3,4],[4,6],10,0.1) @test LHS ≈ [10*dot([1,2],[3,4])+sum([4,6])+0.1] - nmpc17 = NonLinMPC(linmodel1, Hp=10, transcription=MultipleShooting()) - @test nmpc17.transcription == MultipleShooting() - @test length(nmpc17.Z̃) == linmodel1.nu*nmpc17.Hc + nmpc17.estim.nx̂*nmpc17.Hp + nmpc17.nϵ - @test size(nmpc17.con.Aeq, 1) == nmpc17.estim.nx̂*nmpc17.Hp + nmpc17 = NonLinMPC(linmodel1, Hp=10, transcription=SingleShooting()) + @test nmpc17.transcription isa SingleShooting + @test length(nmpc17.Z̃) == linmodel1.nu*nmpc17.Hc + nmpc17.nϵ + @test size(nmpc17.con.Aeq, 1) == 0 @test_throws DimensionMismatch NonLinMPC(linmodel1, Hp=15, Ewt=[1, 1]) @test_throws ErrorException NonLinMPC(linmodel1, Hp=15, JE = (_,_,_)->0.0) @@ -861,17 +864,18 @@ end using JuMP, Ipopt, DifferentiationInterface import FiniteDiff linmodel1 = LinModel(sys,Ts,i_d=[3]) - nmpc0 = NonLinMPC(linmodel1, Hp=15) - @test isa(nmpc0.estim, SteadyKalmanFilter) f = (x,u,d,model) -> model.A*x + model.Bu*u + model.Bd*d h = (x,d,model) -> model.C*x + model.Dd*d nonlinmodel = NonLinModel(f, h, Ts, 2, 4, 2, 1, p=linmodel1, solver=nothing) nmpc1 = NonLinMPC(nonlinmodel, Hp=15) @test isa(nmpc1.estim, UnscentedKalmanFilter) - @test size(nmpc1.R̂y, 1) == 15*nmpc1.estim.model.ny + @test nmpc1.transcription isa MultipleShooting + @test length(nmpc1.Z̃) == nonlinmodel.nu*nmpc1.Hc + nmpc1.estim.nx̂*nmpc1.Hp + nmpc1.nϵ + @test nmpc1.con.neq == nonlinmodel.nx*nmpc1.Hp + @test size(nmpc1.R̂y, 1) == nmpc1.Hp*nmpc1.estim.model.ny nmpc2 = NonLinMPC(nonlinmodel, Hp=15, Hc=4, Cwt=Inf) - @test size(nmpc2.Ẽ, 2) == 4*nonlinmodel.nu + @test size(nmpc2.Ẽ, 2) == nmpc2.Hc*nonlinmodel.nu + nmpc2.estim.nx̂*nmpc2.Hp + nmpc2.nϵ optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer, "nlp_scaling_max_gradient"=>1.0)) nmpc8 = NonLinMPC(nonlinmodel, Hp=15, optim=optim) @test solver_name(nmpc8.optim) == "Ipopt" @@ -883,10 +887,10 @@ end @test nmpc11.estim.nint_u == [1, 1] @test nmpc11.estim.nint_ym == [0, 0] gc! = (LHS,_,_,_,_,_)-> (LHS .= 0.0) # useless, only for coverage - nmpc16 = NonLinMPC(nonlinmodel, Hp=10, transcription=MultipleShooting(), nc=10, gc=gc!) - @test isa(nmpc16.transcription, MultipleShooting) - @test length(nmpc16.Z̃) == nonlinmodel.nu*nmpc16.Hc + nmpc16.estim.nx̂*nmpc16.Hp + nmpc16.nϵ - @test nmpc16.con.neq == nmpc16.estim.model.nx*nmpc16.Hp + nmpc16 = NonLinMPC(nonlinmodel, Hp=10, transcription=SingleShooting(), nc=10, gc=gc!) + @test nmpc16.transcription isa SingleShooting + @test length(nmpc16.Z̃) == nonlinmodel.nu*nmpc16.Hc + nmpc16.nϵ + @test nmpc16.con.neq == 0 @test nmpc16.con.nc == 10 nonlinmodel_c = NonLinModel((ẋ,x,u,_,_)->ẋ .= -0.1x .+ u, (y,x,_,_)->y.=x, 1, 1, 1, 1) nmpc17 = NonLinMPC(nonlinmodel_c, Hp=10, transcription=TrapezoidalCollocation(), nc=10, gc=gc!) @@ -916,7 +920,8 @@ end @test nmpc20.hessian == SecondOrder(AutoForwardDiff(), AutoForwardDiff()) @test_nowarn repr(nmpc20) # printing SecondOrder backends, for coverage - nonlinmodel2 = NonLinModel{Float32}(f, h, Ts, 2, 4, 2, 1, solver=nothing) + linmodel2 = LinModel{Float32}(linmodel1.A, linmodel1.Bu, linmodel1.C, linmodel1.Bd, linmodel1.Dd, Ts) + nonlinmodel2 = NonLinModel{Float32}(f, h, Ts, 2, 4, 2, 1, solver=nothing, p=linmodel2) nmpc15 = NonLinMPC(nonlinmodel2, Hp=15) @test isa(nmpc15, NonLinMPC{Float32}) @test isa(nmpc15.estim, UnscentedKalmanFilter{Float32}) @@ -964,6 +969,21 @@ end import FiniteDiff linmodel = setop!(LinModel(tf(5, [2000, 1]), 3000.0), yop=[10]) + nmpc9 = NonLinMPC(linmodel, Nwt=[0], Hp=100, Hc=1, transcription=SingleShooting()) + preparestate!(nmpc9, [10]) + u = moveinput!(nmpc9, [20]) + @test u ≈ [2] atol=5e-2 + info = getinfo(nmpc9) + @test info[:u] ≈ u + @test info[:Ŷ][end] ≈ 20 atol=5e-2 +end + +@testitem "NonLinMPC moves & getinfo (LinModel, MS)" setup=[SetupMPCtests] begin + using .SetupMPCtests, ControlSystemsBase, LinearAlgebra + using DifferentiationInterface + import FiniteDiff + linmodel = setop!(LinModel(tf(5, [2000, 1]), 3000.0), yop=[10]) + Hp = 100 nmpc_lin = NonLinMPC(linmodel, Nwt=[0], Hp=Hp, Hc=1) ry, ru = [15], [4] @@ -1014,21 +1034,6 @@ end @test_nowarn ModelPredictiveControl.info2debugstr(info) end -@testitem "NonLinMPC moves & getinfo (LinModel, MS)" setup=[SetupMPCtests] begin - using .SetupMPCtests, ControlSystemsBase, LinearAlgebra - using DifferentiationInterface - import FiniteDiff - linmodel = setop!(LinModel(tf(5, [2000, 1]), 3000.0), yop=[10]) - - nmpc9 = NonLinMPC(linmodel, Nwt=[0], Hp=100, Hc=1, transcription=MultipleShooting()) - preparestate!(nmpc9, [10]) - u = moveinput!(nmpc9, [20]) - @test u ≈ [2] atol=5e-2 - info = getinfo(nmpc9) - @test info[:u] ≈ u - @test info[:Ŷ][end] ≈ 20 atol=5e-2 -end - @testitem "NonLinMPC moves & getinfo (NonLinModel, SS)" setup=[SetupMPCtests] begin using .SetupMPCtests, ControlSystemsBase, LinearAlgebra using DifferentiationInterface From ea325252cc7f443107c292e6f5ce01d2295066c4 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 16:46:14 -0500 Subject: [PATCH 04/15] test: update `NonLinMPC` test --- test/3_test_predictive_control.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/3_test_predictive_control.jl b/test/3_test_predictive_control.jl index ba49f0823..660621305 100644 --- a/test/3_test_predictive_control.jl +++ b/test/3_test_predictive_control.jl @@ -1466,8 +1466,8 @@ end @test -nmpc.con.A_ΔUmin[:, end] ≈ [0.05,0.06] @test -nmpc.con.A_ΔUmax[:, end] ≈ [0.07,0.08] setconstraint!(nmpc, c_ymin=[1.00,1.01], c_ymax=[1.02,1.03]) - @test -nmpc.con.A_Ymin ≈ zeros(0,3) - @test -nmpc.con.A_Ymax ≈ zeros(0,3) + @test -nmpc.con.A_Ymin ≈ zeros(0,9) + @test -nmpc.con.A_Ymax ≈ zeros(0,9) @test nmpc.con.C_ymin ≈ [1.00,1.01] @test nmpc.con.C_ymax ≈ [1.02,1.03] setconstraint!(nmpc, From e935eda93511de304898c9d1ab6721caa0c15296 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 17:02:02 -0500 Subject: [PATCH 05/15] test: various cleanup and debug in `NonLinMPC` tests --- test/3_test_predictive_control.jl | 139 +++++++++++++++--------------- 1 file changed, 70 insertions(+), 69 deletions(-) diff --git a/test/3_test_predictive_control.jl b/test/3_test_predictive_control.jl index 660621305..7d10c58e4 100644 --- a/test/3_test_predictive_control.jl +++ b/test/3_test_predictive_control.jl @@ -1042,55 +1042,21 @@ end f = (x,u,d,model) -> model.A*x + model.Bu*u + model.Bd*d h = (x,d,model) -> model.C*x + model.Dd*d nonlinmodel = NonLinModel(f, h, 3000.0, 1, 2, 1, 1, solver=nothing, p=linmodel2) - - nmpc1 = NonLinMPC(nonlinmodel, Nwt=[0], Hp=100, Hc=1) - preparestate!(nmpc1, [0], [0]) - # if d=[0.1], the output will eventually reach 7*0.1=0.7, no action needed (u=0): - d = [0.1] - u = moveinput!(nmpc1, 7d, d) - @test u ≈ [0] atol=5e-2 - u = nmpc1(7d, d) - @test u ≈ [0] atol=5e-2 - info = getinfo(nmpc1) - @test info[:u] ≈ u - @test info[:Ŷ][end] ≈ 7d[1] atol=5e-2 - - nmpc2 = NonLinMPC(nonlinmodel, Nwt=[0], Cwt=Inf, Hp=100, Hc=1) - preparestate!(nmpc2, [0], [0]) - u = moveinput!(nmpc2, 7d, d) - @test u ≈ [0] atol=5e-2 - - nmpc3 = NonLinMPC(nonlinmodel, Hp=15, Mwt=[0], Nwt=[0], Lwt=[1]) + + transcription = SingleShooting() + nmpc3 = NonLinMPC(nonlinmodel; Hp=15, Mwt=[0], Nwt=[0], Lwt=[1], transcription) preparestate!(nmpc3, [0], [0]) - u = moveinput!(nmpc3, [0], d, R̂u=fill(12, nmpc3.Hp)) + u = moveinput!(nmpc3, [0], [0], R̂u=fill(12, nmpc3.Hp)) @test u ≈ [12] atol=5e-2 - nonlinmodel2 = NonLinModel{Float32}(f, h, 3000.0, 1, 2, 1, 1, solver=nothing, p=linmodel2) - nmpc7 = NonLinMPC(nonlinmodel2, Hp=10) - y = similar(nonlinmodel2.yop) - ModelPredictiveControl.h!(y, nonlinmodel2, Float32[0,0], Float32[0]) - preparestate!(nmpc7, [0], [0]) - @test moveinput!(nmpc7, [0], [0]) ≈ [0.0] atol=5e-2 - - nmpc10 = setconstraint!(NonLinMPC( - nonlinmodel, Nwt=[0], Hp=100, Hc=1, - gradient=AutoFiniteDiff(), - jacobian=AutoFiniteDiff(), - hessian=AutoFiniteDiff() - ), ymax=[100], ymin=[-100] - ) - preparestate!(nmpc10, [0], [0]) - u = moveinput!(nmpc10, [10], [0]) + transcription = SingleShooting() + nmpc4 = NonLinMPC(nonlinmodel; Nwt=[0], Hp=100, Hc=1, transcription) + preparestate!(nmpc4, [0], [0]) + u = moveinput!(nmpc4, [10], [0]) @test u ≈ [2] atol=5e-2 - info = getinfo(nmpc10) + info = getinfo(nmpc4) @test info[:u] ≈ u @test info[:Ŷ][end] ≈ 10 atol=5e-2 - - nmpc11 = NonLinMPC(nonlinmodel, Hp=10, Hc=[1, 2, 3, 4], Nwt=[10]) - preparestate!(nmpc11, y, [0]) - moveinput!(nmpc11, [10], [0]) - ΔU_diff = diff(getinfo(nmpc11)[:U]) - @test ΔU_diff[[2, 4, 5, 7, 8, 9]] ≈ zeros(6) atol=1e-9 function f!(ẋ, x, u, d, p) ẋ[] = -p[] * (x[] - 0.2 * u[] - 0.2 * d[]) @@ -1118,16 +1084,24 @@ end f = (x,u,d,model) -> model.A*x + model.Bu*u + model.Bd*d h = (x,d,model) -> model.C*x + model.Dd*d nonlinmodel = NonLinModel(f, h, 3000.0, 1, 2, 1, 1, solver=nothing, p=linmodel2) - - transcription = MultipleShooting() - nmpc4 = NonLinMPC(nonlinmodel; Nwt=[0], Hp=100, Hc=1, transcription) - preparestate!(nmpc4, [0], [0]) - u = moveinput!(nmpc4, [10], [0]) - @test u ≈ [2] atol=5e-2 - info = getinfo(nmpc4) + + nmpc1 = NonLinMPC(nonlinmodel, Nwt=[0], Hp=100, Hc=1) + preparestate!(nmpc1, [0], [0]) + # if d=[0.1], the output will eventually reach 7*0.1=0.7, no action needed (u=0): + d = [0.1] + u = moveinput!(nmpc1, 7d, d) + @test u ≈ [0] atol=5e-2 + u = nmpc1(7d, d) + @test u ≈ [0] atol=5e-2 + info = getinfo(nmpc1) @test info[:u] ≈ u - @test info[:Ŷ][end] ≈ 10 atol=5e-2 + @test info[:Ŷ][end] ≈ 7d[1] atol=5e-2 + nmpc2 = NonLinMPC(nonlinmodel, Nwt=[0], Cwt=Inf, Hp=100, Hc=1) + preparestate!(nmpc2, [0], [0]) + u = moveinput!(nmpc2, 7d, d) + @test u ≈ [0] atol=5e-2 + transcription = MultipleShooting(f_threads=true, h_threads=true) nmpc4t = NonLinMPC(nonlinmodel; Nwt=[0], Hp=100, Hc=1, transcription, hessian=true) nmpc4t = setconstraint!(nmpc4t, ymax=[100], ymin=[-100]) # coverage of getinfo! Hessians of Lagrangian @@ -1138,6 +1112,33 @@ end @test info[:u] ≈ u @test info[:Ŷ][end] ≈ 10 atol=5e-2 + nonlinmodel2 = NonLinModel{Float32}(f, h, 3000.0, 1, 2, 1, 1, solver=nothing, p=linmodel2) + nmpc7 = NonLinMPC(nonlinmodel2, Hp=10) + y = similar(nonlinmodel2.yop) + ModelPredictiveControl.h!(y, nonlinmodel2, Float32[0,0], Float32[0]) + preparestate!(nmpc7, [0], [0]) + @test moveinput!(nmpc7, [0], [0]) ≈ [0.0] atol=5e-2 + + nmpc10 = setconstraint!(NonLinMPC( + nonlinmodel, Nwt=[0], Hp=100, Hc=1, + gradient=AutoFiniteDiff(), + jacobian=AutoFiniteDiff(), + hessian=AutoFiniteDiff() + ), ymax=[100], ymin=[-100] + ) + preparestate!(nmpc10, [0], [0]) + u = moveinput!(nmpc10, [10], [0]) + @test u ≈ [2] atol=5e-2 + info = getinfo(nmpc10) + @test info[:u] ≈ u + @test info[:Ŷ][end] ≈ 10 atol=5e-2 + + nmpc11 = NonLinMPC(nonlinmodel, Hp=10, Hc=[1, 2, 3, 4], Nwt=[10]) + preparestate!(nmpc11, y, [0]) + moveinput!(nmpc11, [10], [0]) + ΔU_diff = diff(getinfo(nmpc11)[:U]) + @test ΔU_diff[[2, 4, 5, 7, 8, 9]] ≈ zeros(6) atol=1e-9 + function f!(ẋ, x, u, d, p) ẋ[] = -p[] * (x[] - 0.2 * u[] - 0.2 * d[]) return nothing @@ -1477,28 +1478,28 @@ end @test nmpc.con.c_x̂min ≈ [0.21,0.22,0.23,0.24,0.25,0.26] @test nmpc.con.c_x̂max ≈ [0.31,0.32,0.33,0.34,0.35,0.36] - nmpc_ms = NonLinMPC(nonlinmodel, Hp=1, Hc=1, transcription=MultipleShooting()) + nmpc_ss = NonLinMPC(nonlinmodel, Hp=1, Hc=1, transcription=SingleShooting()) - setconstraint!(nmpc_ms, ymin=[-6, -11],ymax=[55, 35]) - @test nmpc_ms.con.Y0min ≈ [-6,-11] - @test nmpc_ms.con.Y0max ≈ [55,35] - setconstraint!(nmpc_ms, x̂min=[-21,-22,-23,-24,-25,-26], x̂max=[21,22,23,24,25,26]) - @test nmpc_ms.con.x̂0min ≈ [-21,-22,-23,-24,-25,-26] - @test nmpc_ms.con.x̂0max ≈ [21,22,23,24,25,26] - - setconstraint!(nmpc_ms, c_ymin=[1.00,1.01], c_ymax=[1.02,1.03]) - @test -nmpc_ms.con.A_Ymin ≈ zeros(0,9) - @test -nmpc_ms.con.A_Ymax ≈ zeros(0,9) - @test nmpc_ms.con.C_ymin ≈ [1.00,1.01] - @test nmpc_ms.con.C_ymax ≈ [1.02,1.03] - setconstraint!(nmpc_ms, + setconstraint!(nmpc_ss, ymin=[-6, -11],ymax=[55, 35]) + @test nmpc_ss.con.Y0min ≈ [-6,-11] + @test nmpc_ss.con.Y0max ≈ [55,35] + setconstraint!(nmpc_ss, x̂min=[-21,-22,-23,-24,-25,-26], x̂max=[21,22,23,24,25,26]) + @test nmpc_ss.con.x̂0min ≈ [-21,-22,-23,-24,-25,-26] + @test nmpc_ss.con.x̂0max ≈ [21,22,23,24,25,26] + + setconstraint!(nmpc_ss, c_ymin=[1.00,1.01], c_ymax=[1.02,1.03]) + @test -nmpc_ss.con.A_Ymin ≈ zeros(0,3) + @test -nmpc_ss.con.A_Ymax ≈ zeros(0,3) + @test nmpc_ss.con.C_ymin ≈ [1.00,1.01] + @test nmpc_ss.con.C_ymax ≈ [1.02,1.03] + setconstraint!(nmpc_ss, c_x̂min=[0.21,0.22,0.23,0.24,0.25,0.26], c_x̂max=[0.31,0.32,0.33,0.34,0.35,0.36] ) @test -nmpc_lin.con.A_x̂min[:, end] ≈ [0.21,0.22,0.23,0.24,0.25,0.26] @test -nmpc_lin.con.A_x̂max[:, end] ≈ [0.31,0.32,0.33,0.34,0.35,0.36] - @test nmpc_ms.con.c_x̂min ≈ [0.21,0.22,0.23,0.24,0.25,0.26] - @test nmpc_ms.con.c_x̂max ≈ [0.31,0.32,0.33,0.34,0.35,0.36] + @test nmpc_ss.con.c_x̂min ≈ [0.21,0.22,0.23,0.24,0.25,0.26] + @test nmpc_ss.con.c_x̂max ≈ [0.31,0.32,0.33,0.34,0.35,0.36] end @@ -1655,7 +1656,7 @@ end @test all(isapprox.(info[:gc][Hp+1:end], 0.0; atol=1e-1)) nmpc_ms = NonLinMPC( - nonlinmodel; Hp, Hc=5, transcription=MultipleShooting(), gc, nc=2Hp, p=[0; 0] + nonlinmodel; Hp, Hc=5, transcription=SingleShooting(), gc, nc=2Hp, p=[0; 0] ) JuMP.set_attribute(nmpc_ms.optim, "constr_viol_tol", 1e-3) @@ -1757,7 +1758,7 @@ end @test mpc.weights.Ñ_Hc ≈ diagm([0.1;1e6]) @test mpc.weights.L_Hp ≈ diagm(1.1:1000.1) f = (x,u,d,_) -> estim.model.A*x + estim.model.Bu*u + estim.model.Bd*d - h = (x,d,_) -> estim.model.C*x + estim.model.Du*d + h = (x,d,_) -> estim.model.C*x + estim.model.Dd*d nonlinmodel = NonLinModel(f, h, 10.0, 1, 1, 1) nmpc = NonLinMPC(nonlinmodel, Nwt=[0], Cwt=1e4, Hp=1000, Hc=10) setmodel!(nmpc, Mwt=[100], Nwt=[200], Lwt=[300]) From 361f6b31c5fd816d22accbd2fa8a78ac6e18dc70 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 17:05:03 -0500 Subject: [PATCH 06/15] test: idem --- test/3_test_predictive_control.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/3_test_predictive_control.jl b/test/3_test_predictive_control.jl index 7d10c58e4..238721784 100644 --- a/test/3_test_predictive_control.jl +++ b/test/3_test_predictive_control.jl @@ -1356,14 +1356,14 @@ end nlmodel = setop!(nlmodel, yop=[10]) u, ym = let nlmodel=nlmodel, r=r, outdist=outdist estim = UnscentedKalmanFilter(nlmodel, nint_u=[1]) - nmpc_nint_u_ms = NonLinMPC(estim; Hp=10, transcription=MultipleShooting()) + nmpc_nint_u_ss = NonLinMPC(estim; Hp=10, transcription=SingleShooting()) nlmodel.x0 .= 0 ym, u = nlmodel() - outdist, [0.0] for i=1:25 ym = nlmodel() - outdist - preparestate!(nmpc_nint_u_ms, ym) - u = moveinput!(nmpc_nint_u_ms, r) - updatestate!(nmpc_nint_u_ms, u, ym) + preparestate!(nmpc_nint_u_ss, ym) + u = moveinput!(nmpc_nint_u_ss, r) + updatestate!(nmpc_nint_u_ss, u, ym) updatestate!(nlmodel, u) end u, ym From 201f33dce7f50a958ab0badbaa1fe6fd510d21a1 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 17:08:33 -0500 Subject: [PATCH 07/15] test: idem --- test/3_test_predictive_control.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/3_test_predictive_control.jl b/test/3_test_predictive_control.jl index 238721784..07ae2fc8a 100644 --- a/test/3_test_predictive_control.jl +++ b/test/3_test_predictive_control.jl @@ -874,7 +874,8 @@ end @test length(nmpc1.Z̃) == nonlinmodel.nu*nmpc1.Hc + nmpc1.estim.nx̂*nmpc1.Hp + nmpc1.nϵ @test nmpc1.con.neq == nonlinmodel.nx*nmpc1.Hp @test size(nmpc1.R̂y, 1) == nmpc1.Hp*nmpc1.estim.model.ny - nmpc2 = NonLinMPC(nonlinmodel, Hp=15, Hc=4, Cwt=Inf) + gc! = (LHS,_,_,_,_,_)-> (LHS .= 0.0) # useless gc!, only for coverage + nmpc2 = NonLinMPC(nonlinmodel, Hp=15, Hc=4, Cwt=Inf, nc=15, gc=gc!) @test size(nmpc2.Ẽ, 2) == nmpc2.Hc*nonlinmodel.nu + nmpc2.estim.nx̂*nmpc2.Hp + nmpc2.nϵ optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer, "nlp_scaling_max_gradient"=>1.0)) nmpc8 = NonLinMPC(nonlinmodel, Hp=15, optim=optim) @@ -886,7 +887,6 @@ end nmpc11 = NonLinMPC(nonlinmodel, Hp=15, nint_u=[1, 1], nint_ym=[0, 0]) @test nmpc11.estim.nint_u == [1, 1] @test nmpc11.estim.nint_ym == [0, 0] - gc! = (LHS,_,_,_,_,_)-> (LHS .= 0.0) # useless, only for coverage nmpc16 = NonLinMPC(nonlinmodel, Hp=10, transcription=SingleShooting(), nc=10, gc=gc!) @test nmpc16.transcription isa SingleShooting @test length(nmpc16.Z̃) == nonlinmodel.nu*nmpc16.Hc + nmpc16.nϵ From d8571755a653589950ada48db7f93de6c87d7622 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 18:24:00 -0500 Subject: [PATCH 08/15] doc: minor modification in pendulum example --- docs/src/manual/nonlinmpc1.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/manual/nonlinmpc1.md b/docs/src/manual/nonlinmpc1.md index 89c0bef5b..5677716bc 100644 --- a/docs/src/manual/nonlinmpc1.md +++ b/docs/src/manual/nonlinmpc1.md @@ -128,8 +128,8 @@ nmpc = setconstraint!(nmpc; umin, umax) The option `Cwt=Inf` disables the slack variable `ϵ` for constraint softening. By default, [`NonLinMPC`](@ref) controllers use [`Ipopt`](https://coin-or.github.io/Ipopt/) and a direct -[`SingleShooting`](@ref) transcription method to solve the optimal control problem. We test -`mpc` performance on `plant` by imposing an angular setpoint of 180° (inverted position): +[`MultipleShooting`](@ref) transcription method to solve the optimal control problem. We +test `mpc` performance on `plant` by imposing an angular setpoint of 180° (inverted position): ```@example man_nonlin using JuMP; unset_time_limit_sec(nmpc.optim) # hide @@ -359,7 +359,7 @@ A [`SteadyKalmanFilter`](@ref) and a [`LinMPC`](@ref) are designed from `linmode ```@example man_nonlin skf = SteadyKalmanFilter(linmodel; σQ, σR, nint_u, σQint_u) mpc = LinMPC(skf; Hp, Hc, Mwt, Nwt, Cwt=Inf) -mpc = setconstraint!(mpc, umin=[-1.5], umax=[+1.5]) +mpc = setconstraint!(mpc; umin, umax) ``` The linear controller satisfactorily rejects the 10° step disturbance: From 7748e617ad6006c6da14d895bbbd45fa7ecd7d2a Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 18:25:51 -0500 Subject: [PATCH 09/15] doc: idem --- docs/src/manual/nonlinmpc1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/manual/nonlinmpc1.md b/docs/src/manual/nonlinmpc1.md index 5677716bc..06fe0e3ad 100644 --- a/docs/src/manual/nonlinmpc1.md +++ b/docs/src/manual/nonlinmpc1.md @@ -303,7 +303,7 @@ We construct the controller by enabling relaxation with the `Cwt` argument, and specifying the number of custom inequality constraints `nc`: ```@example man_nonlin -Cwt, Pmax, nc = 1e5, 3, Hp+1 +Cwt, Pmax, nc = 5e4, 3, Hp+1 nmpc2 = NonLinMPC(estim2; Hp, Hc, Nwt=Nwt, Mwt=[0.5, 0], Cwt, gc!, nc, p=Pmax) nmpc2 = setconstraint!(nmpc2; umin, umax) using JuMP; unset_time_limit_sec(nmpc2.optim) # hide From ddcd61f2bbe3fd7b20198297eda47f847c56ccf0 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 19:44:18 -0500 Subject: [PATCH 10/15] doc: correct outdated information --- src/controller/nonlinmpc.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controller/nonlinmpc.jl b/src/controller/nonlinmpc.jl index 2c3c21ce6..d8fe62bbf 100644 --- a/src/controller/nonlinmpc.jl +++ b/src/controller/nonlinmpc.jl @@ -173,14 +173,14 @@ subject to [`setconstraint!`](@ref) bounds, and the custom inequality constraint ```math \mathbf{g_c}(\mathbf{U_e, Ŷ_e, D̂_e, p}, ϵ) ≤ \mathbf{0} ``` -with the decision variables ``\mathbf{Z}`` and slack ``ϵ``. By default, a [`SingleShooting`](@ref) -transcription method is used, hence ``\mathbf{Z=ΔU}``. The economic function ``J_E`` can -penalizes solutions with high economic costs. Setting all the weights to 0 except ``E`` -creates a pure economic model predictive controller (EMPC). As a matter of fact, ``J_E`` can -be any nonlinear function as a custom objective, even if there is no economic interpretation -to it. The arguments of ``J_E`` and ``\mathbf{g_c}`` include the manipulated inputs, -predicted outputs and measured disturbances, extended from ``k`` to ``k+H_p`` (inclusively, -see Extended Help for more details): +with the decision variables ``\mathbf{Z}`` and slack ``ϵ``. The transcription method defines +the content of ``\mathbf{Z}`` (default to [`MultipleShooting`](@ref)). The economic function +``J_E`` can penalizes solutions with high economic costs. Setting all the weights to zero +except ``E`` creates a pure economic model predictive controller (EMPC). As a matter of +fact, ``J_E`` can be any nonlinear function as a custom objective, even if there is no +economic interpretation to it. The arguments of ``J_E`` and ``\mathbf{g_c}`` include the +manipulated inputs, predicted outputs and measured disturbances, extended from ``k`` to +``k+H_p`` (inclusively, see Extended Help for more details): ```math \mathbf{U_e} = \begin{bmatrix} \mathbf{U} \\ \mathbf{u}(k+H_p-1) \end{bmatrix} , \quad \mathbf{Ŷ_e} = \begin{bmatrix} \mathbf{ŷ}(k) \\ \mathbf{Ŷ} \end{bmatrix} , \quad From ecaae2aeedcd6e5ec6a33e3f4fa4992ffaca6852 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Tue, 1 Dec 2026 19:59:02 -0500 Subject: [PATCH 11/15] changed: precompile with `MultipleShooting` w/o multi-threading --- src/precompile.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/precompile.jl b/src/precompile.jl index 04d0b25ac..9a7c7197f 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -84,7 +84,7 @@ R̂y = repeat([55; 30], 3) nlmodel = setop!(nlmodel, uop=[10, 10], yop=[50, 30]) y = nlmodel() - transcription = MultipleShooting(f_threads=true) + transcription = MultipleShooting() nmpc_ukf = setconstraint!( NonLinMPC(nlmodel; Hp=3, Mwt=[0, 0], Ewt=1, JE=JE, p=R̂y, transcription), ymin=[45, -Inf] From 632cc4cba0ed301888e6633afcaf5ee883c46e82 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Wed, 2 Dec 2026 09:02:41 -0500 Subject: [PATCH 12/15] debug: still `SingleShooting` by default for MHE --- src/controller/nonlinmpc.jl | 6 +++++- src/estimator/internal_model.jl | 2 +- src/estimator/mhe/construct.jl | 12 ++++++++---- src/model/nonlinmodeldae.jl | 4 ---- src/sim_model.jl | 2 ++ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/controller/nonlinmpc.jl b/src/controller/nonlinmpc.jl index d8fe62bbf..a2dfcba34 100644 --- a/src/controller/nonlinmpc.jl +++ b/src/controller/nonlinmpc.jl @@ -464,7 +464,11 @@ end default_estimator(model::SimModelODE; kwargs...) = UnscentedKalmanFilter(model; kwargs...) default_estimator(model::SimModelDAE; kwargs...) = MovingHorizonEstimator(model; kwargs...) -default_estimator(model::LinModel; kwargs...) = SteadyKalmanFilter(model; kwargs...) +default_estimator(model::LinModel; kwargs...) = SteadyKalmanFilter(model; kwargs...) + +"Default to `MultipleShooting()`, or `model.transcription` if `model` is a `NonLinModelDAE`." +default_transcription(::SimModel) = MultipleShooting() +default_transcription(model::NonLinModelDAE) = model.transcription """ validate_JE(NT, JE) -> nothing diff --git a/src/estimator/internal_model.jl b/src/estimator/internal_model.jl index 3eb3d83f1..4a82c7c8f 100644 --- a/src/estimator/internal_model.jl +++ b/src/estimator/internal_model.jl @@ -32,7 +32,7 @@ struct InternalModel{NT<:Real, SM<:SimModel} <: StateEstimator{NT} model::SM, i_ym, Asm, Bsm, Csm, Dsm ) where {NT<:Real, SM<:SimModel} nu, ny, nd = model.nu, model.ny, model.nd - nk̄ = get_nk̄(model, default_transcription(model)) + nk̄ = get_nk̄(model) nym, nyu = validate_ym(model, i_ym) validate_internalmodel(model, nym, Csm, Dsm) As, Bs, Cs, Ds = stoch_ym2y(model, i_ym, Asm, Bsm, Csm, Dsm) diff --git a/src/estimator/mhe/construct.jl b/src/estimator/mhe/construct.jl index 8cee5621d..9c426400f 100644 --- a/src/estimator/mhe/construct.jl +++ b/src/estimator/mhe/construct.jl @@ -357,7 +357,7 @@ at each time step for the optimization. not (details in Extended Help). - `nc=0` : number of custom nonlinear inequality constraints. - `p=model.p` : ``\mathbf{g_c}`` functions parameter ``\mathbf{p}`` (any type). -- `transcription=default_transcription(model)` : a [`TranscriptionMethod`](@ref) object, +- `transcription=default_transcription_mhe(model)` : a [`TranscriptionMethod`](@ref) object, default to [`SingleShooting`](@ref) or `model.transcription` for [`NonLinModelDAE`](@ref). - `optim=default_optim_mhe(model,nc)` : a [`JuMP.Model`](@extref) object with a quadratic or nonlinear optimizer for solving (default to [`Ipopt`](https://github.com/jump-dev/Ipopt.jl), @@ -571,7 +571,7 @@ function MovingHorizonEstimator( gc ::Function = gc!, nc ::Int = 0, p = model.p, - transcription::TranscriptionMethod = default_transcription(model), + transcription::TranscriptionMethod = default_transcription_mhe(model), optim::JM = default_optim_mhe(model, nc), gradient::AbstractADType = DEFAULT_GRADIENT, jacobian::AbstractADType = default_jacobian(transcription), @@ -604,7 +604,7 @@ end gc!=(_,_,_,_,_,_,_,_,_,_,_,_) -> nothing, gc=gc!, nc=0, - transcription=default_transcription(model), + transcription=default_transcription_mhe(model), optim=default_optim_mhe(model, nc), gradient=AutoForwardDiff(), jacobian=AutoForwardDiff(), @@ -625,7 +625,7 @@ function MovingHorizonEstimator( gc ::Function = gc!, nc = 0, p = model.p, - transcription::TranscriptionMethod = default_transcription(model), + transcription::TranscriptionMethod = default_transcription_mhe(model), optim::JM = default_optim_mhe(model, nc), gradient::AbstractADType = DEFAULT_GRADIENT, jacobian::AbstractADType = default_jacobian(transcription), @@ -657,6 +657,10 @@ function MovingHorizonEstimator( ) end +"Default to `Singlehooting()`, or `model.transcription` if `model` is a `NonLinModelDAE`." +default_transcription_mhe(::SimModel) = MultipleShooting() +default_transcription_mhe(model::NonLinModelDAE) = model.transcription + "Default optimizer for MHE, depending on the model and the number of custom NL constraints." function default_optim_mhe(model::SimModel, nc) if model isa LinModel && iszero(nc) diff --git a/src/model/nonlinmodeldae.jl b/src/model/nonlinmodeldae.jl index dcb1c4e6c..9113b2edf 100644 --- a/src/model/nonlinmodeldae.jl +++ b/src/model/nonlinmodeldae.jl @@ -410,10 +410,6 @@ function validate_strictly_proper(NT, fq!, h!, nu, nx, na, ny, nd, p) return iszero_Ha end -"Default to `MultipleShooting()`, or `model.transcription` if `model` is a `NonLinModelDAE`." -default_transcription(::SimModel) = MultipleShooting() -default_transcription(model::NonLinModelDAE) = model.transcription - "Get the number of algebraic variable `na` in `model`." get_na(model::NonLinModelDAE) = model.na get_na(::SimModel) = 0 diff --git a/src/sim_model.jl b/src/sim_model.jl index e1eb593c9..28d3e20f4 100644 --- a/src/sim_model.jl +++ b/src/sim_model.jl @@ -399,6 +399,8 @@ end "Get length of the `k̄` vector with all the solver intermediate steps or all the collocation pts." get_nk̄(model::SimModel, ::ShootingMethod) = model.nk̄ get_nk̄(model::SimModel, transcription::CollocationMethod) = model.nx*transcription.no +get_nk̄(model::SimModelDAE) = model.nx*model.transcription.no +get_nk̄(model::SimModelODE) = model.nk̄ include("model/linmodel.jl") include("model/linearization.jl") From b1930a8b2f95071cb0e9de76426793e5d9ac4d7f Mon Sep 17 00:00:00 2001 From: franckgaga Date: Wed, 2 Dec 2026 09:13:47 -0500 Subject: [PATCH 13/15] debug: idem --- src/estimator/mhe/construct.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/estimator/mhe/construct.jl b/src/estimator/mhe/construct.jl index 9c426400f..1f4c0cb40 100644 --- a/src/estimator/mhe/construct.jl +++ b/src/estimator/mhe/construct.jl @@ -658,7 +658,7 @@ function MovingHorizonEstimator( end "Default to `Singlehooting()`, or `model.transcription` if `model` is a `NonLinModelDAE`." -default_transcription_mhe(::SimModel) = MultipleShooting() +default_transcription_mhe(::SimModel) = SingleShooting() default_transcription_mhe(model::NonLinModelDAE) = model.transcription "Default optimizer for MHE, depending on the model and the number of custom NL constraints." From 7d87fc22aade1b09cdff77cc02092485528bfc55 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Wed, 2 Dec 2026 09:37:08 -0500 Subject: [PATCH 14/15] doc: update `jldoctest` --- src/controller/nonlinmpc.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controller/nonlinmpc.jl b/src/controller/nonlinmpc.jl index a2dfcba34..585884fca 100644 --- a/src/controller/nonlinmpc.jl +++ b/src/controller/nonlinmpc.jl @@ -253,10 +253,10 @@ julia> mpc = NonLinMPC(model, Hp=20, Hc=10, transcription=SingleShooting()) NonLinMPC controller with a sample time Ts = 5.0 s: ├ estimator: UnscentedKalmanFilter ├ model: NonLinModel -├ optimizer: Ipopt +├ optimizer: Ipopt ├ transcription: SingleShooting ├ gradient: AutoForwardDiff -├ jacobian: AutoSparse (AutoForwardDiff, TracerSparsityDetector, GreedyColoringAlgorithm) +├ jacobian: AutoForwardDiff ├ hessian: nothing └ dimensions: │ ├ 20 prediction steps Hp @@ -267,11 +267,11 @@ NonLinMPC controller with a sample time Ts = 5.0 s: │ ├ 0 unmeasured outputs yu │ └ 0 measured disturbances d └ optimization: - ├ 51 decision variables Z̃ (1 slack variable, 1 bounds) + ├ 11 decision variables Z̃ (1 slack variable, 1 bounds) ├ 0 linear inequality constraints A (0 custom) - ├ 20 linear equality constraints Aeq + ├ 0 linear equality constraints Aeq ├ 0 nonlinear inequality constraints g (0 custom) - └ 20 nonlinear equality constraints geq + └ 0 nonlinear equality constraints geq ``` # Extended Help From c079eb02bbefcace7032257c8a3c4970299f664d Mon Sep 17 00:00:00 2001 From: franckgaga Date: Wed, 2 Dec 2026 09:53:47 -0500 Subject: [PATCH 15/15] doc: idem --- src/controller/nonlinmpc.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controller/nonlinmpc.jl b/src/controller/nonlinmpc.jl index 585884fca..2d0c4cb11 100644 --- a/src/controller/nonlinmpc.jl +++ b/src/controller/nonlinmpc.jl @@ -398,10 +398,10 @@ julia> mpc = NonLinMPC(estim, Hp=20, Cwt=1e4) NonLinMPC controller with a sample time Ts = 5.0 s: ├ estimator: UnscentedKalmanFilter ├ model: NonLinModel -├ optimizer: Ipopt -├ transcription: SingleShooting +├ optimizer: Ipopt +├ transcription: MultipleShooting ├ gradient: AutoForwardDiff -├ jacobian: AutoForwardDiff +├ jacobian: AutoSparse (AutoForwardDiff, TracerSparsityDetector, GreedyColoringAlgorithm) ├ hessian: nothing └ dimensions: │ ├ 20 prediction steps Hp @@ -412,11 +412,11 @@ NonLinMPC controller with a sample time Ts = 5.0 s: │ ├ 0 unmeasured outputs yu │ └ 0 measured disturbances d └ optimization: - ├ 3 decision variables Z̃ (1 slack variable, 1 bounds) - ├ 0 linear inequality constraints A (0 custom) - ├ 0 linear equality constraints Aeq - ├ 0 nonlinear inequality constraints g (0 custom) - └ 0 nonlinear equality constraints geq + ├ 43 decision variables Z̃ (1 slack variable, 1 bounds) + ├ 0 linear inequality constraints A (0 custom) + ├ 20 linear equality constraints Aeq + ├ 0 nonlinear inequality constraints g (0 custom) + └ 20 nonlinear equality constraints geq ``` """ function NonLinMPC(