@@ -1145,6 +1145,7 @@ end
11451145 using . SetupMPCtests, ControlSystemsBase, LinearAlgebra, ForwardDiff
11461146 using JuMP, Ipopt, DifferentiationInterface, SparseMatrixColorings, SparseConnectivityTracer
11471147 import ForwardDiff
1148+
11481149 linmodel = LinModel (sys,Ts,i_u= [1 ,2 ], i_d= [3 ])
11491150 linmodel = setop! (linmodel, uop= [10 ,50 ], yop= [50 ,30 ], dop= [5 ])
11501151 f (x,u,d,model) = model. A* x + model. Bu* u + model. Bd* d
@@ -1237,7 +1238,13 @@ end
12371238 end
12381239 preparestate! (mhe3, [50 , 30 ], [5 ])
12391240 @test mhe3 ([5 ]) ≈ [50 , 30 ] atol= 1e-3
1240-
1241+ initstate! (mhe3, [10 , 50 ], [50 , 30 ], [5 ])
1242+ setstate! (mhe3, [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ])
1243+ preparestate! (mhe3, [50 , 30 ], [5 ])
1244+ updatestate! (mhe3, [10 , 50 ], [50 , 30 ], [5 ])
1245+ info = getinfo (mhe3) # test getinfo when Nk<He
1246+ @test info[:Ŵ ] ≈ [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ]
1247+ @test info[:V̂ ] ≈ [0.0 , 0.0 ]
12411248
12421249 Q̂ = diagm ([1 / 4 , 1 / 4 , 1 / 4 , 1 / 4 ]. ^ 2 )
12431250 R̂ = diagm ([1 , 1 ]. ^ 2 )
@@ -1267,6 +1274,7 @@ end
12671274 end
12681275 preparestate! (mhe6, [13 ])
12691276 @test mhe6 () ≈ [13 ] atol= 1e-3
1277+
12701278 transcription = TrapezoidalCollocation (1 )
12711279 mhe7 = MovingHorizonEstimator (
12721280 nonlinmodel_c; He= 3 , direct= true , transcription
@@ -1277,6 +1285,12 @@ end
12771285 end
12781286 preparestate! (mhe7, [13 ])
12791287 @test mhe7 () ≈ [13 ] atol= 1e-3
1288+ initstate! (mhe7, [0.0 ], [0.0 ])
1289+ setstate! (mhe7, [0.0 , 0.0 ])
1290+ preparestate! (mhe7, [0.0 ])
1291+ info = getinfo (mhe7) # test getinfo when Nk<He
1292+ @test info[:Ŵ ] ≈ [0.0 , 0.0 ]
1293+ @test info[:V̂ ] ≈ [0.0 ]
12801294
12811295 # coverage of the branch with error termination status (with an infeasible problem):
12821296 mhe_infeas = MovingHorizonEstimator (nonlinmodel, He= 1 , Cwt= Inf )
0 commit comments