Skip to content

Commit 6429c6e

Browse files
committed
debug: correctly modify custom linear constraint softness
1 parent c5d691a commit 6429c6e

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/controller/construct.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ function setconstraint!(
445445
isnothing(C_Δumax) && !isnothing(c_Δumax) && (C_Δumax = repeat(c_Δumax, Hc))
446446
isnothing(C_ymin) && !isnothing(c_ymin) && (C_ymin = repeat(c_ymin, Hp))
447447
isnothing(C_ymax) && !isnothing(c_ymax) && (C_ymax = repeat(c_ymax, Hp))
448+
isnothing(C_wmin) && !isnothing(c_wmin) && (C_wmin = repeat(c_wmin, Hp+1))
449+
isnothing(C_wmax) && !isnothing(c_wmax) && (C_wmax = repeat(c_wmax, Hp+1))
448450
if !isnothing(C_umin)
449451
size(C_umin) == (nu*Hp,) || throw(ArgumentError("C_umin size must be $((nu*Hp,))"))
450452
any(<(0), C_umin) && error("C_umin weights should be non-negative")

test/3_test_predictive_control.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ end
295295
setconstraint!(mpc, ymin=[-6, -11],ymax=[55, 35])
296296
@test mpc.con.Y0min [-6,-11]
297297
@test mpc.con.Y0max [55,35]
298+
setconstraint!(mpc, wmin=[-7, -12], wmax=[75, 65])
299+
@test mpc.con.Wmin [-7, -12, -7, -12]
300+
@test mpc.con.Wmax [75, 65, 75, 65]
298301
setconstraint!(mpc, x̂min=[-21,-22,-23,-24,-25,-26], x̂max=[21,22,23,24,25,26])
299302
@test mpc.con.x̂0min [-21,-22,-23,-24,-25,-26]
300303
@test mpc.con.x̂0max [21,22,23,24,25,26]
@@ -308,6 +311,9 @@ end
308311
setconstraint!(mpc, c_ymin=[1.00,1.01], c_ymax=[1.02,1.03])
309312
@test -mpc.con.A_Ymin[:, end] [1.00,1.01]
310313
@test -mpc.con.A_Ymax[:, end] [1.02,1.03]
314+
setconstraint!(mpc, c_wmin=[2.00,2.01], c_wmax=[2.02,2.03])
315+
@test -mpc.con.A_Wmin[:, end] [2.00,2.01,2.00,2.01]
316+
@test -mpc.con.A_Wmax[:, end] [2.02,2.03,2.02,2.03]
311317
setconstraint!(mpc, c_x̂min=[0.21,0.22,0.23,0.24,0.25,0.26], c_x̂max=[0.31,0.32,0.33,0.34,0.35,0.36])
312318
@test -mpc.con.A_x̂min[:, end] [0.21,0.22,0.23,0.24,0.25,0.26]
313319
@test -mpc.con.A_x̂max[:, end] [0.31,0.32,0.33,0.34,0.35,0.36]
@@ -324,6 +330,7 @@ end
324330
setconstraint!(mpc2, Ymin=-1(1:50).-3, Ymax=+1(1:50).+3)
325331
@test mpc2.con.Y0min -1(1:50).-3
326332
@test mpc2.con.Y0max +1(1:50).+3
333+
#setconstraint!(mpc3)
327334

328335
setconstraint!(mpc2, C_umin=+1(1:50).+4, C_umax=+1(1:50).+4)
329336
@test -mpc2.con.A_Umin[:, end] +1(1:50).+4

0 commit comments

Comments
 (0)