Skip to content

Commit f0f8d2a

Browse files
authored
Merge pull request #227 from JuliaControl/new_version
bump
2 parents cd18b83 + e5288df commit f0f8d2a

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelPredictiveControl"
22
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
33
authors = ["Francis Gagnon"]
4-
version = "1.8.1"
4+
version = "1.8.2"
55

66
[deps]
77
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"

benchmark/2_bench_state_estim.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ mhe_pendulum_ipopt_curr = MovingHorizonEstimator(
303303
)
304304
mhe_pendulum_ipopt_curr = setconstraint!(mhe_pendulum_ipopt_curr; v̂min, v̂max)
305305
JuMP.unset_time_limit_sec(mhe_pendulum_ipopt_curr.optim)
306+
JuMP.set_attribute(mhe_pendulum_ipopt_curr.optim, "tol", 1e-7)
306307

307308
optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer,"sb"=>"yes"), add_bridges=false)
308309
direct = false
@@ -311,6 +312,7 @@ mhe_pendulum_ipopt_pred = MovingHorizonEstimator(
311312
)
312313
mhe_pendulum_ipopt_pred = setconstraint!(mhe_pendulum_ipopt_pred; v̂min, v̂max)
313314
JuMP.unset_time_limit_sec(mhe_pendulum_ipopt_pred.optim)
315+
JuMP.set_attribute(mhe_pendulum_ipopt_pred.optim, "tol", 1e-7)
314316

315317
optim = JuMP.Model(MadNLP.Optimizer, add_bridges=false)
316318
direct = true
@@ -319,6 +321,7 @@ mhe_pendulum_madnlp_curr = MovingHorizonEstimator(
319321
)
320322
mhe_pendulum_madnlp_curr = setconstraint!(mhe_pendulum_madnlp_curr; v̂min, v̂max)
321323
JuMP.unset_time_limit_sec(mhe_pendulum_madnlp_curr.optim)
324+
JuMP.set_attribute(mhe_pendulum_madnlp_curr.optim, "tol", 1e-7)
322325

323326
optim = JuMP.Model(MadNLP.Optimizer, add_bridges=false)
324327
direct = false
@@ -327,6 +330,7 @@ mhe_pendulum_madnlp_pred = MovingHorizonEstimator(
327330
)
328331
mhe_pendulum_madnlp_pred = setconstraint!(mhe_pendulum_madnlp_pred; v̂min, v̂max)
329332
JuMP.unset_time_limit_sec(mhe_pendulum_madnlp_pred.optim)
333+
JuMP.set_attribute(mhe_pendulum_madnlp_pred.optim, "tol", 1e-7)
330334

331335
samples, evals, seconds = 10, 1, 15*60
332336
CASE_ESTIM["Pendulum"]["MovingHorizonEstimator"]["Ipopt"]["Current form"] =

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)