@@ -1174,13 +1174,13 @@ end
11741174 updatestate! (mhe1, [11 , 52 ], [50 , 30 ], [5 ])
11751175 end
11761176 preparestate! (mhe1, [50 , 30 ], [5 ])
1177- @test mhe1 ([5 ]) ≈ [50 , 30 ] atol= 1e -3
1177+ @test mhe1 ([5 ]) ≈ [50 , 30 ] atol= 5e -3
11781178 for i in 1 : 50
11791179 preparestate! (mhe1, [51 , 32 ], [5 ])
11801180 updatestate! (mhe1, [10 , 50 ], [51 , 32 ], [5 ])
11811181 end
11821182 preparestate! (mhe1, [51 , 32 ], [5 ])
1183- @test mhe1 ([5 ]) ≈ [51 , 32 ] atol= 1e -3
1183+ @test mhe1 ([5 ]) ≈ [51 , 32 ] atol= 5e -3
11841184
11851185 mhe1b = MovingHorizonEstimator (nonlinmodel, He= 2 , nint_u= [1 , 1 ], nint_ym= 0 , direct= false )
11861186 JuMP. set_attribute (mhe1b. optim, " tol" , 1e-7 )
@@ -1210,12 +1210,12 @@ end
12101210 preparestate! (mhe1c, [50 , 30 ], [5 ])
12111211 updatestate! (mhe1c, [11 , 52 ], [50 , 30 ], [5 ])
12121212 end
1213- @test mhe1c ([5 ]) ≈ [50 , 30 ] atol= 1e -3
1213+ @test mhe1c ([5 ]) ≈ [50 , 30 ] atol= 5e -3
12141214 for i in 1 : 50
12151215 preparestate! (mhe1c, [51 , 32 ], [5 ])
12161216 updatestate! (mhe1c, [10 , 50 ], [51 , 32 ], [5 ])
12171217 end
1218- @test mhe1c ([5 ]) ≈ [51 , 32 ] atol= 1e -3
1218+ @test mhe1c ([5 ]) ≈ [51 , 32 ] atol= 5e -3
12191219
12201220 gc! (gc, args... ) = (gc[1 ] = 0 ) # for coverage only
12211221 mhe2 = MovingHorizonEstimator (
@@ -1227,7 +1227,7 @@ end
12271227 updatestate! (mhe2, [11 , 52 ], [50 , 30 ], [5 ])
12281228 end
12291229 preparestate! (mhe2, [50 , 30 ], [5 ])
1230- @test mhe2 ([5 ]) ≈ [50 , 30 ] atol= 1e -3
1230+ @test mhe2 ([5 ]) ≈ [50 , 30 ] atol= 5e -3
12311231
12321232 mhe3 = MovingHorizonEstimator (
12331233 nonlinmodel, He= 3 , direct= false , transcription= MultipleShooting (f_threads= true )
@@ -1237,7 +1237,7 @@ end
12371237 updatestate! (mhe3, [11 , 52 ], [50 , 30 ], [5 ])
12381238 end
12391239 preparestate! (mhe3, [50 , 30 ], [5 ])
1240- @test mhe3 ([5 ]) ≈ [50 , 30 ] atol= 1e -3
1240+ @test mhe3 ([5 ]) ≈ [50 , 30 ] atol= 5e -3
12411241 initstate! (mhe3, [10 , 50 ], [50 , 30 ], [5 ])
12421242 setstate! (mhe3, [0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ])
12431243 preparestate! (mhe3, [50 , 30 ], [5 ])
@@ -1264,6 +1264,7 @@ end
12641264 f! = (ẋ,x,u,_,_) -> ẋ .= - 0.001 x .+ u
12651265 h! = (y,x,_,_) -> y .= x
12661266 nonlinmodel_c = NonLinModel (f!, h!, 500 , 1 , 1 , 1 )
1267+
12671268 transcription = TrapezoidalCollocation (f_threads= true , h_threads= true )
12681269 mhe6 = MovingHorizonEstimator (
12691270 nonlinmodel_c; He= 3 , direct= false , transcription
@@ -1273,7 +1274,7 @@ end
12731274 updatestate! (mhe6, [- 6 ], [13 ])
12741275 end
12751276 preparestate! (mhe6, [13 ])
1276- @test mhe6 () ≈ [13 ] atol= 1e -3
1277+ @test mhe6 () ≈ [13 ] atol= 5e -3
12771278
12781279 transcription = TrapezoidalCollocation (1 )
12791280 mhe7 = MovingHorizonEstimator (
@@ -1284,14 +1285,36 @@ end
12841285 updatestate! (mhe7, [- 6 ], [13 ])
12851286 end
12861287 preparestate! (mhe7, [13 ])
1287- @test mhe7 () ≈ [13 ] atol= 1e -3
1288+ @test mhe7 () ≈ [13 ] atol= 5e -3
12881289 initstate! (mhe7, [0.0 ], [0.0 ])
12891290 setstate! (mhe7, [0.0 , 0.0 ])
12901291 preparestate! (mhe7, [0.0 ])
12911292 info = getinfo (mhe7) # test getinfo when Nk<He
12921293 @test info[:Ŵ ] ≈ [0.0 , 0.0 ]
12931294 @test info[:V̂ ] ≈ [0.0 ]
12941295
1296+ transcription = OrthogonalCollocation (f_threads= true , h_threads= true )
1297+ mhe10 = MovingHorizonEstimator (
1298+ nonlinmodel_c; He= 3 , direct= false , transcription
1299+ )
1300+ for i in 1 : 50
1301+ preparestate! (mhe10, [13 ])
1302+ updatestate! (mhe10, [- 6 ], [13 ])
1303+ end
1304+ preparestate! (mhe10, [13 ])
1305+ @test mhe10 () ≈ [13 ] atol= 5e-3
1306+
1307+ transcription = OrthogonalCollocation (1 , 2 , roots= :gausslegendre )
1308+ mhe11 = MovingHorizonEstimator (
1309+ nonlinmodel_c; He= 3 , direct= true , transcription
1310+ )
1311+ for i in 1 : 50
1312+ preparestate! (mhe11, [13 ])
1313+ updatestate! (mhe11, [- 6 ], [13 ])
1314+ end
1315+ preparestate! (mhe11, [13 ])
1316+ @test mhe11 () ≈ [13 ] atol= 5e-3
1317+
12951318 # coverage of the branch with error termination status (with an infeasible problem):
12961319 mhe_infeas = MovingHorizonEstimator (nonlinmodel, He= 1 , Cwt= Inf )
12971320 mhe_infeas = setconstraint! (mhe_infeas, v̂min= [1 , 1 ], v̂max= [- 1 , - 1 ])
@@ -1302,9 +1325,9 @@ end
13021325 )
13031326
13041327 # for coverage of NLP functions, the univariate syntax of JuMP.@operator
1305- mhe6 = MovingHorizonEstimator (nonlinmodel, He= 1 , Cwt= Inf )
1306- setconstraint! (mhe6 , v̂min= [- 51 ,- 52 ], v̂max= [53 ,54 ])
1307- x̂ = preparestate! (mhe6 , [50 , 30 ], [5 ])
1328+ mhe7 = MovingHorizonEstimator (nonlinmodel, He= 1 , Cwt= Inf )
1329+ setconstraint! (mhe7 , v̂min= [- 51 ,- 52 ], v̂max= [53 ,54 ])
1330+ x̂ = preparestate! (mhe7 , [50 , 30 ], [5 ])
13081331 @test x̂ ≈ zeros (6 ) atol= 1e-9
13091332 @test_nowarn ModelPredictiveControl. info2debugstr (info)
13101333 @test_throws ErrorException setstate! (mhe1, [1 ,2 ,3 ,4 ,5 ,6 ], diagm (.1 : .1 : .6 ))
@@ -1315,12 +1338,12 @@ end
13151338 coloring_algorithm= GreedyColoringAlgorithm (),
13161339 )
13171340
1318- mhe7 = MovingHorizonEstimator (nonlinmodel; He= 2 , hessian)
1341+ mhe8 = MovingHorizonEstimator (nonlinmodel; He= 2 , hessian)
13191342 @test_logs (
13201343 (:warn , " NaN values in the MHE measurements ym: ignoring them in the objective" ),
1321- preparestate! (mhe7 , [50 , NaN ], [5 ])
1344+ preparestate! (mhe8 , [50 , NaN ], [5 ])
13221345 )
1323- @test mhe7 . x̂0 ≈ zeros (6 ) atol= 1e-9
1346+ @test mhe8 . x̂0 ≈ zeros (6 ) atol= 1e-9
13241347
13251348end
13261349
0 commit comments