|
94 | 94 | info = getinfo(mpc5)
|
95 | 95 | @test info[:u] ≈ [1] atol=1e-2
|
96 | 96 | @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 |
98 | 104 | @test_throws DimensionMismatch moveinput!(mpc1, [0,0,0])
|
99 | 105 | @test_throws DimensionMismatch moveinput!(mpc1, [0], [0,0])
|
100 | 106 | @test_throws DimensionMismatch moveinput!(mpc1; D̂ = fill(0, mpc1.Hp+1))
|
|
636 | 642 | h = (x,d,_) -> linmodel2.C*x + linmodel2.Dd*d
|
637 | 643 | nonlinmodel = NonLinModel(f, h, 3000.0, 1, 2, 1, 1, solver=nothing)
|
638 | 644 | nmpc2 = NonLinMPC(nonlinmodel, Nwt=[0], Hp=100, Hc=1)
|
| 645 | + preparestate!(nmpc2, [0], [0]) |
639 | 646 | # if d=[0.1], the output will eventually reach 7*0.1=0.7, no action needed (u=0):
|
640 | 647 | d = [0.1]
|
641 |
| - preparestate!(nmpc2, [0], d) |
642 | 648 | u = moveinput!(nmpc2, 7d, d)
|
643 | 649 | @test u ≈ [0] atol=5e-2
|
644 | 650 | u = nmpc2(7d, d)
|
|
0 commit comments