@@ -358,13 +358,25 @@ end
358358 @test_throws DimensionMismatch setconstraint! (mpc, Δumax= [0 ,0 ,0 ])
359359 @test_throws DimensionMismatch setconstraint! (mpc, ymin= [0 ,0 ,0 ])
360360 @test_throws DimensionMismatch setconstraint! (mpc, ymax= [0 ,0 ,0 ])
361+ @test_throws DimensionMismatch setconstraint! (mpc, wmin= [0 ,0 ,0 ])
362+ @test_throws DimensionMismatch setconstraint! (mpc, wmax= [0 ,0 ,0 ])
361363 @test_throws DimensionMismatch setconstraint! (mpc, c_umin= [0 ,0 ,0 ])
362364 @test_throws DimensionMismatch setconstraint! (mpc, c_umax= [0 ,0 ,0 ])
363365 @test_throws DimensionMismatch setconstraint! (mpc, c_Δumin= [0 ,0 ,0 ])
364366 @test_throws DimensionMismatch setconstraint! (mpc, c_Δumax= [0 ,0 ,0 ])
365367 @test_throws DimensionMismatch setconstraint! (mpc, c_ymin= [0 ,0 ,0 ])
366368 @test_throws DimensionMismatch setconstraint! (mpc, c_ymax= [0 ,0 ,0 ])
367-
369+ @test_throws DimensionMismatch setconstraint! (mpc, c_wmin= [0 ,0 ,0 ])
370+ @test_throws DimensionMismatch setconstraint! (mpc, c_wmax= [0 ,0 ,0 ])
371+ @test_throws ErrorException setconstraint! (mpc, c_umin= [- 1 ,- 1 ])
372+ @test_throws ErrorException setconstraint! (mpc, c_umax= [- 1 ,- 1 ])
373+ @test_throws ErrorException setconstraint! (mpc, c_Δumin= [- 1 ,- 1 ])
374+ @test_throws ErrorException setconstraint! (mpc, c_Δumax= [- 1 ,- 1 ])
375+ @test_throws ErrorException setconstraint! (mpc, c_ymin= [- 1 ,- 1 ])
376+ @test_throws ErrorException setconstraint! (mpc, c_ymax= [- 1 ,- 1 ])
377+ @test_throws ErrorException setconstraint! (mpc, c_wmin= [- 1 ,- 1 ])
378+ @test_throws ErrorException setconstraint! (mpc, c_wmax= [- 1 ,- 1 ])
379+
368380 preparestate! (mpc, mpc. estim. model. yop, mpc. estim. model. dop)
369381 moveinput! (mpc, [0 , 0 ], [0 ])
370382 @test_throws ErrorException setconstraint! (mpc, c_umin= [1 , 1 ], c_umax= [1 , 1 ])
436448 info = getinfo (mpc)
437449 @test info[:x̂end ][1 ] ≈ 0 atol= 1e-1
438450 setconstraint! (mpc, x̂min= [- 1e6 ,- Inf ], x̂max= [+ 1e6 ,+ Inf ])
451+
452+ model2 = LinModel ([tf ([2 ], [10 , 1 ]) tf (0.1 , [7 , 1 ])], 3.0 , i_d= [2 ])
453+ model2 = setop! (model2, uop= [25 ], dop= [30 ], yop= [50 ])
454+ mpc_wy = LinMPC (model2, Nwt= [0 ], Cwt= Inf , Hp= 50 , Hc= 50 , Wy= [1 ])
455+ mpc_wy = setconstraint! (mpc_wy, wmax= [75 ])
456+ preparestate! (mpc_wy, [50 ], [30 ])
457+ u = moveinput! (mpc_wy, [100 ], [30 ])
458+ @test all (isapprox .(getinfo (mpc_wy)[:Ŷ ], 75.0 ; atol= 1e-1 ))
459+ mpc_wu = LinMPC (model2, Nwt= [0 ], Cwt= Inf , Hp= 50 , Hc= 50 , Wu= [1 ])
460+ mpc_wu = setconstraint! (mpc_wu, wmax= [20 ])
461+ preparestate! (mpc_wu, [50 ], [30 ])
462+ u = moveinput! (mpc_wu, [100 ], [30 ])
463+ @test all (isapprox .(getinfo (mpc_wu)[:U ], 20.0 ; atol= 1e-1 ))
464+ mpc_wd = LinMPC (model2, Nwt= [0 ], Cwt= Inf , Hp= 50 , Hc= 50 , Wd= [1 ], Wy= [1 ])
465+ mpc_wd = setconstraint! (mpc_wd, wmax= [95 ])
466+ preparestate! (mpc_wd, [50 ], [30 ])
467+ u = moveinput! (mpc_wd, [100 ], [30 ])
468+ @test all (isapprox .(getinfo (mpc_wd)[:Ŷ ], 95 - 30 ; atol= 1e-1 ))
469+ mpc_wr = LinMPC (model2, Nwt= [0 ], Cwt= Inf , Hp= 50 , Hc= 50 , Wr= [1 ], Wy= [1 ])
470+ mpc_wr = setconstraint! (mpc_wr, wmax= [175 ])
471+ preparestate! (mpc_wr, [50 ], [30 ])
472+ u = moveinput! (mpc_wr, [100 ], [30 ])
473+ @test all (isapprox .(getinfo (mpc_wr)[:Ŷ ], 175 - 100 ; atol= 1e-1 ))
439474end
440475
441476@testitem " LinMPC terminal cost" setup= [SetupMPCtests] begin
0 commit comments