@@ -1318,7 +1318,8 @@ end
1318
1318
using . SetupMPCtests, ControlSystemsBase, LinearAlgebra
1319
1319
linmodel = LinModel (ss (0.5 , 0.3 , 1.0 , 0 , 10.0 ))
1320
1320
linmodel = setop! (linmodel, uop= [2.0 ], yop= [50.0 ], xop= [3.0 ], fop= [3.0 ])
1321
- mhe = MovingHorizonEstimator (linmodel, He= 1 , nint_ym= 0 , direct= false )
1321
+ He = 5
1322
+ mhe = MovingHorizonEstimator (linmodel; He, nint_ym= 0 , direct= false )
1322
1323
setconstraint! (mhe, x̂min= [- 1000 ], x̂max= [1000 ])
1323
1324
@test mhe. Â ≈ [0.5 ]
1324
1325
@test evaloutput (mhe) ≈ [50.0 ]
@@ -1331,19 +1332,18 @@ end
1331
1332
@test mhe. Â ≈ [0.2 ]
1332
1333
@test evaloutput (mhe) ≈ [55.0 ]
1333
1334
@test mhe. lastu0 ≈ [2.0 - 3.0 ]
1334
- @test mhe. U0 ≈ [2.0 - 3.0 ]
1335
- @test mhe. Y0m ≈ [50.0 - 55.0 ]
1336
- preparestate! (mhe, [55.0 ])
1337
- x̂ = updatestate! (mhe, [3.0 ], [55.0 ])
1335
+ @test mhe. U0 ≈ repeat ([2.0 - 3.0 ], He)
1336
+ @test mhe. Y0m ≈ repeat ([50.0 - 55.0 ], He)
1337
+ x̂ = preparestate! (mhe, [55.0 ])
1338
1338
@test x̂ ≈ [3.0 ]
1339
1339
newlinmodel = setop! (newlinmodel, uop= [3.0 ], yop= [55.0 ], xop= [8.0 ], fop= [8.0 ])
1340
1340
setmodel! (mhe, newlinmodel)
1341
1341
@test mhe. x̂0 ≈ [3.0 - 8.0 ]
1342
1342
@test mhe. Z̃[1 ] ≈ 3.0 - 8.0
1343
- @test mhe. X̂0 ≈ [3.0 - 8.0 ]
1343
+ @test mhe. X̂0 ≈ repeat ( [3.0 - 8.0 ], He)
1344
1344
@test mhe. x̂0arr_old ≈ [3.0 - 8.0 ]
1345
- @test mhe. con. X̂0min ≈ [- 1000 - 8.0 ]
1346
- @test mhe. con. X̂0max ≈ [+ 1000 - 8.0 ]
1345
+ @test mhe. con. X̂0min ≈ repeat ( [- 1000 - 8.0 ], He)
1346
+ @test mhe. con. X̂0max ≈ repeat ( [+ 1000 - 8.0 ], He)
1347
1347
@test mhe. con. x̃0min ≈ [- 1000 - 8.0 ]
1348
1348
@test mhe. con. x̃0max ≈ [+ 1000 - 8.0 ]
1349
1349
setmodel! (mhe, Q̂= [1e-3 ], R̂= [1e-6 ])
@@ -1352,7 +1352,7 @@ end
1352
1352
f (x,u,d,model) = model. A* x + model. Bu* u + model. Bd* d
1353
1353
h (x,d,model) = model. C* x + model. Du* d
1354
1354
nonlinmodel = NonLinModel (f, h, 10.0 , 1 , 1 , 1 , p= linmodel, solver= nothing )
1355
- mhe2 = MovingHorizonEstimator (nonlinmodel, He= 1 , nint_ym= 0 )
1355
+ mhe2 = MovingHorizonEstimator (nonlinmodel; He, nint_ym= 0 )
1356
1356
setmodel! (mhe2, Q̂= [1e-3 ], R̂= [1e-6 ])
1357
1357
@test mhe2. Q̂ ≈ [1e-3 ]
1358
1358
@test mhe2. R̂ ≈ [1e-6 ]
0 commit comments