@@ -123,19 +123,19 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
123123 x̂0end = similar (mpc. estim. x̂0)
124124 Ue, Ŷe = Vector {NT} (undef, nUe), Vector {NT} (undef, nŶe)
125125 U0, Ŷ0 = similar (mpc. Uop), similar (mpc. Yop)
126- X̂0, Û0 = Vector {NT} (undef, nX̂0 ), Vector {NT} (undef, nÛ0 )
126+ Û0, X̂0 = Vector {NT} (undef, nÛ0 ), Vector {NT} (undef, nX̂0 )
127127 U, Ŷ = similar (mpc. Uop), similar (mpc. Yop)
128- Ŷs = similar (mpc. Yop)
129128 U0 = getU0! (U0, mpc, Z̃)
130- ΔŨ = getΔŨ! (ΔŨ, mpc, mpc . transcription, Z̃)
129+ ΔŨ = getΔŨ! (ΔŨ, mpc, transcription, Z̃)
131130 Ŷ0, x̂0end = predict! (Ŷ0, x̂0end, X̂0, Û0, mpc, model, transcription, U0, Z̃)
132131 Ue, Ŷe = extended_vectors! (Ue, Ŷe, mpc, U0, Ŷ0)
133132 U .= U0 .+ mpc. Uop
134133 Ŷ .= Ŷ0 .+ mpc. Yop
135134 J = obj_nonlinprog! (Ŷ0, U0, mpc, model, Ue, Ŷe, ΔŨ)
135+ Ŷs = similar (mpc. Yop)
136136 predictstoch! (Ŷs, mpc, mpc. estim)
137137 info[:ΔU ] = Z̃[1 : mpc. Hc* model. nu]
138- info[:ϵ ] = mpc. nϵ == 1 ? mpc . Z̃[ end ] : zero (NT )
138+ info[:ϵ ] = getϵ ( mpc, Z̃ )
139139 info[:J ] = J
140140 info[:U ] = U
141141 info[:u ] = info[:U ][1 : model. nu]
@@ -161,6 +161,15 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
161161 return info
162162end
163163
164+ """
165+ getϵ(mpc::PredictiveController, Z̃) -> ϵ
166+
167+ Get the slack `ϵ` from the decision vector `Z̃` if present, otherwise return 0.
168+ """
169+ function getϵ (mpc:: PredictiveController , Z̃:: AbstractVector{NT} ) where NT<: Real
170+ return mpc. nϵ ≠ 0 ? Z̃[end ] : zero (NT)
171+ end
172+
164173"""
165174 addinfo!(info, mpc::PredictiveController) -> info
166175
@@ -361,6 +370,9 @@ function obj_nonlinprog!(
361370 return JR̂y + JΔŨ + JR̂u + E_JE
362371end
363372
373+ " No custom nonlinear constraints `gc` by default, return `gc` unchanged."
374+ con_custom! (gc, :: PredictiveController , _ , _, _ ) = gc
375+
364376" By default, the economic term is zero."
365377function obj_econ (:: PredictiveController , :: SimModel , _ , :: AbstractVector{NT} ) where NT
366378 return zero (NT)
0 commit comments