|
53 | 53 | mpc16 = LinMPC(model, Hc=[1,2,3,6,6,6], Hp=10, Cwt=Inf) |
54 | 54 | @test mpc16.Hc == 4 # the last 2 elements of Hc are ignored |
55 | 55 | @test size(mpc16.P̃u) == (10*mpc1.estim.model.nu, 4*mpc1.estim.model.nu) |
| 56 | + |
| 57 | + Wy = ones(3, ny) |
| 58 | + mpc17 = LinMPC(model; Wy) |
| 59 | + @test mpc17.con.W̄y ≈ ModelPredictiveControl.repeatdiag(Wy, mpc17.Hp+1) |
| 60 | + @test mpc17.con.W̄u ≈ zeros(model.nu*(mpc17.Hp+1), model.nu*(mpc17.Hp+1)) |
| 61 | + @test mpc17.con.W̄d ≈ zeros(model.nd*(mpc17.Hp+1), model.nd*(mpc17.Hp+1)) |
| 62 | + @test mpc17.con.W̄r ≈ zeros(model.ny*(mpc17.Hp+1), model.ny*(mpc17.Hp+1)) |
| 63 | + |
| 64 | + Wy = ones(2, model.ny) |
| 65 | + Wu = 2*ones(2, model.nu) |
| 66 | + Wd = 3*ones(2, model.nd) |
| 67 | + Wr = 0.5*ones(2, model.ny) |
| 68 | + mpc18 = LinMPC(model; Wy, Wu, Wd, Wr) |
| 69 | + @test mpc18.con.W̄y ≈ ModelPredictiveControl.repeatdiag(Wy, mpc18.Hp+1) |
| 70 | + @test mpc18.con.W̄u ≈ ModelPredictiveControl.repeatdiag(Wu, mpc18.Hp+1) |
| 71 | + @test mpc18.con.W̄d ≈ ModelPredictiveControl.repeatdiag(Wd, mpc18.Hp+1) |
| 72 | + @test mpc18.con.W̄r ≈ ModelPredictiveControl.repeatdiag(Wr, mpc18.Hp+1) |
56 | 73 |
|
57 | 74 | @test_logs( |
58 | 75 | (:warn, |
|
62 | 79 | ) |
63 | 80 | @test_throws ArgumentError LinMPC(model, Hc=0) |
64 | 81 | @test_throws ArgumentError LinMPC(model, Hp=1, Hc=2) |
65 | | - @test_throws ArgumentError LinMPC(model, Mwt=[1]) |
66 | | - @test_throws ArgumentError LinMPC(model, Mwt=[1]) |
67 | | - @test_throws ArgumentError LinMPC(model, Lwt=[1]) |
68 | | - @test_throws ArgumentError LinMPC(model, Cwt=[1]) |
| 82 | + @test_throws DimensionMismatch LinMPC(model, Mwt=[1]) |
| 83 | + @test_throws DimensionMismatch LinMPC(model, Mwt=[1]) |
| 84 | + @test_throws DimensionMismatch LinMPC(model, Lwt=[1]) |
| 85 | + @test_throws DimensionMismatch LinMPC(model, Cwt=[1]) |
69 | 86 | @test_throws ArgumentError LinMPC(model, Mwt=[-1,1]) |
70 | 87 | @test_throws ArgumentError LinMPC(model, Nwt=[-1,1]) |
71 | 88 | @test_throws ArgumentError LinMPC(model, Lwt=[-1,1]) |
72 | 89 | @test_throws ArgumentError LinMPC(model, Cwt=-1) |
| 90 | + @test_throws DimensionMismatch LinMPC(model, Wy=ones(2, ny+1)) |
| 91 | + @test_throws DimensionMismatch LinMPC(model, Wu=ones(2, nu-1)) |
| 92 | + @test_throws DimensionMismatch LinMPC(model, Wd=ones(2, nd+1)) |
| 93 | + @test_throws DimensionMismatch LinMPC(model, Wr=ones(2, ny-1)) |
| 94 | + @test_throws DimensionMismatch LinMPC(model, Wy=ones(2, ny), Wu=ones(3, nu)) |
73 | 95 | end |
74 | 96 |
|
75 | 97 | @testitem "LinMPC moves and getinfo" setup=[SetupMPCtests] begin |
|
0 commit comments