@@ -155,7 +155,7 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
155155 U .= U0 .+ mpc. Uop
156156 Ŷ .= Ŷ0 .+ mpc. Yop
157157 D̂ .= mpc. D̂0 + mpc. Dop
158- J = obj_nonlinprog! (Ŷ0, U0, mpc, model, Ue, Ŷe, ΔŨ)
158+ J = obj_nonlinprog! (Ŷ0, U0, mpc, model, Ue, Ŷe, ΔŨ, Z̃ )
159159 Ŷs = similar (mpc. Yop)
160160 predictstoch! (Ŷs, mpc, mpc. estim)
161161 info[:ΔU ] = Z̃[1 : mpc. Hc* model. nu]
@@ -387,32 +387,15 @@ end
387387iszero_nc (mpc:: PredictiveController ) = (mpc. con. nc == 0 )
388388
389389"""
390- obj_nonlinprog!( _ , _ , mpc::PredictiveController, model::LinModel, Ue, Ŷe, _ , Z̃)
391-
392- Nonlinear programming objective function when `model` is a [`LinModel`](@ref).
393-
394- The method is called by the nonlinear optimizer of [`NonLinMPC`](@ref) controllers. It can
395- also be called on any [`PredictiveController`](@ref)s to evaluate the objective function `J`
396- at specific `Ue`, `Ŷe` and `Z̃`, values. It does not mutate any argument.
397- """
398- function obj_nonlinprog! (
399- _, _, mpc:: PredictiveController , model:: LinModel , Ue, Ŷe, _ , Z̃:: AbstractVector{NT}
400- ) where NT <: Real
401- JQP = obj_quadprog (Z̃, mpc. H̃, mpc. q̃) + mpc. r[]
402- E_JE = obj_econ (mpc, model, Ue, Ŷe)
403- return JQP + E_JE
404- end
405-
406- """
407- obj_nonlinprog!(Ȳ, Ū, mpc::PredictiveController, model::SimModel, Ue, Ŷe, ΔŨ)
390+ obj_nonlinprog!(Ȳ, Ū, mpc::PredictiveController, model::SimModel, Ue, Ŷe, ΔŨ, Z̃)
408391
409392Nonlinear programming objective method when `model` is not a [`LinModel`](@ref). The
410393function `dot(x, A, x)` is a performant way of calculating `x'*A*x`. This method mutates
411394`Ȳ` and `Ū` arguments, without assuming any initial values (it recuperates the values in
412395`Ŷe` and `Ue` arguments).
413396"""
414397function obj_nonlinprog! (
415- Ȳ, Ū, mpc:: PredictiveController , model:: SimModel , Ue, Ŷe, ΔŨ:: AbstractVector{NT}
398+ Ȳ, Ū, mpc:: PredictiveController , model:: SimModel , Ue, Ŷe, ΔŨ, :: AbstractVector{NT}
416399) where NT<: Real
417400 nu, ny = model. nu, model. ny
418401 # --- output setpoint tracking term ---
@@ -442,6 +425,23 @@ function obj_nonlinprog!(
442425 return JR̂y + JΔŨ + JR̂u + E_JE
443426end
444427
428+ """
429+ obj_nonlinprog!( _ , _ , mpc::PredictiveController, model::LinModel, Ue, Ŷe, ΔŨ, Z̃)
430+
431+ Nonlinear programming objective function when `model` is a [`LinModel`](@ref).
432+
433+ The method is called by the nonlinear optimizer of [`NonLinMPC`](@ref) controllers. It can
434+ also be called on any [`PredictiveController`](@ref)s to evaluate the objective function `J`
435+ at specific `Ue`, `Ŷe` and `Z̃`, values. It does not mutate any argument.
436+ """
437+ function obj_nonlinprog! (
438+ _, _, mpc:: PredictiveController , model:: LinModel , Ue, Ŷe, _ , Z̃:: AbstractVector{NT}
439+ ) where NT <: Real
440+ JQP = obj_quadprog (Z̃, mpc. H̃, mpc. q̃) + mpc. r[]
441+ E_JE = obj_econ (mpc, model, Ue, Ŷe)
442+ return JQP + E_JE
443+ end
444+
445445" No custom nonlinear constraints `gc` by default, return `gc` unchanged."
446446con_custom! (gc, :: PredictiveController , _ , _, _ ) = gc
447447
0 commit comments