Skip to content

Commit fc0006d

Browse files
committed
add unit test for sim! on ExplicitMPC
1 parent c9a59e1 commit fc0006d

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

test/test_plot_sim.jl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,30 @@ end
7272
end
7373

7474
@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)
7777
@test isa(res.obj, LinMPC)
7878
@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
8090
@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̂)
8494
end
8595

8696
@testset "PredictiveController Plots" begin
8797
mpc = LinMPC(LinModel(sys, Ts, i_d=[3]), Lwt=[0.01, 0.01])
8898
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
9099
res = sim!(mpc, 15)
91100
p1 = plot(res, plotŷ=true)
92101
@test p1[1][1][:x] res.T_data

0 commit comments

Comments
 (0)