@@ -607,32 +607,32 @@ end
607607
608608@doc raw """
609609 predict!(
610- Ŷ0, x̂0 , _, _, _,
610+ Ŷ0, x̂0next , _, _, _,
611611 mpc::PredictiveController, model::LinModel, transcription::TranscriptionMethod,
612612 Z̃
613613 ) -> Ŷ0, x̂0end
614614
615615Compute the predictions `Ŷ0` and terminal states `x̂0end` if model is a [`LinModel`](@ref).
616616
617- The method mutates `Ŷ0` and `x̂0 ` vector arguments. The `x̂end` vector is used for
617+ The method mutates `Ŷ0` and `x̂0next ` vector arguments. The `x̂end` vector is used for
618618the terminal constraints applied on ``\m athbf{x̂}_{k-1}(k+H_p)``. The computations are
619619identical for any [`TranscriptionMethod`](@ref).
620620"""
621621function predict! (
622- Ŷ0, x̂0 , _ , _ , _ ,
622+ Ŷ0, x̂0next , _ , _ , _ ,
623623 mpc:: PredictiveController , :: LinModel , :: TranscriptionMethod ,
624624 Z̃
625625)
626626 # in-place operations to reduce allocations :
627- Ŷ0 .= mul! (Ŷ0, mpc. Ẽ, Z̃) .+ mpc. F
628- x̂0 . = mul! (x̂0, mpc . con . ẽx̂, Z̃) .+ mpc . con . fx̂
629- x̂0end = x̂0
627+ Ŷ0 .= mul! (Ŷ0, mpc. Ẽ, Z̃) .+ mpc. F
628+ x̂0end = x̂0next
629+ x̂0end . = mul! (x̂0end, mpc . con . ẽx̂, Z̃) .+ mpc . con . fx̂
630630 return Ŷ0, x̂0end
631631end
632632
633633@doc raw """
634634 predict!(
635- Ŷ0, x̂0, x̂0next , u0, û0,
635+ Ŷ0, x̂0next, x̂0 , u0, û0,
636636 mpc::PredictiveController, model::NonLinModel, transcription::SingleShooting,
637637 Z̃
638638 ) -> Ŷ0, x̂0end
@@ -642,7 +642,7 @@ Compute vectors if `model` is a [`NonLinModel`](@ref) and for [`SingleShooting`]
642642The method mutates `Ŷ0`, `x̂0`, `x̂0next`, `u0` and `û0` arguments.
643643"""
644644function predict! (
645- Ŷ0, x̂0, x̂0next , u0, û0,
645+ Ŷ0, x̂0next, x̂0 , u0, û0,
646646 mpc:: PredictiveController , model:: NonLinModel , :: SingleShooting ,
647647 Z̃
648648)
@@ -663,37 +663,38 @@ function predict!(
663663 ŷ0 = @views Ŷ0[(1 + ny* (j- 1 )): (ny* j)]
664664 ĥ! (ŷ0, mpc. estim, model, x̂0, d0)
665665 end
666- Ŷ0 .+ = mpc. F # F = Ŷs if mpc.estim is an InternalModel, else F = 0.
667- x̂0end = x̂0
666+ Ŷ0 .+ = mpc. F # F = Ŷs if mpc.estim is an InternalModel, else F = 0.
667+ x0end = x0next
668668 return Ŷ0, x̂0end
669669end
670670
671671@doc raw """
672672 predict!(
673- Ŷ0, x̂0 , _ , _ , _ ,
673+ Ŷ0, x̂0next , _ , _ , _ ,
674674 mpc::PredictiveController, model::NonLinModel, transcription::MultipleShooting,
675675 Z̃
676676 ) -> Ŷ0, x̂0end
677677
678678Compute vectors if `model` is a [`NonLinModel`](@ref) and for [`MultipleShooting`](@ref).
679679
680- The method mutates `Ŷ0` and `x̂0 ` arguments.
680+ The method mutates `Ŷ0` and `x̂0next ` arguments.
681681"""
682682function predict! (
683- Ŷ0, x̂0, x̂0next, u0, û0 ,
683+ Ŷ0, x̂0next, _, _, _ ,
684684 mpc:: PredictiveController , model:: NonLinModel , :: MultipleShooting ,
685685 Z̃
686686)
687687 nu, ny, nd, nx̂, Hp, Hc = model. nu, model. ny, model. nd, mpc. estim. nx̂, mpc. Hp, mpc. Hc
688688 X̂0 = @views Z̃[(nu* Hc+ 1 ): (nu* Hc+ nx̂* Hp)] # Z̃ = [ΔU; X̂0; ϵ]
689689 D̂0 = mpc. D̂0
690690 for j= 1 : Hp
691- x̂0 . = @views X̂0[(1 + nx̂* (j- 1 )): (nx̂* j)]
692- d0 = @views D̂0[(1 + nd* (j- 1 )): (nd* j)]
693- ŷ0 = @views Ŷ0[(1 + ny* (j- 1 )): (ny* j)]
691+ x̂0 = @views X̂0[(1 + nx̂* (j- 1 )): (nx̂* j)]
692+ d0 = @views D̂0[(1 + nd* (j- 1 )): (nd* j)]
693+ ŷ0 = @views Ŷ0[(1 + ny* (j- 1 )): (ny* j)]
694694 ĥ! (ŷ0, mpc. estim, model, x̂0, d0)
695695 end
696- Ŷ0 .+ = mpc. F # F = Ŷs if mpc.estim is an InternalModel, else F = 0.
697- x̂0end = x̂0
696+ Ŷ0 .+ = mpc. F # F = Ŷs if mpc.estim is an InternalModel, else F = 0.
697+ x̂0end = x̂0next
698+ x̂0end .= x̂0
698699 return Ŷ0, x̂0end
699700end
0 commit comments