Skip to content

Commit fc578dd

Browse files
committed
bench: increase samples to reduce uncertainty
1 parent a811f83 commit fc578dd

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

benchmark/1_bench_sim_model.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## ----------------- Unit tests ----------------------------------------------------------
2-
const UNIT_MODEL = SUITE["unit tests"]["SimModel"]
1+
## ----------------------------------------------------------------------------------------
2+
## ----------------- UNIT TESTS ----------------------------------------------------------
3+
## ----------------------------------------------------------------------------------------
4+
const UNIT_MODEL = SUITE["UNIT TESTS"]["SimModel"]
35

46
UNIT_MODEL["LinModel"]["updatestate!"] =
57
@benchmarkable(
@@ -22,6 +24,8 @@ UNIT_MODEL["NonLinModel"]["linearize!"] =
2224
linearize!($linmodel, $nonlinmodel);
2325
)
2426

25-
## ----------------- Case studies ---------------------------------------------------------
26-
const CASE_MODEL = SUITE["case studies"]["SimModel"]
27+
## ----------------------------------------------------------------------------------------
28+
## ----------------- CASE STUDIES ---------------------------------------------------------
29+
## ----------------------------------------------------------------------------------------
30+
const CASE_MODEL = SUITE["CASE STUDIES"]["SimModel"]
2731
# TODO: Add case study benchmarks for SimModel

benchmark/2_bench_state_estim.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## ----------------- Unit tests -----------------------------------------------------------
2-
const UNIT_ESTIM = SUITE["unit tests"]["StateEstimator"]
1+
## ----------------------------------------------------------------------------------------
2+
## ----------------- UNIT TESTS -----------------------------------------------------------
3+
## ----------------------------------------------------------------------------------------
4+
const UNIT_ESTIM = SUITE["UNIT TESTS"]["StateEstimator"]
35

46
skf = SteadyKalmanFilter(linmodel)
57
UNIT_ESTIM["SteadyKalmanFilter"]["preparestate!"] =
@@ -193,8 +195,10 @@ UNIT_ESTIM["MovingHorizonEstimator"]["updatestate!"]["NonLinModel"]["Prediction
193195
samples=samples, evals=evals, seconds=seconds,
194196
)
195197

196-
## ----------------- Case studies ---------------------------------------------------
197-
const CASE_ESTIM = SUITE["case studies"]["StateEstimator"]
198+
## ----------------------------------------------------------------------------------------
199+
## ----------------- CASE STUDIES ---------------------------------------------------------
200+
## ----------------------------------------------------------------------------------------
201+
const CASE_ESTIM = SUITE["CASE STUDIES"]["StateEstimator"]
198202

