@@ -120,8 +120,8 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
120120 Ȳ, Ū = similar (mpc. Yop), similar (mpc. Uop)
121121 Ŷe, Ue = Vector {NT} (undef, nŶe), Vector {NT} (undef, nUe)
122122 Ŷ0, x̂0end = predict! (Ŷ0, x̂0, x̂0next, u0, û0, mpc, model, mpc. ΔŨ)
123- Ŷe, Ue = extended_predictions! (Ŷe, Ue , Ū, mpc, model, Ŷ0, mpc. ΔŨ)
124- J = obj_nonlinprog! (Ȳ, Ū, mpc, model, Ŷe, Ue , mpc. ΔŨ)
123+ Ue, Ŷe = extended_predictions! (Ue, Ŷe , Ū, mpc, model, Ŷ0, mpc. ΔŨ)
124+ J = obj_nonlinprog! (Ȳ, Ū, mpc, model, Ue, Ŷe , mpc. ΔŨ)
125125 U = Ū
126126 U .= @views Ue[1 : end - model. nu]
127127 Ŷ = Ȳ
@@ -362,28 +362,28 @@ function predict!(Ŷ0, x̂0, x̂0next, u0, û0, mpc::PredictiveController, mod
362362end
363363
364364"""
365- extended_predictions!(Ŷe, Ue , Ū, mpc, model, Ŷ0, ΔŨ) -> Ŷe, Ue
365+ extended_predictions!(Ue, Ŷe , Ū, mpc, model, Ŷ0, ΔŨ) -> Ŷe, Ue
366366
367- Compute the extended predictions `Ŷe ` and `Ue` for the nonlinear optimization.
367+ Compute the extended vectors `Ue ` and `Ŷe` and for the nonlinear optimization.
368368
369- The function mutates `Ŷe `, `Ue ` and `Ū` in arguments, without assuming any initial values.
369+ The function mutates `Ue `, `Ŷe ` and `Ū` in arguments, without assuming any initial values.
370370"""
371- function extended_predictions! (Ŷe, Ue , Ū, mpc, model, Ŷ0, ΔŨ)
371+ function extended_predictions! (Ue, Ŷe , Ū, mpc, model, Ŷ0, ΔŨ)
372372 ny, nu = model. ny, model. nu
373- # --- extended output predictions Ŷe = [ŷ(k); Ŷ] ---
374- Ŷe[1 : ny] .= mpc. ŷ
375- Ŷe[ny+ 1 : end ] .= Ŷ0 .+ mpc. Yop
376373 # --- extended manipulated inputs Ue = [U; u(k+Hp-1)] ---
377374 U0 = Ū
378375 U0 .= mul! (U0, mpc. S̃, ΔŨ) .+ mpc. T_lastu0
379376 Ue[1 : end - nu] .= U0 .+ mpc. Uop
380377 # u(k + Hp) = u(k + Hp - 1) since Δu(k+Hp) = 0 (because Hc ≤ Hp):
381378 Ue[end - nu+ 1 : end ] .= @views Ue[end - 2 nu+ 1 : end - nu]
382- return Ŷe, Ue
379+ # --- extended output predictions Ŷe = [ŷ(k); Ŷ] ---
380+ Ŷe[1 : ny] .= mpc. ŷ
381+ Ŷe[ny+ 1 : end ] .= Ŷ0 .+ mpc. Yop
382+ return Ue, Ŷe
383383end
384384
385385"""
386- obj_nonlinprog!( _ , _ , mpc::PredictiveController, model::LinModel, Ŷe, Ue , ΔŨ)
386+ obj_nonlinprog!( _ , _ , mpc::PredictiveController, model::LinModel, Ue, Ŷe , ΔŨ)
387387
388388Nonlinear programming objective function when `model` is a [`LinModel`](@ref).
389389
@@ -392,23 +392,23 @@ also be called on any [`PredictiveController`](@ref)s to evaluate the objective
392392at specific `Ue`, `Ŷe` and `ΔŨ`, values. It does not mutate any argument.
393393"""
394394function obj_nonlinprog! (
395- _, _, mpc:: PredictiveController , model:: LinModel , Ŷe, Ue , ΔŨ:: AbstractVector{NT}
395+ _, _, mpc:: PredictiveController , model:: LinModel , Ue, Ŷe , ΔŨ:: AbstractVector{NT}
396396) where NT <: Real
397397 JQP = obj_quadprog (ΔŨ, mpc. H̃, mpc. q̃) + mpc. r[]
398- E_JE = obj_econ! (Ue, Ŷe, mpc, model )
398+ E_JE = obj_econ (mpc, model, Ue, Ŷe )
399399 return JQP + E_JE
400400end
401401
402402"""
403- obj_nonlinprog!(Ȳ, Ū, mpc::PredictiveController, model::SimModel, Ŷe, Ue , ΔŨ)
403+ obj_nonlinprog!(Ȳ, Ū, mpc::PredictiveController, model::SimModel, Ue, Ŷe , ΔŨ)
404404
405405Nonlinear programming objective method when `model` is not a [`LinModel`](@ref). The
406406function `dot(x, A, x)` is a performant way of calculating `x'*A*x`. This method mutates
407407`Ȳ` and `Ū` arguments, without assuming any initial values (it recuperates the values in
408408`Ŷe` and `Ue` arguments).
409409"""
410410function obj_nonlinprog! (
411- Ȳ, Ū, mpc:: PredictiveController , model:: SimModel , Ŷe, Ue , ΔŨ:: AbstractVector{NT}
411+ Ȳ, Ū, mpc:: PredictiveController , model:: SimModel , Ue, Ŷe , ΔŨ:: AbstractVector{NT}
412412) where NT<: Real
413413 nu, ny = model. nu, model. ny
414414 # --- output setpoint tracking term ---
@@ -426,12 +426,12 @@ function obj_nonlinprog!(
426426 JR̂u = 0.0
427427 end
428428 # --- economic term ---
429- E_JE = obj_econ! (Ue, Ŷe, mpc, model )
429+ E_JE = obj_econ (mpc, model, Ue, Ŷe )
430430 return JR̂y + JΔŨ + JR̂u + E_JE
431431end
432432
433433" By default, the economic term is zero."
434- obj_econ! ( _ , _ , :: PredictiveController , :: SimModel ) = 0.0
434+ obj_econ ( :: PredictiveController , :: SimModel , _ , _ ) = 0.0
435435
436436@doc raw """
437437 optim_objective!(mpc::PredictiveController) -> ΔŨ
0 commit comments