Skip to content

Commit 7912b9f

Browse files
committed
add tests for time-varying weights
1 parent 6feb14f commit 7912b9f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/test_predictive_control.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ sys = [ tf(1.90,[18.0,1]) tf(1.90,[18.0,1]) tf(1.90,[18.0,1]);
2727
@test mpc9.estim.nint_u == [1, 1]
2828
@test mpc9.estim.nint_ym == [0, 0]
2929

30+
mpc10 = LinMPC(model, M_Hp=Diagonal(1.01:0.01:1.2))
31+
@test mpc10.M_Hp Diagonal(1.01:0.01:1.2)
32+
mpc11 = LinMPC(model, N_Hc=Diagonal([0.1,0.11,0.12,0.13]), Cwt=Inf)
33+
@test mpc11.Ñ_Hc Diagonal([0.1,0.11,0.12,0.13])
34+
mcp12 = LinMPC(model, L_Hp=Diagonal(0.001:0.001:0.02))
35+
@test mcp12.L_Hp Diagonal(0.001:0.001:0.02)
36+
3037
@test_throws ArgumentError LinMPC(model, Hp=0)
3138
@test_throws ArgumentError LinMPC(model, Hc=0)
3239
@test_throws ArgumentError LinMPC(model, Hp=1, Hc=2)
@@ -236,6 +243,12 @@ end
236243
mpc9 = ExplicitMPC(model, nint_u=[1, 1], nint_ym=[0, 0])
237244
@test mpc9.estim.nint_u == [1, 1]
238245
@test mpc9.estim.nint_ym == [0, 0]
246+
mpc10 = ExplicitMPC(model, M_Hp=Diagonal(1.01:0.01:1.2))
247+
@test mpc10.M_Hp Diagonal(1.01:0.01:1.2)
248+
mpc11 = ExplicitMPC(model, N_Hc=Diagonal([0.1,0.11,0.12,0.13]))
249+
@test mpc11.Ñ_Hc Diagonal([0.1,0.11,0.12,0.13])
250+
mcp12 = ExplicitMPC(model, L_Hp=Diagonal(0.001:0.001:0.02))
251+
@test mcp12.L_Hp Diagonal(0.001:0.001:0.02)
239252
end
240253

241254
@testset "ExplicitMPC moves and getinfo" begin
@@ -349,6 +362,12 @@ end
349362
nmpc11 = NonLinMPC(nonlinmodel, Hp=15, nint_u=[1, 1], nint_ym=[0, 0])
350363
@test nmpc11.estim.nint_u == [1, 1]
351364
@test nmpc11.estim.nint_ym == [0, 0]
365+
nmpc12 = NonLinMPC(nonlinmodel, M_Hp=Diagonal(1.01:0.01:1.2))
366+
@test nmpc12.M_Hp Diagonal(1.01:0.01:1.2)
367+
nmpc13 = NonLinMPC(nonlinmodel, N_Hc=Diagonal([0.1,0.11,0.12,0.13]), Cwt=Inf)
368+
@test nmpc13.Ñ_Hc Diagonal([0.1,0.11,0.12,0.13])
369+
nmcp14 = NonLinMPC(nonlinmodel, L_Hp=Diagonal(0.001:0.001:0.02))
370+
@test nmcp14.L_Hp Diagonal(0.001:0.001:0.02)
352371

353372
@test_throws ArgumentError NonLinMPC(nonlinmodel, Hp=15, Ewt=[1, 1])
354373
# to uncomment when deprecated constructor is removed:

0 commit comments

Comments
 (0)