Skip to content

Commit 35b7f03

Browse files
committed
bench: new NonLinMPC benchs with Hessian
1 parent 38436a5 commit 35b7f03

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

benchmark/3_bench_predictive_control.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,18 @@ nmpc_nonlin_ss = NonLinMPC(
4646
nonlinmodel, transcription=SingleShooting(),
4747
Mwt=[1, 1], Nwt=[0.1, 0.1], Lwt=[0.1, 0.1], Hp=10
4848
)
49+
nmpc_nonlin_ss_hess = NonLinMPC(
50+
nonlinmodel_c, transcription=SingleShooting(), hessian=true,
51+
Mwt=[1], Nwt=[0.1], Lwt=[0.1], Hp=10
52+
)
4953
nmpc_nonlin_ms = NonLinMPC(
5054
nonlinmodel, transcription=MultipleShooting(),
5155
Mwt=[1, 1], Nwt=[0.1, 0.1], Lwt=[0.1, 0.1], Hp=10
5256
)
57+
nmpc_nonlin_ms_hess = NonLinMPC(
58+
nonlinmodel_c, transcription=MultipleShooting(), hessian=true,
59+
Mwt=[1], Nwt=[0.1], Lwt=[0.1], Hp=10
60+
)
5361
nmpc_nonlin_tc = NonLinMPC(
5462
nonlinmodel_c, transcription=TrapezoidalCollocation(),
5563
Mwt=[1], Nwt=[0.1], Lwt=[0.1], Hp=10
@@ -74,12 +82,24 @@ UNIT_MPC["NonLinMPC"]["moveinput!"]["NonLinModel"]["SingleShooting"] =
7482
setup=preparestate!($nmpc_nonlin_ss, $y, $d),
7583
samples=samples, evals=evals, seconds=seconds
7684
)
85+
UNIT_MPC["NonLinMPC"]["moveinput!"]["NonLinModel"]["SingleShootingHessian"] =
86+
@benchmarkable(
87+
moveinput!($nmpc_nonlin_ss, $y, $d),
88+
setup=preparestate!($nmpc_nonlin_ss_hess, $y, $d),
89+
samples=samples, evals=evals, seconds=seconds
90+
)
7791
UNIT_MPC["NonLinMPC"]["moveinput!"]["NonLinModel"]["MultipleShooting"] =
7892
@benchmarkable(
7993
moveinput!($nmpc_nonlin_ms, $y, $d),
8094
setup=preparestate!($nmpc_nonlin_ms, $y, $d),
8195
samples=samples, evals=evals, seconds=seconds
8296
)
97+
UNIT_MPC["NonLinMPC"]["moveinput!"]["NonLinModel"]["MultipleShootingHessian"] =
98+
@benchmarkable(
99+
moveinput!($nmpc_nonlin_ms, $y, $d),
100+
setup=preparestate!($nmpc_nonlin_ms_hess, $y, $d),
101+
samples=samples, evals=evals, seconds=seconds
102+
)
83103
UNIT_MPC["NonLinMPC"]["moveinput!"]["NonLinModel"]["TrapezoidalCollocation"] =
84104
@benchmarkable(
85105
moveinput!($nmpc_nonlin_tc, $y_c, $d_c),
@@ -258,12 +278,24 @@ nmpc_ipopt_ss = NonLinMPC(estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription)
258278
nmpc_ipopt_ss = setconstraint!(nmpc_ipopt_ss; umin, umax)
259279
JuMP.unset_time_limit_sec(nmpc_ipopt_ss.optim)
260280

281+
optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer,"sb"=>"yes"), add_bridges=false)
282+
transcription, hessian = SingleShooting(), true
283+
nmpc_ipopt_ss_hess = NonLinMPC(estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription, hessian)
284+
nmpc_ipopt_ss_hess = setconstraint!(nmpc_ipopt_ss_hess; umin, umax)
285+
JuMP.unset_time_limit_sec(nmpc_ipopt_ss_hess.optim)
286+
261287
optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer,"sb"=>"yes"), add_bridges=false)
262288
transcription = MultipleShooting()
263289
nmpc_ipopt_ms = NonLinMPC(estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription)
264290
nmpc_ipopt_ms = setconstraint!(nmpc_ipopt_ms; umin, umax)
265291
JuMP.unset_time_limit_sec(nmpc_ipopt_ms.optim)
266292

293+
optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer,"sb"=>"yes"), add_bridges=false)
294+
transcription, hessian = MultipleShooting(), true
295+
nmpc_ipopt_ms_hess = NonLinMPC(estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription, hessian)
296+
nmpc_ipopt_ms_hess = setconstraint!(nmpc_ipopt_ms_hess; umin, umax)
297+
JuMP.unset_time_limit_sec(nmpc_nmpc_ipopt_ms_hess.optim)
298+
267299
optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer,"sb"=>"yes"), add_bridges=false)
268300
transcription = MultipleShooting(f_threads=true)
269301
nmpc_ipopt_mst = NonLinMPC(estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription)
@@ -308,11 +340,21 @@ CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["Ipopt"]["SingleShooting"] =
308340
sim!($nmpc_ipopt_ss, $N, $ry; plant=$plant, x_0=$x_0, x̂_0=$x̂_0),
309341
samples=samples, evals=evals, seconds=seconds
310342
)
343+
CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["Ipopt"]["SingleShooting (Hessian)"] =
344+
@benchmarkable(
345+
sim!($nmpc_ipopt_ss_hess, $N, $ry; plant=$plant, x_0=$x_0, x̂_0=$x̂_0),
346+
samples=samples, evals=evals, seconds=seconds
347+
)
311348
CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["Ipopt"]["MultipleShooting"] =
312349
@benchmarkable(
313350
sim!($nmpc_ipopt_ms, $N, $ry; plant=$plant, x_0=$x_0, x̂_0=$x̂_0),
314351
samples=samples, evals=evals, seconds=seconds
315352
)
353+
CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["Ipopt"]["MultipleShooting (Hessian)"] =
354+
@benchmarkable(
355+
sim!($nmpc_ipopt_ms_hess, $N, $ry; plant=$plant, x_0=$x_0, x̂_0=$x̂_0),
356+
samples=samples, evals=evals, seconds=seconds
357+
)
316358
CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["Ipopt"]["MultipleShooting (threaded)"] =
317359
@benchmarkable(
318360
sim!($nmpc_ipopt_mst, $N, $ry; plant=$plant, x_0=$x_0, x̂_0=$x̂_0),

0 commit comments

Comments
 (0)