|
72 | 72 | end |
73 | 73 |
|
74 | 74 | @testset "PredictiveController quick simulation" begin |
75 | | - mpc = LinMPC(LinModel(sys, Ts, i_d=[3])) |
76 | | - res = sim!(mpc, 15) |
| 75 | + mpc1 = LinMPC(LinModel(sys, Ts, i_d=[3])) |
| 76 | + res = sim!(mpc1, 15) |
77 | 77 | @test isa(res.obj, LinMPC) |
78 | 78 | @test length(res.T_data) == 15 |
79 | | - @test res.Ry_data[:, 1] ≈ mpc.estim.model.yop .+ 1 |
| 79 | + @test res.Ry_data[:, 1] ≈ mpc1.estim.model.yop .+ 1 |
| 80 | + @test res.Ud_data ≈ res.U_data |
| 81 | + @test res.D_data[:, 1] ≈ mpc1.estim.model.dop |
| 82 | + @test res.X_data[:, 1] ≈ zeros(mpc1.estim.model.nx) |
| 83 | + @test res.X̂_data[:, 1] ≈ zeros(mpc1.estim.nx̂) |
| 84 | + |
| 85 | + mpc2 = ExplicitMPC(LinModel(sys, Ts, i_d=[3])) |
| 86 | + res = sim!(mpc2, 15) |
| 87 | + @test isa(res.obj, ExplicitMPC) |
| 88 | + @test length(res.T_data) == 15 |
| 89 | + @test res.Ry_data[:, 1] ≈ mpc2.estim.model.yop .+ 1 |
80 | 90 | @test res.Ud_data ≈ res.U_data |
81 | | - @test res.D_data[:, 1] ≈ mpc.estim.model.dop |
82 | | - @test res.X_data[:, 1] ≈ zeros(mpc.estim.model.nx) |
83 | | - @test res.X̂_data[:, 1] ≈ zeros(mpc.estim.nx̂) |
| 91 | + @test res.D_data[:, 1] ≈ mpc2.estim.model.dop |
| 92 | + @test res.X_data[:, 1] ≈ zeros(mpc2.estim.model.nx) |
| 93 | + @test res.X̂_data[:, 1] ≈ zeros(mpc2.estim.nx̂) |
84 | 94 | end |
85 | 95 |
|
86 | 96 | @testset "PredictiveController Plots" begin |
87 | 97 | mpc = LinMPC(LinModel(sys, Ts, i_d=[3]), Lwt=[0.01, 0.01]) |
88 | 98 | mpc = setconstraint!(mpc, umin=[-50, -51], umax=[52, 53], ymin=[-54,-55], ymax=[56,57]) |
89 | | - # TODO: ajouter des tests pour umin umax ymin ymax |
90 | 99 | res = sim!(mpc, 15) |
91 | 100 | p1 = plot(res, plotŷ=true) |
92 | 101 | @test p1[1][1][:x] ≈ res.T_data |
|
0 commit comments