@@ -787,7 +787,7 @@ function linconstraint!(mpc::PredictiveController, model::LinModel, ::Transcript
787787 mul!(fx̂, mpc. con. gx̂, mpc. d0, 1 , 1 )
788788 mul!(fx̂, mpc. con. jx̂, mpc. D̂0, 1 , 1 )
789789 end
790- mpc . con . nw > 0 && linconstraint_custom!(mpc, model)
790+ linconstraint_custom!(mpc, model)
791791 n = 0
792792 mpc. con. b[(n+ 1 ): (n+ nU)] .= @. - mpc. con. U0min + mpc. Tu_lastu0
793793 n += nU
@@ -816,12 +816,12 @@ function linconstraint!(mpc::PredictiveController, model::LinModel, ::Transcript
816816end
817817
818818" Set `b` excluding predicted output constraints for `NonLinModel` and not `SingleShooting`."
819- function linconstraint!(mpc:: PredictiveController , :: NonLinModel , :: TranscriptionMethod )
819+ function linconstraint!(mpc:: PredictiveController , model :: NonLinModel , :: TranscriptionMethod )
820820 nU, nΔŨ = length(mpc. con. U0min), length(mpc. con. ΔŨmin)
821821 nW = length(mpc. con. Wmin)
822822 nx̂ = mpc. estim. nx̂
823823 # here, updating fx̂ is not necessary since fx̂ = 0
824- mpc . con . nw > 0 && linconstraint_custom!(mpc, model)
824+ linconstraint_custom!(mpc, model)
825825 n = 0
826826 mpc. con. b[(n+ 1 ): (n+ nU)] .= @. - mpc. con. U0min + mpc. Tu_lastu0
827827 n += nU
@@ -845,10 +845,10 @@ function linconstraint!(mpc::PredictiveController, ::NonLinModel, ::Transcriptio
845845end
846846
847847" Also exclude terminal constraints for `NonLinModel` and `SingleShooting`."
848- function linconstraint!(mpc:: PredictiveController , :: NonLinModel , :: SingleShooting )
848+ function linconstraint!(mpc:: PredictiveController , model :: NonLinModel , :: SingleShooting )
849849 nU, nΔŨ = length(mpc. con. U0min), length(mpc. con. ΔŨmin)
850850 nW = length(mpc. con. Wmin)
851- mpc . con . nw > 0 && linconstraint_custom!(mpc, model)
851+ linconstraint_custom!(mpc, model)
852852 n = 0
853853 mpc. con. b[(n+ 1 ): (n+ nU)] .= @. - mpc. con. U0min + mpc. Tu_lastu0
854854 n += nU
@@ -868,38 +868,6 @@ function linconstraint!(mpc::PredictiveController, ::NonLinModel, ::SingleShooti
868868 return nothing
869869end
870870
871- " Init the ``\\ mathbf{F_w}`` vector for the linear model custom inequality constraints."
872- function linconstraint_custom!(mpc:: PredictiveController , model:: SimModel )
873- ny, nu, nd, buffer = model. ny, model. nu, model. nd, mpc. buffer
874- Fw = mpc. con. Fw
875- Ue_term, D̂e_term, R̂e_term = buffer. Ue, buffer. D̂e, buffer. Ŷe
876- Fw .= 0
877- Ue_term[1 : end - nu] .= mpc. Tu_lastu0 .+ mpc. Uop
878- Ue_term[end - nu+ 1 : end ] .= mpc. lastu0 .+ model. uop
879- mul!(Fw, mpc. con. W̄u, Ue_term, 1 , 1 )
880- if model. nd > 0
881- D̂e_term[1 : nd] .= mpc. d0 .+ model. dop
882- D̂e_term[nd+ 1 : end ] .= mpc. D̂0 .+ mpc. Dop
883- mul!(Fw, mpc. con. W̄d, D̂e_term, 1 , 1 )
884- end
885- R̂e_term[1 : ny] .= mpc. ry
886- R̂e_term[ny+ 1 : end ] .= mpc. R̂y
887- mul!(Fw, mpc. con. W̄r, R̂e_term, 1 , 1 )
888- return linconstraint_custom_outputs!(mpc, model)
889- end
890-
891- " Also include the `W̄y` term in the custom linear constraints for [`LinModel`](@ref)."
892- function linconstraint_custom_outputs!(mpc:: PredictiveController , model:: LinModel )
893- Ŷe_term, Fw, ny = mpc. buffer. Ŷe, mpc. con. Fw, model. ny
894- Ŷe_term[1 : ny] .= mpc. ŷ
895- Ŷe_term[ny+ 1 : end ] .= mpc. F .+ mpc. Yop
896- mul!(Fw, mpc. con. W̄y, Ŷe_term, 1 , 1 )
897- return nothing
898- end
899- " Do nothing for other model types."
900- linconstraint_custom_outputs!(:: PredictiveController , :: SimModel ) = nothing
901-
902-
903871@doc raw """
904872 linconstrainteq!(
905873 mpc::PredictiveController, model::LinModel, transcription::MultipleShooting
0 commit comments