@@ -1064,6 +1064,29 @@ end
10641064 @test_throws ErrorException setstate! (mhe1, [1 ,2 ,3 ,4 ,5 ,6 ], diagm (.1 : .1 : .6 ))
10651065end
10661066
1067+ @testitem " MovingHorizonEstimator estimation with unfilled window" setup= [SetupMPCtests] begin
1068+ f (x,u,_,_) = 0.5 x + u
1069+ h (x,_,_) = x
1070+ model = NonLinModel (f, h, 10.0 , 1 , 1 , 1 , solver= nothing )
1071+ mhe1 = MovingHorizonEstimator (model, nint_u= [1 ], He= 3 , direct= true )
1072+ for i = 1 : 40
1073+ y = model ()
1074+ x̂ = preparestate! (mhe1, y)
1075+ updatestate! (mhe1, [0.0 ], y)
1076+ updatestate! (model, [0.1 ])
1077+ end
1078+ @test mhe1 () ≈ model () atol = 1e-9
1079+ model = NonLinModel (f, h, 10.0 , 1 , 1 , 1 , solver= nothing )
1080+ mhe2 = MovingHorizonEstimator (model, nint_u= [1 ], He= 3 , direct= false )
1081+ for i = 1 : 40
1082+ y = model ()
1083+ x̂ = preparestate! (mhe2, y)
1084+ updatestate! (mhe2, [0.0 ], y)
1085+ updatestate! (model, [0.1 ])
1086+ end
1087+ @test mhe2 () ≈ model () atol = 1e-9
1088+ end
1089+
10671090@testitem " MovingHorizonEstimator fallbacks for arrival covariance estimation" setup= [SetupMPCtests] begin
10681091 using . SetupMPCtests, ControlSystemsBase, LinearAlgebra
10691092 linmodel = setop! (LinModel (sys,Ts,i_u= [1 ,2 ], i_d= [3 ]), uop= [10 ,50 ], yop= [50 ,30 ], dop= [5 ])
0 commit comments