Skip to content

Commit 3f17f0e

Browse files
committed
debug : getinfo on ExplicitMPC now works
1 parent 57f1b61 commit 3f17f0e

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelPredictiveControl"
22
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
33
authors = ["Francis Gagnon"]
4-
version = "1.1.4"
4+
version = "1.2.0"
55

66
[deps]
77
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"

src/controller/execute.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
124124
Ŷe, Ue = extended_predictions!(Ŷe, Ue, Ū, mpc, model, Ŷ0, mpc.ΔŨ)
125125
J = obj_nonlinprog!(Ȳ, Ū, mpc, model, Ue, Ŷe, mpc.ΔŨ)
126126
U, Ŷ = Ū, Ȳ
127-
U .= mul!(U, mpc.S̃, ΔŨ) .+ mpc.T_lastu
127+
U .= mul!(U, mpc.S̃, mpc.ΔŨ) .+ mpc.T_lastu
128128
Ŷ .= Ŷ0 .+ mpc.Yop
129129
oldF = copy(mpc.F)
130130
F = predictstoch!(mpc, mpc.estim)
@@ -390,14 +390,14 @@ special cases in which `Ŷe`, `Ue` and `Ū` are not mutated:
390390
"""
391391
function extended_predictions!(Ŷe, Ue, Ū, mpc, model, Ŷ0, ΔŨ)
392392
ny, nu = model.ny, model.nu
393-
nocustomfcts = (mpc.weights.iszero_E && mpc.con.nc==0)
393+
nocustomfonctions = (mpc.weights.iszero_E && iszero_nc(mpc))
394394
# --- extended output predictions Ŷe = [ŷ(k); Ŷ] ---
395-
if !(mpc.weights.iszero_M_Hp[] && nocustomfcts)
395+
if !(mpc.weights.iszero_M_Hp[] && mpc.nocustomfcts)
396396
Ŷe[1:ny] .= mpc.
397397
Ŷe[ny+1:end] .= Ŷ0 .+ mpc.Yop
398398
end
399399
# --- extended manipulated inputs Ue = [U; u(k+Hp-1)] ---
400-
if !(mpc.weights.iszero_L_Hp[] && nocustomfcts)
400+
if !(mpc.weights.iszero_L_Hp[] && mpc.nocustomfcts)
401401
U =
402402
U .= mul!(U, mpc.S̃, ΔŨ) .+ mpc.T_lastu
403403
Ue[1:end-nu] .= U
@@ -407,6 +407,9 @@ function extended_predictions!(Ŷe, Ue, Ū, mpc, model, Ŷ0, ΔŨ)
407407
return Ŷe, Ue
408408
end
409409

410+
"Verify if the custom nonlinear constraint has zero elements."
411+
iszero_nc(mpc::PredictiveController) = (mpc.con.nc == 0)
412+
410413
"""
411414
obj_nonlinprog!( _ , _ , mpc::PredictiveController, model::LinModel, Ue, Ŷe, ΔŨ)
412415

src/controller/explicitmpc.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ function predict!(Ŷ, x̂, _ , _ , _ , mpc::ExplicitMPC, ::LinModel, ΔŨ)
195195
return Ŷ, x̂
196196
end
197197

198+
"`ExplicitMPC` does not support custom nonlinear constraint, return `true`."
199+
iszero_nc(mpc::ExplicitMPC) = true
198200

199201
"""
200202
addinfo!(info, mpc::ExplicitMPC) -> info

0 commit comments

Comments
 (0)