Skip to content

Commit a284603

Browse files
committed
test: improve coverage of MultipleShooting
1 parent 4354b06 commit a284603

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/3_test_predictive_control.jl

+8-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ end
9494
info = getinfo(mpc5)
9595
@test info[:u] [1] atol=1e-2
9696
@test info[:Ŷ][end] 15 atol=1e-2
97-
97+
linmodel2 = LinModel([tf(5, [2000, 1]) tf(7, [8000,1])], 3000.0, i_d=[2])
98+
mpc6 = LinMPC(linmodel2, Nwt=[0], Hp=1000, Hc=1)
99+
preparestate!(mpc6, [0], [0])
100+
# if d=[0.1], the output will eventually reach 7*0.1=0.7, no action needed (u=0):
101+
d = [0.1]
102+
u = moveinput!(mpc6, 7d, d)
103+
@test u [0] atol=1e-2
98104
@test_throws DimensionMismatch moveinput!(mpc1, [0,0,0])
99105
@test_throws DimensionMismatch moveinput!(mpc1, [0], [0,0])
100106
@test_throws DimensionMismatch moveinput!(mpc1; D̂ = fill(0, mpc1.Hp+1))
@@ -636,9 +642,9 @@ end
636642
h = (x,d,_) -> linmodel2.C*x + linmodel2.Dd*d
637643
nonlinmodel = NonLinModel(f, h, 3000.0, 1, 2, 1, 1, solver=nothing)
638644
nmpc2 = NonLinMPC(nonlinmodel, Nwt=[0], Hp=100, Hc=1)
645+
preparestate!(nmpc2, [0], [0])
639646
# if d=[0.1], the output will eventually reach 7*0.1=0.7, no action needed (u=0):
640647
d = [0.1]
641-
preparestate!(nmpc2, [0], d)
642648
u = moveinput!(nmpc2, 7d, d)
643649
@test u [0] atol=5e-2
644650
u = nmpc2(7d, d)

0 commit comments

Comments
 (0)