Skip to content

Commit e5288df

Browse files
committed
test: reduce ALMOST_LOCALLY_SOLVED warning noise
Tweaking the optimizer tolerances
1 parent 3563947 commit e5288df

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

test/2_test_state_estim.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ end
916916
nonlinmodel = setop!(nonlinmodel, uop=[10,50], yop=[50,30], dop=[5])
917917

918918
mhe1 = MovingHorizonEstimator(nonlinmodel, He=2)
919+
JuMP.set_attribute(mhe1.optim, "tol", 1e-7)
919920
preparestate!(mhe1, [50, 30], [5])
920921
= updatestate!(mhe1, [10, 50], [50, 30], [5])
921922
@test zeros(6) atol=1e-9
@@ -944,6 +945,7 @@ end
944945
@test mhe1([5]) [51, 32] atol=1e-3
945946

946947
mhe1 = MovingHorizonEstimator(nonlinmodel, He=2, nint_u=[1, 1], nint_ym=[0, 0], direct=false)
948+
JuMP.set_attribute(mhe1.optim, "tol", 1e-7)
947949
preparestate!(mhe1, [50, 30], [5])
948950
= updatestate!(mhe1, [10, 50], [50, 30], [5])
949951
@test zeros(6) atol=1e-9
@@ -1065,7 +1067,8 @@ end
10651067
updatestate!(mhe1, [0.0], y)
10661068
updatestate!(model, [0.1])
10671069
end
1068-
@test mhe1() model() atol = 1e-9
1070+
preparestate!(mhe1, model())
1071+
@test mhe1() model() atol = 1e-6
10691072
model = NonLinModel(f, h, 10.0, 1, 1, 1, solver=nothing)
10701073
mhe2 = MovingHorizonEstimator(model, nint_u=[1], He=3, direct=false)
10711074
for i = 1:40
@@ -1074,7 +1077,8 @@ end
10741077
updatestate!(mhe2, [0.0], y)
10751078
updatestate!(model, [0.1])
10761079
end
1077-
@test mhe2() model() atol = 1e-9
1080+
preparestate!(mhe2, model())
1081+
@test mhe2() model() atol = 1e-6
10781082
end
10791083

10801084
@testitem "MovingHorizonEstimator fallbacks for arrival covariance estimation" setup=[SetupMPCtests] begin

test/3_test_predictive_control.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,12 +1022,13 @@ end
10221022
end
10231023

10241024
@testitem "NonLinMPC constraint violation" setup=[SetupMPCtests] begin
1025-
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra
1025+
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra, JuMP
10261026
gc(Ue, Ŷe, _ ,p , ϵ) = [p[1]*(Ue[1:end-1] .- 4.2 .- ϵ); p[2]*(Ŷe[2:end] .- 3.14 .- ϵ)]
10271027
Hp=50
10281028

10291029
linmodel = LinModel(tf([2], [10000, 1]), 3000.0)
10301030
nmpc_lin = NonLinMPC(linmodel; Hp, Hc=5, gc, nc=2Hp, p=[0; 0])
1031+
JuMP.set_attribute(nmpc_lin.optim, "constr_viol_tol", 1e-3)
10311032

10321033
setconstraint!(nmpc_lin, x̂min=[-1e6,-Inf], x̂max=[1e6,+Inf])
10331034
setconstraint!(nmpc_lin, umin=[-10], umax=[10])
@@ -1098,6 +1099,7 @@ end
10981099
h = (x,_,p) -> p.C*x
10991100
nonlinmodel = NonLinModel(f, h, linmodel.Ts, 1, 1, 1, solver=nothing, p=linmodel)
11001101
nmpc = NonLinMPC(nonlinmodel; Hp, Hc=5, gc, nc=2Hp, p=[0; 0])
1102+
JuMP.set_attribute(nmpc.optim, "constr_viol_tol", 1e-3)
11011103

11021104
setconstraint!(nmpc, x̂min=[-1e6,-Inf], x̂max=[+1e6,+Inf])
11031105
setconstraint!(nmpc, umin=[-1e6], umax=[+1e6])
@@ -1167,6 +1169,7 @@ end
11671169
nmpc_ms = NonLinMPC(
11681170
nonlinmodel; Hp, Hc=5, transcription=MultipleShooting(), gc, nc=2Hp, p=[0; 0]
11691171
)
1172+
JuMP.set_attribute(nmpc_ms.optim, "constr_viol_tol", 1e-3)
11701173

11711174
setconstraint!(nmpc_ms, x̂min=[-1e6,-Inf], x̂max=[+1e6,+Inf])
11721175
setconstraint!(nmpc_ms, ymin=[-100], ymax=[100])

0 commit comments

Comments
 (0)