Skip to content

Commit c7efa1c

Browse files
committed
test: verifying default constraint parameters
1 parent 0d2a5ae commit c7efa1c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/3_test_predictive_control.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ end
244244
model = LinModel(sys, Ts, i_d=[3])
245245
mpc = LinMPC(model, Hp=1, Hc=1)
246246

247+
# test default constraints before modifying any:
248+
@test all((mpc.con.U0min, mpc.con.U0max) .≈ (fill(-Inf, model.nu), fill(Inf, model.nu)))
249+
@test all((mpc.con.ΔŨmin, mpc.con.ΔŨmax) .≈ (vcat(fill(-Inf, model.nu), 0), vcat(fill(Inf, model.nu), Inf)))
250+
@test all((mpc.con.Y0min, mpc.con.Y0max) .≈ (fill(-Inf, model.ny), fill(Inf, model.ny)))
251+
@test all((mpc.con.x̂0min, mpc.con.x̂0max) .≈ (fill(-Inf, mpc.estim.nx̂), fill(Inf, mpc.estim.nx̂)))
252+
@test all((-mpc.con.A_Umin[:, end], -mpc.con.A_Umax[:, end]) .≈ (fill(0.0, model.nu), fill(0.0, model.nu)))
253+
@test all((-mpc.con.A_ΔŨmin[1:end-1, end], -mpc.con.A_ΔŨmax[1:end-1, end]) .≈ (fill(0.0, model.nu), fill(0.0, model.nu)))
254+
@test all((-mpc.con.A_Ymin[:, end], -mpc.con.A_Ymax[:, end]) .≈ (fill(1.0, model.ny), fill(1.0, model.ny)))
255+
@test all((-mpc.con.A_x̂min[:, end], -mpc.con.A_x̂max[:, end]) .≈ (fill(1.0, mpc.estim.nx̂), fill(1.0, mpc.estim.nx̂)))
256+
247257
setconstraint!(mpc, umin=[-5, -9.9], umax=[100,99])
248258
@test all((mpc.con.U0min, mpc.con.U0max) .≈ ([-5, -9.9], [100,99]))
249259
setconstraint!(mpc, Δumin=[-5,-10], Δumax=[6,11])

0 commit comments

Comments
 (0)