@@ -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, ΔŨ, Z̃ )
158+ J = obj_nonlinprog! (Ŷ0, U0, mpc, Ue, Ŷe, ΔŨ)
159159 Ŷs = similar (mpc. Yop)
160160 predictstoch! (Ŷs, mpc, mpc. estim)
161161 info[:ΔU ] = Z̃[1 : mpc. Hc* model. nu]
@@ -387,15 +387,18 @@ end
387387iszero_nc (mpc:: PredictiveController ) = (mpc. con. nc == 0 )
388388
389389"""
390- obj_nonlinprog!(Ȳ, Ū, mpc::PredictiveController, model::SimModel, Ue, Ŷe, ΔŨ, Z̃ )
390+ obj_nonlinprog!(Ȳ, Ū, mpc::PredictiveController, Ue, Ŷe, ΔŨ)
391391
392392Nonlinear programming objective method when `model` is not a [`LinModel`](@ref). The
393393function `dot(x, A, x)` is a performant way of calculating `x'*A*x`. This method mutates
394394`Ȳ` and `Ū` arguments, without assuming any initial values (it recuperates the values in
395395`Ŷe` and `Ue` arguments).
396+
397+ Note that a specialized version on [`LinModel`](@ref) that uses the Hessian matrix `mpc.H̃`
398+ is actually slower in the [`MultipleShooting`](@ref) case, so only one method is defined.
396399"""
397400function obj_nonlinprog! (
398- Ȳ, Ū, mpc:: PredictiveController , model :: SimModel , Ue, Ŷe, ΔŨ, :: AbstractVector{NT}
401+ Ȳ, Ū, mpc:: PredictiveController , Ue, Ŷe, ΔŨ:: AbstractVector{NT}
399402) where NT<: Real
400403 nu, ny = model. nu, model. ny
401404 # --- output setpoint tracking term ---
@@ -425,23 +428,6 @@ function obj_nonlinprog!(
425428 return JR̂y + JΔŨ + JR̂u + E_JE
426429end
427430
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-
445431" No custom nonlinear constraints `gc` by default, return `gc` unchanged."
446432con_custom! (gc, :: PredictiveController , _ , _, _ ) = gc
447433
0 commit comments