Skip to content

Commit bb65ff1

Browse files
authored
Merge pull request #317 from JuliaControl/info_custom_linconstraint
added: custom linear constraint vector `W` in `getinfo` dict.
2 parents 7295588 + 531f564 commit bb65ff1

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/controller/execute.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,12 @@ The function should be called after calling [`moveinput!`](@ref). It returns the
104104
- `:u` : current optimal manipulated input, ``\mathbf{u}(k)``
105105
- `:d` : current measured disturbance, ``\mathbf{d}(k)``
106106
107-
For [`LinMPC`](@ref) and [`NonLinMPC`](@ref), the field `:sol` also contains the optimizer
108-
solution summary that can be printed. Lastly, for [`NonLinMPC`](@ref), the following fields
109-
are also available:
107+
For [`LinMPC`](@ref) and [`NonLinMPC`](@ref), the following fields are also available:
108+
109+
- `:W` : custom linear inequality constraint vector at the optimum, ``\mathbf{W}``.
110+
- `:sol` : a [solution summary](@extref JuMP solution_summary) that can be printed.
111+
112+
Lastly, the following fields are also available for [`NonLinMPC`](@ref) only:
110113
111114
- `:JE`: economic cost value at the optimum, ``J_E``
112115
- `:gc`: custom nonlinear constraints values at the optimum, ``\mathbf{g_c}``
@@ -194,9 +197,14 @@ end
194197
"""
195198
addinfo!(info, mpc::PredictiveController) -> info
196199
197-
By default, add the solution summary `:sol` that can be printed to `info`.
200+
By default, add the custom linear inrquality vector `W` and the solution summary `:sol` that
201+
can be printed to `info`.
198202
"""
199-
function addinfo!(info, mpc::PredictiveController)
203+
function addinfo!(info, mpc::PredictiveController{NT}) where NT<:Real
204+
nW = mpc.con.nw*(mpc.Hp+1)
205+
W = Vector{NT}(undef, nW)
206+
W .= mul!(W, mpc.con.Ẽw, mpc.Z̃) .+ mpc.con.Fw
207+
info[:W] = W
200208
info[:sol] = JuMP.solution_summary(mpc.optim, verbose=true)
201209
return info
202210
end

0 commit comments

Comments
 (0)