@@ -50,6 +50,10 @@ nmpc_nonlin_ms = NonLinMPC(
50
50
nonlinmodel, transcription= MultipleShooting (),
51
51
Mwt= [1 , 1 ], Nwt= [0.1 , 0.1 ], Lwt= [0.1 , 0.1 ], Hp= 10
52
52
)
53
+ nmpc_nonlin_tc = NonLinMPC (
54
+ nonlinmodel_c, transcription= TrapezoidalCollocation (),
55
+ Mwt= [1 ], Nwt= [0.1 ], Lwt= [0.1 ], Hp= 10
56
+ )
53
57
54
58
samples, evals, seconds = 10000 , 1 , 60
55
59
UNIT_MPC[" NonLinMPC" ][" moveinput!" ][" LinModel" ][" SingleShooting" ] =
@@ -76,6 +80,12 @@ UNIT_MPC["NonLinMPC"]["moveinput!"]["NonLinModel"]["MultipleShooting"] =
76
80
setup= preparestate! ($ nmpc_nonlin_ms, $ y, $ d),
77
81
samples= samples, evals= evals, seconds= seconds
78
82
)
83
+ UNIT_MPC[" NonLinMPC" ][" moveinput!" ][" NonLinModel" ][" TrapezoidalCollocation" ] =
84
+ @benchmarkable (
85
+ moveinput! ($ nmpc_nonlin_tc, $ y_c, $ d_c),
86
+ setup= preparestate! ($ nmpc_nonlin_tc, $ y_c, $ d_c),
87
+ samples= samples, evals= evals, seconds= seconds
88
+ )
79
89
80
90
# # ----------------------------------------------------------------------------------------
81
91
# # ---------------------- CASE STUDIES ----------------------------------------------------
@@ -230,7 +240,6 @@ CASE_MPC["CSTR"]["LinMPC"]["With feedforward"]["Ipopt"]["MultipleShooting"] =
230
240
samples= samples, evals= evals
231
241
)
232
242
233
-
234
243
# ----------------- Case study: Pendulum noneconomic -----------------------------
235
244
model, p = pendulum_model, pendulum_p
236
245
σQ = [0.1 , 1.0 ]; σR= [5.0 ]; nint_u= [1 ]; σQint_u= [0.1 ]
@@ -255,13 +264,20 @@ nmpc_ipopt_ms = NonLinMPC(estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription)
255
264
nmpc_ipopt_ms = setconstraint! (nmpc_ipopt_ms; umin, umax)
256
265
JuMP. unset_time_limit_sec (nmpc_ipopt_ms. optim)
257
266
267
+ optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
268
+ transcription = TrapezoidalCollocation ()
269
+ nmpc_ipopt_tc = NonLinMPC (estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription)
270
+ nmpc_ipopt_tc = setconstraint! (nmpc_ipopt_tc; umin, umax)
271
+ JuMP. unset_time_limit_sec (nmpc_ipopt_tc. optim)
272
+
258
273
optim = JuMP. Model (MadNLP. Optimizer, add_bridges= false )
259
274
transcription = SingleShooting ()
260
275
nmpc_madnlp_ss = NonLinMPC (estim; Hp, Hc, Mwt, Nwt, Cwt, optim, transcription)
261
276
nmpc_madnlp_ss = setconstraint! (nmpc_madnlp_ss; umin, umax)
262
277
JuMP. unset_time_limit_sec (nmpc_madnlp_ss. optim)
263
278
264
- # TODO : does not work well with MadNLP and MultipleShooting, figure out why. Current theory:
279
+ # TODO : does not work well with MadNLP and MultipleShooting or TrapezoidalCollocation,
280
+ # figure out why. Current theory:
265
281
# MadNLP LBFGS approximation is less robust than Ipopt version. Re-test when exact Hessians
266
282
# will be supported in ModelPredictiveControl.jl. The following attributes kinda work with
267
283
# the MadNLP LBFGS approximation but super slow (~1000 times slower than Ipopt):
@@ -285,6 +301,11 @@ CASE_MPC["Pendulum"]["NonLinMPC"]["Noneconomic"]["Ipopt"]["MultipleShooting"] =
285
301
sim! ($ nmpc_ipopt_ms, $ N, $ ry; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0),
286
302
samples= samples, evals= evals, seconds= seconds
287
303
)
304
+ CASE_MPC[" Pendulum" ][" NonLinMPC" ][" Noneconomic" ][" Ipopt" ][" TrapezoidalCollocation" ] =
305
+ @benchmarkable (
306
+ sim! ($ nmpc_ipopt_tc, $ N, $ ry; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0),
307
+ samples= samples, evals= evals, seconds= seconds
308
+ )
288
309
CASE_MPC[" Pendulum" ][" NonLinMPC" ][" Noneconomic" ][" MadNLP" ][" SingleShooting" ] =
289
310
@benchmarkable (
290
311
sim! ($ nmpc_madnlp_ss, $ N, $ ry; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0),
@@ -316,13 +337,19 @@ empc_ipopt_ms = NonLinMPC(estim2; Hp, Hc, Nwt, Mwt=Mwt2, Cwt, JE, Ewt, optim, tr
316
337
empc_ipopt_ms = setconstraint! (empc_ipopt_ms; umin, umax)
317
338
JuMP. unset_time_limit_sec (empc_ipopt_ms. optim)
318
339
340
+ optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
341
+ transcription = TrapezoidalCollocation ()
342
+ empc_ipopt_tc = NonLinMPC (estim2; Hp, Hc, Nwt, Mwt= Mwt2, Cwt, JE, Ewt, optim, transcription, p)
343
+ empc_ipopt_tc = setconstraint! (empc_ipopt_tc; umin, umax)
344
+ JuMP. unset_time_limit_sec (empc_ipopt_tc. optim)
345
+
319
346
optim = JuMP. Model (MadNLP. Optimizer, add_bridges= false )
320
347
transcription = SingleShooting ()
321
348
empc_madnlp_ss = NonLinMPC (estim2; Hp, Hc, Nwt, Mwt= Mwt2, Cwt, JE, Ewt, optim, transcription, p)
322
349
empc_madnlp_ss = setconstraint! (empc_madnlp_ss; umin, umax)
323
350
JuMP. unset_time_limit_sec (empc_madnlp_ss. optim)
324
351
325
- # TODO : test EMPC with MadNLP and MultipleShooting, see comment above.
352
+ # TODO : test EMPC with MadNLP and MultipleShooting and TrapezoidalCollocation , see comment above.
326
353
327
354
samples, evals, seconds = 100 , 1 , 15 * 60
328
355
CASE_MPC[" Pendulum" ][" NonLinMPC" ][" Economic" ][" Ipopt" ][" SingleShooting" ] =
@@ -335,6 +362,11 @@ CASE_MPC["Pendulum"]["NonLinMPC"]["Economic"]["Ipopt"]["MultipleShooting"] =
335
362
sim! ($ empc_ipopt_ms, $ N, $ ry; plant= $ plant2, x_0= $ x_0, x̂_0= $ x̂_0),
336
363
samples= samples, evals= evals, seconds= seconds
337
364
)
365
+ CASE_MPC[" Pendulum" ][" NonLinMPC" ][" Economic" ][" Ipopt" ][" TrapezoidalCollocation" ] =
366
+ @benchmarkable (
367
+ sim! ($ empc_ipopt_tc, $ N, $ ry; plant= $ plant2, x_0= $ x_0, x̂_0= $ x̂_0),
368
+ samples= samples, evals= evals, seconds= seconds
369
+ )
338
370
CASE_MPC[" Pendulum" ][" NonLinMPC" ][" Economic" ][" MadNLP" ][" SingleShooting" ] =
339
371
@benchmarkable (
340
372
sim! ($ empc_madnlp_ss, $ N, $ ry; plant= $ plant2, x_0= $ x_0, x̂_0= $ x̂_0),
@@ -373,8 +405,17 @@ nmpc2_ipopt_ms = NonLinMPC(estim2;
373
405
nmpc2_ipopt_ms = setconstraint! (nmpc2_ipopt_ms; umin, umax)
374
406
JuMP. unset_time_limit_sec (nmpc2_ipopt_ms. optim)
375
407
408
+ optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
409
+ transcription = TrapezoidalCollocation ()
410
+ nmpc2_ipopt_tc = NonLinMPC (estim2;
411
+ Hp, Hc, Nwt= Nwt, Mwt= [0.5 , 0 ], Cwt, gc!, nc, p= Pmax, optim, transcription
412
+ )
413
+ nmpc2_ipopt_tc = setconstraint! (nmpc2_ipopt_tc; umin, umax)
414
+ JuMP. unset_time_limit_sec (nmpc2_ipopt_tc. optim)
415
+
376
416
# TODO : test custom constraints with MadNLP and SingleShooting, see comment above.
377
417
# TODO : test custom constraints with MadNLP and MultipleShooting, see comment above.
418
+ # TODO : test custom constraints with MadNLP and TrapezoidalCollocation, see comment above.
378
419
379
420
samples, evals, seconds = 100 , 1 , 15 * 60
380
421
CASE_MPC[" Pendulum" ][" NonLinMPC" ][" Custom constraints" ][" Ipopt" ][" SingleShooting" ] =
@@ -387,6 +428,11 @@ CASE_MPC["Pendulum"]["NonLinMPC"]["Custom constraints"]["Ipopt"]["MultipleShooti
387
428
sim! ($ nmpc2_ipopt_ms, $ N, $ ry; plant= $ plant2, x_0= $ x_0, x̂_0= $ x̂_0),
388
429
samples= samples, evals= evals, seconds= seconds
389
430
)
431
+ CASE_MPC[" Pendulum" ][" NonLinMPC" ][" Custom constraints" ][" Ipopt" ][" TrapezoidalCollocation" ] =
432
+ @benchmarkable (
433
+ sim! ($ nmpc2_ipopt_tc, $ N, $ ry; plant= $ plant2, x_0= $ x_0, x̂_0= $ x̂_0),
434
+ samples= samples, evals= evals, seconds= seconds
435
+ )
390
436
391
437
# ----------------- Case study: Pendulum successive linearization -------------------------
392
438
linmodel = linearize (model, x= [0 , 0 ], u= [0 ])
0 commit comments