Skip to content

Commit 365b34b

Browse files
committed
add tests constraints plot
1 parent 076e976 commit 365b34b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

test/test_plot_sim.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ end
8585

8686
@testset "PredictiveController Plots" begin
8787
mpc = LinMPC(LinModel(sys, Ts, i_d=[3]), Lwt=[0.01, 0.01])
88+
mpc = setconstraint!(mpc, umin=[-50, -51], umax=[52, 53], ŷmin=[-54,-55], ŷmax=[56,57])
89+
# TODO: ajouter des tests pour umin umax ŷmin ŷmax
8890
res = sim!(mpc, 15)
8991
p1 = plot(res, plotŷ=true)
9092
@test p1[1][1][:x] res.T_data
@@ -118,4 +120,20 @@ end
118120
@test p4[end-2][2][:y] res.X̂_data[4,:]
119121
@test p4[end-1][1][:y] res.X̂_data[5,:]
120122
@test p4[end-0][1][:y] res.X̂_data[6,:]
123+
p5 = plot(res, plotumin=true, plotumax=false, plotŷmin=false, plotŷmax=false)
124+
@test p5[1][1][:x] res.T_data
125+
@test all(p5[end-2][3][:y] .≈ -50.0)
126+
@test all(p5[end-1][3][:y] .≈ -51.0)
127+
p6 = plot(res, plotumin=false, plotumax=true, plotŷmin=false, plotŷmax=false)
128+
@test p6[1][1][:x] res.T_data
129+
@test all(p6[end-2][3][:y] .≈ 52.0)
130+
@test all(p6[end-1][3][:y] .≈ 53.0)
131+
p7 = plot(res, plotumin=false, plotumax=false, plotŷmin=true, plotŷmax=false)
132+
@test p7[1][1][:x] res.T_data
133+
@test all(p7[end-4][3][:y] .≈ -54.0)
134+
@test all(p7[end-3][3][:y] .≈ -55.0)
135+
p8 = plot(res, plotumin=false, plotumax=false, plotŷmin=false, plotŷmax=true)
136+
@test p8[1][1][:x] res.T_data
137+
@test all(p8[end-4][3][:y] .≈ 56.0)
138+
@test all(p8[end-3][3][:y] .≈ 57.0)
121139
end

test/test_sim_model.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Gss2 = c2d(sys_ss[:,1:2], 0.5Ts, :zoh)
3838
@test linmodel4.x [1;-1]
3939

4040
linmodel5 = LinModel(sys,Ts,i_d=[3])
41+
setop!(linmodel5, uop=[10,50], yop=[50,30], dop=[20])
4142
@test linmodel5.nx == 4
4243
@test linmodel5.nu == 2
4344
@test linmodel5.nd == 1
@@ -50,6 +51,9 @@ Gss2 = c2d(sys_ss[:,1:2], 0.5Ts, :zoh)
5051
@test linmodel5.Bd sys_ss.B[:,3]
5152
@test linmodel5.C sys_ss.C
5253
@test linmodel5.Dd sys_ss.D[:,3]
54+
@test linmodel5.uop [10,50]
55+
@test linmodel5.yop [50,30]
56+
@test linmodel5.dop [20]
5357

5458
linmodel6 = LinModel([delay(4) delay(4)]*sys,Ts,i_d=[3])
5559
@test linmodel6.nx == 6

0 commit comments

Comments
 (0)