@@ -635,35 +635,41 @@ function setmodel!(
635635 for i= 1 : ny* Hp
636636 mpc. weights. M_Hp[i, i] = Mwt[(i- 1 ) % ny + 1 ]
637637 end
638+ mpc. weights. iszero_M_Hp[] = iszero(mpc. weights. M_Hp)
638639 elseif ! isnothing(M_Hp)
639640 M_Hp = to_hermitian(M_Hp)
640641 nŶ = ny* Hp
641642 size(M_Hp) == (nŶ, nŶ) || throw(ArgumentError(" M_Hp size should be ($nŶ , $nŶ )" ))
642643 mpc. weights. M_Hp .= M_Hp
644+ mpc. weights. iszero_M_Hp[] = iszero(mpc. weights. M_Hp)
643645 end
644646 if isnothing(Ñ_Hc) && ! isnothing(Nwt)
645647 size(Nwt) == (nu,) || throw(ArgumentError(" Nwt should be a vector of length $nu " ))
646648 any(x -> x < 0 , Nwt) && throw(ArgumentError(" Nwt values should be nonnegative" ))
647649 for i= 1 : nu* Hc
648650 mpc. weights. Ñ_Hc[i, i] = Nwt[(i- 1 ) % nu + 1 ]
649651 end
652+ mpc. weights. iszero_Ñ_Hc[] = iszero(mpc. weights. Ñ_Hc)
650653 elseif ! isnothing(Ñ_Hc)
651654 Ñ_Hc = to_hermitian(Ñ_Hc)
652655 nΔŨ = nu* Hc+ nϵ
653656 size(Ñ_Hc) == (nΔŨ, nΔŨ) || throw(ArgumentError(" Ñ_Hc size should be ($nΔŨ , $nΔŨ )" ))
654657 mpc. weights. Ñ_Hc .= Ñ_Hc
658+ mpc. weights. iszero_Ñ_Hc[] = iszero(mpc. weights. Ñ_Hc)
655659 end
656660 if isnothing(L_Hp) && ! isnothing(Lwt)
657661 size(Lwt) == (nu,) || throw(ArgumentError(" Lwt should be a vector of length $nu " ))
658662 any(x -> x < 0 , Lwt) && throw(ArgumentError(" Lwt values should be nonnegative" ))
659663 for i= 1 : nu* Hp
660664 mpc. weights. L_Hp[i, i] = Lwt[(i- 1 ) % nu + 1 ]
661665 end
666+ mpc. weights. iszero_L_Hp[] = iszero(mpc. weights. L_Hp)
662667 elseif ! isnothing(L_Hp)
663668 L_Hp = to_hermitian(L_Hp)
664669 nU = nu* Hp
665670 size(L_Hp) == (nU, nU) || throw(ArgumentError(" L_Hp size should be ($nU , $nU )" ))
666671 mpc. weights. L_Hp .= L_Hp
672+ mpc. weights. iszero_L_Hp[] = iszero(mpc. weights. L_Hp)
667673 end
668674 setmodel_controller!(mpc, x̂op_old)
669675 return mpc
0 commit comments