Skip to content

Commit ee86435

Browse files
committed
test: LinMPC custom linear constraints with lower bound
1 parent b403fa4 commit ee86435

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

test/3_test_predictive_control.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,23 +452,31 @@ end
452452
model2 = LinModel([tf([2], [10, 1]) tf(0.1, [7, 1])], 3.0, i_d=[2])
453453
model2 = setop!(model2, uop=[25], dop=[30], yop=[50])
454454
mpc_wy = LinMPC(model2, Nwt=[0], Cwt=Inf, Hp=50, Hc=50, Wy=[1])
455-
mpc_wy = setconstraint!(mpc_wy, wmax=[75])
455+
mpc_wy = setconstraint!(mpc_wy, wmin=[36], wmax=[75])
456456
preparestate!(mpc_wy, [50], [30])
457+
u = moveinput!(mpc_wy, [0], [30])
458+
@test all(isapprox.(getinfo(mpc_wy)[:Ŷ], 36; atol=1e-1))
457459
u = moveinput!(mpc_wy, [100], [30])
458-
@test all(isapprox.(getinfo(mpc_wy)[:Ŷ], 75.0; atol=1e-1))
460+
@test all(isapprox.(getinfo(mpc_wy)[:Ŷ], 75; atol=1e-1))
459461
mpc_wu = LinMPC(model2, Nwt=[0], Cwt=Inf, Hp=50, Hc=50, Wu=[1])
460-
mpc_wu = setconstraint!(mpc_wu, wmax=[20])
462+
mpc_wu = setconstraint!(mpc_wu, wmin=[4], wmax=[20])
461463
preparestate!(mpc_wu, [50], [30])
464+
u = moveinput!(mpc_wu, [0], [30])
465+
@test all(isapprox.(getinfo(mpc_wu)[:U], 4; atol=1e-1))
462466
u = moveinput!(mpc_wu, [100], [30])
463-
@test all(isapprox.(getinfo(mpc_wu)[:U], 20.0; atol=1e-1))
467+
@test all(isapprox.(getinfo(mpc_wu)[:U], 20; atol=1e-1))
464468
mpc_wd = LinMPC(model2, Nwt=[0], Cwt=Inf, Hp=50, Hc=50, Wd=[1], Wy=[1])
465-
mpc_wd = setconstraint!(mpc_wd, wmax=[95])
469+
mpc_wd = setconstraint!(mpc_wd, wmin=[56], wmax=[95])
466470
preparestate!(mpc_wd, [50], [30])
471+
u = moveinput!(mpc_wd, [0], [30])
472+
@test all(isapprox.(getinfo(mpc_wd)[:Ŷ], 56-30; atol=1e-1))
467473
u = moveinput!(mpc_wd, [100], [30])
468474
@test all(isapprox.(getinfo(mpc_wd)[:Ŷ], 95-30; atol=1e-1))
469475
mpc_wr = LinMPC(model2, Nwt=[0], Cwt=Inf, Hp=50, Hc=50, Wr=[1], Wy=[1])
470-
mpc_wr = setconstraint!(mpc_wr, wmax=[175])
476+
mpc_wr = setconstraint!(mpc_wr, wmin=[52], wmax=[175])
471477
preparestate!(mpc_wr, [50], [30])
478+
u = moveinput!(mpc_wr, [21], [30])
479+
@test all(isapprox.(getinfo(mpc_wr)[:Ŷ], 52-21; atol=1e-1))
472480
u = moveinput!(mpc_wr, [100], [30])
473481
@test all(isapprox.(getinfo(mpc_wr)[:Ŷ], 175-100; atol=1e-1))
474482
end

0 commit comments

Comments
 (0)