Skip to content

Commit 13387b4

Browse files
committed
test: verify setmodel! with He>1 for MHE
1 parent bbc38fe commit 13387b4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/2_test_state_estim.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,8 @@ end
13181318
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra
13191319
linmodel = LinModel(ss(0.5, 0.3, 1.0, 0, 10.0))
13201320
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)
13221323
setconstraint!(mhe, x̂min=[-1000], x̂max=[1000])
13231324
@test mhe. [0.5]
13241325
@test evaloutput(mhe) [50.0]
@@ -1331,19 +1332,18 @@ end
13311332
@test mhe. [0.2]
13321333
@test evaloutput(mhe) [55.0]
13331334
@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-
= 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+
= preparestate!(mhe, [55.0])
13381338
@test [3.0]
13391339
newlinmodel = setop!(newlinmodel, uop=[3.0], yop=[55.0], xop=[8.0], fop=[8.0])
13401340
setmodel!(mhe, newlinmodel)
13411341
@test mhe.x̂0 [3.0 - 8.0]
13421342
@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)
13441344
@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)
13471347
@test mhe.con.x̃0min [-1000 - 8.0]
13481348
@test mhe.con.x̃0max [+1000 - 8.0]
13491349
setmodel!(mhe, Q̂=[1e-3], R̂=[1e-6])
@@ -1352,7 +1352,7 @@ end
13521352
f(x,u,d,model) = model.A*x + model.Bu*u + model.Bd*d
13531353
h(x,d,model) = model.C*x + model.Du*d
13541354
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)
13561356
setmodel!(mhe2, Q̂=[1e-3], R̂=[1e-6])
13571357
@test mhe2. [1e-3]
13581358
@test mhe2. [1e-6]

0 commit comments

Comments
 (0)