199203
## ----------------- Case study: CSTR -----------------------------------------------------
200204
G = [ tf(1.90, [18, 1]) tf(1.90, [18, 1]);
@@ -258,7 +262,7 @@ mhe_cstr_ipopt_pred = MovingHorizonEstimator(model; He, nint_u, σQint_u, optim,
258262
mhe_cstr_ipopt_pred = setconstraint!(mhe_cstr_ipopt_pred, v̂min=[-1, -0.5], v̂max=[+1, +0.5])
259263
JuMP.unset_time_limit_sec(mhe_cstr_ipopt_pred.optim)
260264

261-
samples, evals = 500, 1
265+
samples, evals = 5000, 1
262266
CASE_ESTIM["CSTR"]["MovingHorizonEstimator"]["OSQP"]["Current form"] =
263267
@benchmarkable(test_mhe($mhe_cstr_osqp_curr, $plant);
264268
samples=samples, evals=evals

benchmark/3_bench_predictive_control.jl

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# ---------------------- Unit tests -------------------------------------------------------
2-
const UNIT_MPC = SUITE["unit tests"]["PredictiveController"]
1+
# -----------------------------------------------------------------------------------------
2+
# ---------------------- UNIT TESTS -------------------------------------------------------
3+
# -----------------------------------------------------------------------------------------
4+
const UNIT_MPC = SUITE["UNIT TESTS"]["PredictiveController"]
35

46
linmpc_ss = LinMPC(
57
linmodel, transcription=SingleShooting(),
@@ -10,7 +12,7 @@ linmpc_ms = LinMPC(
1012
Mwt=[1, 1], Nwt=[0.1, 0.1], Lwt=[0.1, 0.1], Hp=10
1113
)
1214

13-
samples, evals, seconds = 500, 1, 60
15+
samples, evals, seconds = 5000, 1, 60
1416
UNIT_MPC["LinMPC"]["moveinput!"]["SingleShooting"] =
1517
@benchmarkable(
1618
moveinput!($linmpc_ss, $y, $d),
@@ -49,7 +51,7 @@ nmpc_nonlin_ms = NonLinMPC(
4951
Mwt=[1, 1], Nwt=[0.1, 0.1], Lwt=[0.1, 0.1], Hp=10
5052
)
5153

52-
samples, evals, seconds = 500, 1, 60
54+
samples, evals, seconds = 5000, 1, 60
5355
UNIT_MPC["NonLinMPC"]["moveinput!"]["LinModel"]["SingleShooting"] =
5456
@benchmarkable(
5557
moveinput!($nmpc_lin_ss, $y, $d),
@@ -75,9 +77,10 @@ UNIT_MPC["NonLinMPC"]["moveinput!"]["NonLinModel"]["MultipleShooting"] =
7577
samples=samples, evals=evals, seconds=seconds
7678
)
7779

78-
79-
## ---------------------- Case studies ----------------------------------------------------
80-
const CASE_MPC = SUITE["case studies"]["PredictiveController"]
80+
## ----------------------------------------------------------------------------------------
81+
## ---------------------- CASE STUDIES ----------------------------------------------------
82+
## ----------------------------------------------------------------------------------------
83+
const CASE_MPC = SUITE["CASE STUDIES"]["PredictiveController"]
8184

8285
## ----------------- Case study: CSTR without feedforward ------------------------
8386
G = [ tf(1.90, [18, 1]) tf(1.90, [18, 1]);
@@ -135,7 +138,7 @@ transcription = MultipleShooting()
135138
mpc_ipopt_ms = setconstraint!(LinMPC(model; optim, transcription), ymin=[45, -Inf])
136139
JuMP.unset_time_limit_sec(mpc_ipopt_ms.optim)
137140

138-
samples, evals = 500, 1
141+
samples, evals = 5000, 1
139142
CASE_MPC["CSTR"]["LinMPC"]["Without feedforward"]["OSQP"]["SingleShooting"] =
140143
@benchmarkable(test_mpc($mpc_osqp_ss, $plant);
141144
samples=samples, evals=evals
@@ -209,7 +212,7 @@ transcription = MultipleShooting()
209212
mpc_d_ipopt_ms = setconstraint!(LinMPC(model_d; optim, transcription), ymin=[45, -Inf])
210213
JuMP.unset_time_limit_sec(mpc_d_ipopt_ms.optim)
211214

212-
samples, evals = 500, 1
215+
samples, evals = 5000, 1
213216
CASE_MPC["CSTR"]["LinMPC"]["With feedforward"]["OSQP"]["SingleShooting"] =
214217
@benchmarkable(test_mpc_d($mpc_d_osqp_ss, $plant);
215218
samples=samples, evals=evals
@@ -285,7 +288,7 @@ JuMP.unset_time_limit_sec(nmpc_madnlp_ss.optim)
285288
# MadNLP_QNopt = MadNLP.QuasiNewtonOptions(; max_history=42)
286289
# JuMP.set_attribute(nmpc_madnlp_ms.optim, "quasi_newton_options", MadNLP_QNopt)
287290

288-
samples, evals, seconds = 50, 1, 15*60
291+
samples, evals, seconds = 100, 1, 15*60
289292
CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["Ipopt"]["SingleShooting"] =
290293
@benchmarkable(
291294
sim!($nmpc_ipopt_ss, $N, $ry; plant=$plant, x_0=$x_0, x̂_0=$x̂_0),
@@ -336,7 +339,7 @@ JuMP.unset_time_limit_sec(empc_madnlp_ss.optim)
336339

337340
# TODO: test EMPC with MadNLP and MultipleShooting, see comment above.
338341

339-
samples, evals, seconds = 50, 1, 15*60
342+
samples, evals, seconds = 100, 1, 15*60
340343
CASE_MPC["Pendulum"]["NonLinMPC"]["Economic"]["Ipopt"]["SingleShooting"] =
341344
@benchmarkable(
342345
sim!($empc_ipopt_ss, $N, $ry; plant=$plant2, x_0=$x_0, x̂_0=$x̂_0),
@@ -388,7 +391,7 @@ JuMP.unset_time_limit_sec(nmpc2_ipopt_ms.optim)
388391
# TODO: test custom constraints with MadNLP and SingleShooting, see comment above.
389392
# TODO: test custom constraints with MadNLP and MultipleShooting, see comment above.
390393

391-
samples, evals, seconds = 50, 1, 15*60
394+
samples, evals, seconds = 100, 1, 15*60
392395
CASE_MPC["Pendulum"]["NonLinMPC"]["Custom constraints"]["Ipopt"]["SingleShooting"] =
393396
@benchmarkable(
394397
sim!($nmpc2_ipopt_ss, $N, $ry; plant=$plant2, x_0=$x_0, x̂_0=$x̂_0),
@@ -458,7 +461,7 @@ mpc3_ipopt_ms = LinMPC(kf; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription)
458461
mpc3_ipopt_ms = setconstraint!(mpc3_ipopt_ms; umin, umax)
459462
JuMP.unset_time_limit_sec(mpc3_ipopt_ms.optim)
460463

461-
samples, evals = 500, 1
464+
samples, evals = 5000, 1
462465
CASE_MPC["Pendulum"]["LinMPC"]["Successive linearization"]["OSQP"]["SingleShooting"] =
463466
@benchmarkable(
464467
sim2!($mpc3_osqp_ss, $model, $N, $ry, $plant, $x_0, $x̂_0, $y_step),

benchmark/benchmarks.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ using JuMP, OSQP, DAQP, Ipopt, MadNLP
44

55
const SUITE = BenchmarkGroup(["ModelPredictiveControl"])
66

7-
SUITE["unit tests"] = BenchmarkGroup(["allocation-free", "allocations", "single call"])
8-
SUITE["case studies"] = BenchmarkGroup(["performance", "speed" ,"integration"])
7+
SUITE["UNIT TESTS"] = BenchmarkGroup(["allocation-free", "allocations", "single call"])
8+
SUITE["CASE STUDIES"] = BenchmarkGroup(["performance", "speed" ,"integration"])
99

1010
include("0_bench_setup.jl")
1111
include("1_bench_sim_model.jl")

0 commit comments

Comments
 (0)