Skip to content

Commit 68825c5

Browse files
committed
bench: MadNLP with MultipleShooting and Hessian
1 parent b11d624 commit 68825c5

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

benchmark/3_bench_predictive_control.jl

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -379,19 +379,13 @@ nmpc_uno_ms_hess = NonLinMPC(estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription,
379379
nmpc_uno_ms_hess = setconstraint!(nmpc_uno_ms_hess; umin, umax)
380380
JuMP.unset_time_limit_sec(nmpc_uno_ms_hess.optim)
381381

382-
# TODO: does not work well with MadNLP and MultipleShooting or TrapezoidalCollocation,
383-
# figure out why. Current theory:
384-
# MadNLP LBFGS approximation is less robust than Ipopt version. Re-test when exact Hessians
385-
# will be supported in ModelPredictiveControl.jl. The following attributes kinda work with
386-
# the MadNLP LBFGS approximation but super slow (~1000 times slower than Ipopt):
387-
# optim = JuMP.Model(MadNLP.Optimizer)
388-
# transcription = MultipleShooting()
389-
# nmpc_madnlp_ms = NonLinMPC(estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription)
390-
# nmpc_madnlp_ms = setconstraint!(nmpc_madnlp_ms; umin, umax)
391-
# JuMP.unset_time_limit_sec(nmpc_madnlp_ms.optim)
392-
# JuMP.set_attribute(nmpc_madnlp_ms.optim, "hessian_approximation", MadNLP.CompactLBFGS)
393-
# MadNLP_QNopt = MadNLP.QuasiNewtonOptions(; max_history=42)
394-
# JuMP.set_attribute(nmpc_madnlp_ms.optim, "quasi_newton_options", MadNLP_QNopt)
382+
# skip MadNLP.jl with MultipleShooting and hessian=false, their LBFGS does not work well
383+
384+
optim = JuMP.Model(MadNLP.Optimizer)
385+
transcription, hessian = MultipleShooting(), true
386+
nmpc_madnlp_ms_hess = NonLinMPC(estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription, hessian)
387+
nmpc_madnlp_ms_hess = setconstraint!(nmpc_madnlp_ms_hess; umin, umax)
388+
JuMP.unset_time_limit_sec(nmpc_madnlp_ms_hess.optim)
395389

396390
samples, evals, seconds = 100, 1, 15*60
397391
CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["Ipopt"]["SingleShooting"] =
@@ -439,6 +433,11 @@ CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["MadNLP"]["SingleShooting"] =
439433
sim!($nmpc_madnlp_ss, $N, $ry; plant=$plant, x_0=$x_0, x̂_0=$x̂_0, progress=false),
440434
samples=samples, evals=evals, seconds=seconds
441435
)
436+
CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["MadNLP"]["MultipleShooting (Hessian)"] =
437+
@benchmarkable(
438+
sim!($nmpc_madnlp_ms_hess, $N, $ry; plant=$plant, x_0=$x_0, x̂_0=$x̂_0, progress=false),
439+
samples=samples, evals=evals, seconds=seconds
440+
)
442441
# CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["Uno"]["MultipleShooting (Hessian)"] =
443442
# @benchmarkable(
444443
# sim!($nmpc_uno_ms_hess, $N, $ry; plant=$plant, x_0=$x_0, x̂_0=$x̂_0, progress=false),

0 commit comments

Comments
 (0)