Skip to content

Commit c1ea8bb

Browse files
committed
test: add unfilled window test for MHE
1 parent 658ab1d commit c1ea8bb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/2_test_state_estim.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,29 @@ end
10641064
@test_throws ErrorException setstate!(mhe1, [1,2,3,4,5,6], diagm(.1:.1:.6))
10651065
end
10661066

1067+
@testitem "MovingHorizonEstimator estimation with unfilled window" setup=[SetupMPCtests] begin
1068+
f(x,u,_,_) = 0.5x + 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+
= 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+
= 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

Comments
 (0)