Skip to content

Commit ed07620

Browse files
committed
test: simple tests with new lastu arg.
1 parent 10c43d5 commit ed07620

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/3_test_predictive_control.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ end
8181
preparestate!(mpc1, [10])
8282
u = moveinput!(mpc1, r)
8383
@test u [1] atol=1e-2
84-
u = mpc1(r)
84+
u = mpc1(r, lastu=[-1])
8585
@test u [1] atol=1e-2
8686
info = getinfo(mpc1)
8787
@test info[:u] u
8888
@test info[:Ŷ][end] r[1] atol=1e-2
89+
@test info[:ΔU] [2.0] atol=1e-2
8990
mpc2 = LinMPC(linmodel, Nwt=[0], Cwt=Inf, Hp=1000, Hc=1)
9091
preparestate!(mpc2, [10])
9192
u = moveinput!(mpc2, r)
@@ -515,11 +516,12 @@ end
515516
preparestate!(mpc1, y)
516517
u = moveinput!(mpc1, r)
517518
@test u [1] atol=1e-2
518-
u = mpc1(r)
519+
u = mpc1(r, lastu=[-1])
519520
@test u [1] atol=1e-2
520521
info = getinfo(mpc1)
521522
@test info[:u] u
522523
@test info[:Ŷ][end] r[1] atol=1e-2
524+
@test info[:ΔU] [2.0] atol=1e-2
523525
mpc2 = ExplicitMPC(model, Nwt=[0], Hp=1000, Hc=1)
524526
preparestate!(mpc2, y)
525527
u = moveinput!(mpc2, [5])
@@ -756,11 +758,12 @@ end
756758
preparestate!(nmpc_lin, [10])
757759
u = moveinput!(nmpc_lin, ry)
758760
@test u [1] atol=5e-2
759-
u = nmpc_lin(ry)
761+
u = nmpc_lin(ry, lastu=[-1])
760762
@test u [1] atol=5e-2
761763
info = getinfo(nmpc_lin)
762764
@test info[:u] u
763765
@test info[:Ŷ][end] ry[1] atol=5e-2
766+
@test info[:ΔU] [2.0] atol=5e-2
764767
setmodel!(nmpc_lin; Mwt=[0], Lwt=[1])
765768
u = moveinput!(nmpc_lin; R̂u=fill(ru[1], Hp))
766769
@test u [4] atol=5e-2

0 commit comments

Comments
 (0)