|
121 | 121 | ΔU_diff = diff(getinfo(mpc7)[:U])
|
122 | 122 | @test ΔU_diff[[2, 4, 5, 7, 8, 9]] ≈ zeros(6) atol=1e-9
|
123 | 123 |
|
| 124 | + # coverage of the branch with error termination status (with an infeasible problem): |
| 125 | + mpc_infeas = LinMPC(linmodel2, Hp=1, Hc=1, Cwt=Inf) |
| 126 | + mpc_infeas = setconstraint!(mpc_infeas, umin=[+1], umax=[-1]) |
| 127 | + preparestate!(mpc_infeas, [0], [0]) |
| 128 | + @test_logs( |
| 129 | + (:error, "MPC terminated without solution: returning last solution shifted "* |
| 130 | + "(more info in debug log)"), |
| 131 | + moveinput!(mpc_infeas, [0], [0]) |
| 132 | + ) |
| 133 | + |
124 | 134 | @test_throws DimensionMismatch moveinput!(mpc1, [0,0,0])
|
125 | 135 | @test_throws DimensionMismatch moveinput!(mpc1, [0], [0,0])
|
126 | 136 | @test_throws DimensionMismatch moveinput!(mpc1; D̂ = fill(0, mpc1.Hp+1))
|
|
823 | 833 | ΔU_diff = diff(getinfo(nmpc11)[:U])
|
824 | 834 | @test ΔU_diff[[2, 4, 5, 7, 8, 9]] ≈ zeros(6) atol=1e-9
|
825 | 835 |
|
| 836 | + # coverage of the branch with error termination status (with an infeasible problem): |
| 837 | + nmpc_infeas = NonLinMPC(nonlinmodel, Hp=1, Hc=1, Cwt=Inf) |
| 838 | + nmpc_infeas = setconstraint!(nmpc_infeas, umin=[+1], umax=[-1]) |
| 839 | + preparestate!(nmpc_infeas, [0], [0]) |
| 840 | + @test_logs( |
| 841 | + (:error, "MPC terminated without solution: returning last solution shifted "* |
| 842 | + "(more info in debug log)"), |
| 843 | + moveinput!(nmpc_infeas, [0], [0]) |
| 844 | + ) |
| 845 | + |
| 846 | + |
826 | 847 | @test_nowarn ModelPredictiveControl.info2debugstr(info)
|
827 | 848 | end
|
828 | 849 |
|
|
0 commit comments