From 533955404cd8f89b0eb14542516f1261bed85b57 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Fri, 13 Mar 2026 11:15:07 -0400 Subject: [PATCH 1/4] =?UTF-8?q?added:=20current=20state=20estimate=20`x?= =?UTF-8?q?=CC=82`=20=20in=20`getinfo`=20for=20MPC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/execute.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/controller/execute.jl b/src/controller/execute.jl index 7a2ed1fb8..1ad704341 100644 --- a/src/controller/execute.jl +++ b/src/controller/execute.jl @@ -93,6 +93,7 @@ The function should be called after calling [`moveinput!`](@ref). It returns the - `:ΔU` or *`:DeltaU`* : optimal manipulated input increments over ``H_c``, ``\mathbf{ΔU}`` - `:ϵ` or *`:epsilon`* : optimal slack variable, ``ϵ`` - `:D̂` or *`:Dhat`* : predicted measured disturbances over ``H_p``, ``\mathbf{D̂}`` +- `:x̂` or *`:xhat`* : current estimated state, ``\mathbf{x̂}_i(k)`` - `:ŷ` or *`:yhat`* : current estimated output, ``\mathbf{ŷ}(k)`` - `:Ŷ` or *`:Yhat`* : optimal predicted outputs over ``H_p``, ``\mathbf{Ŷ}`` - `:Ŷs` or *`:Yhats`* : predicted stochastic output over ``H_p`` of [`InternalModel`](@ref), ``\mathbf{Ŷ_s}`` @@ -167,6 +168,7 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real info[:u] = info[:U][1:model.nu] info[:d] = mpc.d0 + model.dop info[:D̂] = D̂ + info[:x̂] = mpc.estim.x̂0 .+ mpc.estim.x̂op info[:ŷ] = mpc.ŷ info[:Ŷ] = Ŷ info[:x̂end] = x̂0end + mpc.estim.x̂op @@ -177,6 +179,7 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real info[:DeltaU] = info[:ΔU] info[:epsilon] = info[:ϵ] info[:Dhat] = info[:D̂] + info[:xhat] = info[:x̂] info[:yhat] = info[:ŷ] info[:Yhat] = info[:Ŷ] info[:xhatend] = info[:x̂end] From e3c723a96084084f649f56e41feef0b3b94b272f Mon Sep 17 00:00:00 2001 From: franckgaga Date: Fri, 13 Mar 2026 11:21:18 -0400 Subject: [PATCH 2/4] added: last manipulated input `lastu` in `getinfo` for MPC --- src/controller/execute.jl | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/controller/execute.jl b/src/controller/execute.jl index 1ad704341..ed3212eb3 100644 --- a/src/controller/execute.jl +++ b/src/controller/execute.jl @@ -100,10 +100,11 @@ The function should be called after calling [`moveinput!`](@ref). It returns the - `:R̂y` or *`:Rhaty`* : predicted output setpoint over ``H_p``, ``\mathbf{R̂_y}`` - `:R̂u` or *`:Rhatu`* : predicted manipulated input setpoint over ``H_p``, ``\mathbf{R̂_u}`` - `:x̂end` or *`:xhatend`* : optimal terminal states, ``\mathbf{x̂}_i(k+H_p)`` -- `:J` : objective value optimum, ``J`` -- `:U` : optimal manipulated inputs over ``H_p``, ``\mathbf{U}`` -- `:u` : current optimal manipulated input, ``\mathbf{u}(k)`` -- `:d` : current measured disturbance, ``\mathbf{d}(k)`` +- `:J` : objective value optimum, ``J`` +- `:U` : optimal manipulated inputs over ``H_p``, ``\mathbf{U}`` +- `:u` : current optimal manipulated input, ``\mathbf{u}(k)`` +- `:d` : current measured disturbance, ``\mathbf{d}(k)`` +- `:lastu` : last manipulated input, ``\mathbf{u}(k-1)`` For [`LinMPC`](@ref) and [`NonLinMPC`](@ref), the following fields are also available: @@ -161,20 +162,21 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real J = obj_nonlinprog!(Ŷ0, U0, mpc, Ue, Ŷe, ΔŨ) Ŷs = similar(mpc.Yop) predictstoch!(Ŷs, mpc, mpc.estim) - info[:ΔU] = Z̃[1:mpc.Hc*model.nu] - info[:ϵ] = getϵ(mpc, Z̃) - info[:J] = J - info[:U] = U - info[:u] = info[:U][1:model.nu] - info[:d] = mpc.d0 + model.dop - info[:D̂] = D̂ - info[:x̂] = mpc.estim.x̂0 .+ mpc.estim.x̂op - info[:ŷ] = mpc.ŷ - info[:Ŷ] = Ŷ - info[:x̂end] = x̂0end + mpc.estim.x̂op - info[:Ŷs] = Ŷs - info[:R̂y] = mpc.R̂y - info[:R̂u] = mpc.R̂u + info[:ΔU] = Z̃[1:mpc.Hc*model.nu] + info[:ϵ] = getϵ(mpc, Z̃) + info[:J] = J + info[:U] = U + info[:u] = info[:U][1:model.nu] + info[:lastu] = mpc.lastu0 .+ model.uop + info[:d] = mpc.d0 + model.dop + info[:D̂] = D̂ + info[:x̂] = mpc.estim.x̂0 .+ mpc.estim.x̂op + info[:ŷ] = mpc.ŷ + info[:Ŷ] = Ŷ + info[:x̂end] = x̂0end + mpc.estim.x̂op + info[:Ŷs] = Ŷs + info[:R̂y] = mpc.R̂y + info[:R̂u] = mpc.R̂u # --- non-Unicode fields --- info[:DeltaU] = info[:ΔU] info[:epsilon] = info[:ϵ] From 4cb6bdf57c35785c7fc7e74a5538a6a0ef1bc7e3 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Fri, 13 Mar 2026 11:22:23 -0400 Subject: [PATCH 3/4] added: hide `xhat` key in debug log --- src/general.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/general.jl b/src/general.jl index 13a6c3580..41216be6e 100644 --- a/src/general.jl +++ b/src/general.jl @@ -22,7 +22,7 @@ const HIDDEN_GETINFO_KEYS_MHE = ( ) const HIDDEN_GETINFO_KEYS_MPC = ( - :DeltaU, :epsilon, :Dhat, :yhat, :Yhat, :xhatend, :Yhats, :Rhaty, :Rhatu, + :DeltaU, :epsilon, :Dhat, :xhat, :yhat, :Yhat, :xhatend, :Yhats, :Rhaty, :Rhatu, :nablaJ, :nabla2J, :nablag, :nabla2lg, :nablageq, :nabla2lgeq ) From dd66aed06a745011cd045c20d0c57f781db6dd98 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Fri, 13 Mar 2026 11:23:02 -0400 Subject: [PATCH 4/4] bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 53203217d..8d4726f48 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ModelPredictiveControl" uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c" -version = "2.1.2" +version = "2.2.0" authors = ["Francis Gagnon"] [deps]