@@ -1020,15 +1020,34 @@ end
10201020 He = 3
10211021 nx̂ = linmodel. nx
10221022 nc = nx̂* (He+ 1 )
1023- mhe = MovingHorizonEstimator (linmodel, nint_ym= 0 , Cwt= 1e5 , He= He, gc= gcl, nc= nc, p= nc)
1024- @test mhe. con. nc == nc
1025- @test mhe. nε > 0
1026- @test mhe. He == 3
1027-
1023+ mhe16 = MovingHorizonEstimator (linmodel, nint_ym= 0 , Cwt= 1e5 , He= He, gc= gcl, nc= nc, p= nc)
1024+ @test mhe16. con. nc == nc
1025+ @test mhe16. nε > 0
1026+ @test mhe16. He == 3
1027+
1028+ He, i_ym, nint_u, nint_ym = 1 , 1 : 2 , 0 , 0
1029+ P̂_0 = fill (0.5 , 4 , 4 )
1030+ P̂_0[diagind (P̂_0)] .= 1.0
1031+ Q̂, R̂ = 0.5 * P̂_0, [0.1 0.01 ; 0.01 0.1 ]
1032+ mhe17 = MovingHorizonEstimator (linmodel, He, i_ym, nint_u, nint_ym, P̂_0, Q̂, R̂)
1033+ @test mhe17. cov. invP̄ ≈ inv (P̂_0)
1034+ @test mhe17. cov. invQ̂_He ≈ inv (Q̂)
1035+ @test mhe17. cov. invR̂_He ≈ inv (R̂)
1036+
10281037 @test_throws ArgumentError MovingHorizonEstimator (linmodel)
10291038 @test_throws ArgumentError MovingHorizonEstimator (linmodel, He= 0 )
10301039 @test_throws ArgumentError MovingHorizonEstimator (linmodel, Cwt= - 1 )
10311040 @test_throws ArgumentError MovingHorizonEstimator (linmodel, He= 1 , σP_0= nothing )
1041+ @test_throws PosDefException MovingHorizonEstimator (
1042+ linmodel, He, i_ym, nint_u, nint_ym, zeros (4 , 4 ), Q̂, R̂
1043+ )
1044+ @test_throws PosDefException MovingHorizonEstimator (
1045+ linmodel, He, i_ym, nint_u, nint_ym, P̂_0, zeros (4 , 4 ), R̂
1046+ )
1047+ @test_throws PosDefException MovingHorizonEstimator (
1048+ linmodel, He, i_ym, nint_u, nint_ym, P̂_0, Q̂, zeros (2 , 2 )
1049+ )
1050+
10321051end
10331052
10341053@testitem " MHE construction (NonLinModel)" setup= [SetupMPCtests] begin
0 commit comments