@@ -146,36 +146,26 @@ UNIT_ESTIM["ExtendedKalmanFilter"]["evaloutput"]["NonLinModel"] =
146146
147147mhe_lin_curr = MovingHorizonEstimator (linmodel, He= 10 , direct= true )
148148mhe_lin_pred = MovingHorizonEstimator (linmodel, He= 10 , direct= false )
149- mhe_lin_skf = MovingHorizonEstimator (linmodel, He= 10 , covestim= SteadyKalmanFilter (linmodel))
149+ mhe_lin_ms = MovingHorizonEstimator (linmodel, He= 10 , transcription= MultipleShooting ())
150+ mhe_lin_skf = MovingHorizonEstimator (linmodel, He= 10 , covestim= SteadyKalmanFilter (linmodel))
150151mhe_nonlin_curr = MovingHorizonEstimator (nonlinmodel, He= 10 , direct= true )
151152mhe_nonlin_pred = MovingHorizonEstimator (nonlinmodel, He= 10 , direct= false )
153+ mhe_nonlin_ms = MovingHorizonEstimator (nonlinmodel, He= 10 , transcription= MultipleShooting ())
152154
153155samples, evals, seconds = 10000 , 1 , 60
154156UNIT_ESTIM[" MovingHorizonEstimator" ][" preparestate!" ][" LinModel" ][" Current form" ] =
155157 @benchmarkable (
156158 preparestate! ($ mhe_lin_curr, $ y, $ d),
157159 samples= samples, evals= evals, seconds= seconds,
158160 )
159- UNIT_ESTIM[" MovingHorizonEstimator" ][" updatestate!" ][" LinModel" ][" Current form" ] =
160- @benchmarkable (
161- updatestate! ($ mhe_lin_curr, $ u, $ y, $ d),
162- setup= preparestate! ($ mhe_lin_curr, $ y, $ d),
163- samples= samples, evals= evals, seconds= seconds,
164- )
165161UNIT_ESTIM[" MovingHorizonEstimator" ][" preparestate!" ][" LinModel" ][" Constant arr. cov." ] =
166162 @benchmarkable (
167163 preparestate! ($ mhe_lin_skf, $ y, $ d),
168164 samples= samples, evals= evals, seconds= seconds,
169165 )
170- UNIT_ESTIM[" MovingHorizonEstimator" ][" updatestate!" ][" LinModel" ][" Constant arr. cov." ] =
171- @benchmarkable (
172- updatestate! ($ mhe_lin_skf, $ u, $ y, $ d),
173- setup= preparestate! ($ mhe_lin_skf, $ y, $ d),
174- samples= samples, evals= evals, seconds= seconds,
175- )
176- UNIT_ESTIM[" MovingHorizonEstimator" ][" preparestate!" ][" LinModel" ][" Prediction form" ] =
166+ UNIT_ESTIM[" MovingHorizonEstimator" ][" preparestate!" ][" LinModel" ][" MultipleShooting" ] =
177167 @benchmarkable (
178- preparestate! ($ mhe_lin_pred , $ y, $ d),
168+ preparestate! ($ mhe_lin_ms , $ y, $ d),
179169 samples= samples, evals= evals, seconds= seconds,
180170 )
181171UNIT_ESTIM[" MovingHorizonEstimator" ][" updatestate!" ][" LinModel" ][" Prediction form" ] =
@@ -195,15 +185,9 @@ UNIT_ESTIM["MovingHorizonEstimator"]["preparestate!"]["NonLinModel"]["Current fo
195185 preparestate! ($ mhe_nonlin_curr, $ y, $ d),
196186 samples= samples, evals= evals, seconds= seconds,
197187 )
198- UNIT_ESTIM[" MovingHorizonEstimator" ][" updatestate !" ][" NonLinModel" ][" Current form " ] =
188+ UNIT_ESTIM[" MovingHorizonEstimator" ][" preparestate !" ][" NonLinModel" ][" MultipleShooting " ] =
199189 @benchmarkable (
200- updatestate! ($ mhe_nonlin_curr, $ u, $ y, $ d),
201- setup= preparestate! ($ mhe_nonlin_curr, $ y, $ d),
202- samples= samples, evals= evals, seconds= seconds,
203- )
204- UNIT_ESTIM[" MovingHorizonEstimator" ][" preparestate!" ][" NonLinModel" ][" Prediction form" ] =
205- @benchmarkable (
206- preparestate! ($ mhe_nonlin_pred, $ y, $ d),
190+ preparestate! ($ mhe_nonlin_ms, $ y, $ d),
207191 samples= samples, evals= evals, seconds= seconds,
208192 )
209193UNIT_ESTIM[" MovingHorizonEstimator" ][" updatestate!" ][" NonLinModel" ][" Prediction form" ] =
@@ -254,6 +238,12 @@ mhe_cstr_osqp_curr = MovingHorizonEstimator(model; He, nint_u, σQint_u, optim,
254238mhe_cstr_osqp_curr = setconstraint! (mhe_cstr_osqp_curr; v̂min, v̂max)
255239JuMP. unset_time_limit_sec (mhe_cstr_osqp_curr. optim)
256240
241+ optim = JuMP. Model (OSQP. Optimizer, add_bridges= true )
242+ transcription = MultipleShooting ()
243+ mhe_cstr_osqp_ms = MovingHorizonEstimator (model; He, nint_u, σQint_u, optim, transcription)
244+ mhe_cstr_osqp_ms = setconstraint! (mhe_cstr_osqp_ms; v̂min, v̂max)
245+ JuMP. unset_time_limit_sec (mhe_cstr_osqp_ms. optim)
246+
257247optim = JuMP. Model (OSQP. Optimizer, add_bridges= true )
258248direct = false
259249mhe_cstr_osqp_pred = MovingHorizonEstimator (model; He, nint_u, σQint_u, optim, direct)
@@ -277,6 +267,10 @@ CASE_ESTIM["CSTR"]["MovingHorizonEstimator"]["OSQP"]["Current form"] =
277267 @benchmarkable (test_mhe ($ mhe_cstr_osqp_curr, $ plant);
278268 samples= samples, evals= evals
279269 )
270+ CASE_ESTIM[" CSTR" ][" MovingHorizonEstimator" ][" OSQP" ][" MultipleShooting" ] =
271+ @benchmarkable (test_mhe ($ mhe_cstr_osqp_ms, $ plant);
272+ samples= samples, evals= evals
273+ )
280274CASE_ESTIM[" CSTR" ][" MovingHorizonEstimator" ][" OSQP" ][" Prediction form" ] =
281275 @benchmarkable (test_mhe ($ mhe_cstr_osqp_pred, $ plant);
282276 samples= samples, evals= evals
@@ -300,15 +294,17 @@ N = 35;
300294
301295x_0 = [0.1 , 0.1 ]; x̂_0 = [0 , 0 , 0 ]; u = [0.5 ]
302296
297+ # ## The MHE without exact Hessians does not work well on the inverted pendulum, commenting them:
298+ # optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer,"sb"=>"yes"), add_bridges=false)
299+ # direct = true
300+ # mhe_pendulum_ipopt_curr = MovingHorizonEstimator(
301+ # model; He, σQ, σR, nint_u, σQint_u, optim, direct
302+ # )
303+ # mhe_pendulum_ipopt_curr = setconstraint!(mhe_pendulum_ipopt_curr; v̂min, v̂max)
304+ # JuMP.unset_time_limit_sec(mhe_pendulum_ipopt_curr.optim)
305+
303306optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
304307direct = true
305- mhe_pendulum_ipopt_curr = MovingHorizonEstimator (
306- model; He, σQ, σR, nint_u, σQint_u, optim, direct
307- )
308- mhe_pendulum_ipopt_curr = setconstraint! (mhe_pendulum_ipopt_curr; v̂min, v̂max)
309- JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_curr. optim)
310- JuMP. set_attribute (mhe_pendulum_ipopt_curr. optim, " tol" , 1e-7 )
311-
312308hessian = true
313309mhe_pendulum_ipopt_currh = MovingHorizonEstimator (
314310 model; He, σQ, σR, nint_u, σQint_u, optim, direct, hessian
@@ -317,21 +313,42 @@ mhe_pendulum_ipopt_currh = setconstraint!(mhe_pendulum_ipopt_currh; v̂min, v̂m
317313JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_currh. optim)
318314
319315optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
320- direct = false
321- mhe_pendulum_ipopt_pred = MovingHorizonEstimator (
322- model; He, σQ, σR, nint_u, σQint_u, optim, direct
316+ direct = true
317+ hessian = true
318+ transcription = MultipleShooting ()
319+ mhe_pendulum_ipopt_currhms = MovingHorizonEstimator (
320+ model; He, σQ, σR, nint_u, σQint_u, optim, direct, hessian, transcription
323321)
324- mhe_pendulum_ipopt_pred = setconstraint! (mhe_pendulum_ipopt_pred; v̂min, v̂max)
325- JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_pred. optim)
326- JuMP. set_attribute (mhe_pendulum_ipopt_pred. optim, " tol" , 1e-7 )
322+ mhe_pendulum_ipopt_currhms = setconstraint! (mhe_pendulum_ipopt_currhms; v̂min, v̂max)
323+ JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_currhms. optim)
324+
325+ # ## The MHE without exact Hessians does not work well on the inverted pendulum, commenting them:
326+ # optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer,"sb"=>"yes"), add_bridges=false)
327+ # direct = false
328+ # mhe_pendulum_ipopt_pred = MovingHorizonEstimator(
329+ # model; He, σQ, σR, nint_u, σQint_u, optim, direct
330+ # )
331+ # mhe_pendulum_ipopt_pred = setconstraint!(mhe_pendulum_ipopt_pred; v̂min, v̂max)
332+ # JuMP.unset_time_limit_sec(mhe_pendulum_ipopt_pred.optim)
327333
334+ optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
335+ direct = false
328336hessian = true
329337mhe_pendulum_ipopt_predh = MovingHorizonEstimator (
330338 model; He, σQ, σR, nint_u, σQint_u, optim, direct, hessian
331339)
332340mhe_pendulum_ipopt_predh = setconstraint! (mhe_pendulum_ipopt_predh; v̂min, v̂max)
333341JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_predh. optim)
334- JuMP. set_attribute (mhe_pendulum_ipopt_predh. optim, " tol" , 1e-7 )
342+
343+ optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
344+ direct = false
345+ hessian = true
346+ transcription = MultipleShooting ()
347+ mhe_pendulum_ipopt_predhms = MovingHorizonEstimator (
348+ model; He, σQ, σR, nint_u, σQint_u, optim, direct, hessian, transcription
349+ )
350+ mhe_pendulum_ipopt_predhms = setconstraint! (mhe_pendulum_ipopt_predhms; v̂min, v̂max)
351+ JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_predhms. optim)
335352
336353optim = JuMP. Model (MadNLP. Optimizer, add_bridges= false )
337354direct = true
@@ -341,7 +358,6 @@ mhe_pendulum_madnlp_currh = MovingHorizonEstimator(
341358)
342359mhe_pendulum_madnlp_currh = setconstraint! (mhe_pendulum_madnlp_currh; v̂min, v̂max)
343360JuMP. unset_time_limit_sec (mhe_pendulum_madnlp_currh. optim)
344- JuMP. set_attribute (mhe_pendulum_madnlp_currh. optim, " tol" , 1e-7 )
345361
346362optim = JuMP. Model (MadNLP. Optimizer, add_bridges= false )
347363direct = false
@@ -351,29 +367,57 @@ mhe_pendulum_madnlp_predh = MovingHorizonEstimator(
351367)
352368mhe_pendulum_madnlp_pred = setconstraint! (mhe_pendulum_madnlp_predh; v̂min, v̂max)
353369JuMP. unset_time_limit_sec (mhe_pendulum_madnlp_predh. optim)
354- JuMP. set_attribute (mhe_pendulum_madnlp_predh. optim, " tol" , 1e-7 )
370+
371+ optim = JuMP. Model (()-> UnoSolver. Optimizer (preset= " funnelsqp" ), add_bridges= false )
372+ direct = true
373+ hessian = true
374+ mhe_pendulum_uno_currh = MovingHorizonEstimator (
375+ model; He, σQ, σR, nint_u, σQint_u, optim, direct, hessian
376+ )
377+ mhe_pendulum_uno_currh = setconstraint! (mhe_pendulum_uno_currh; v̂min, v̂max)
378+ JuMP. unset_time_limit_sec (mhe_pendulum_uno_currh. optim)
379+
380+ optim = JuMP. Model (()-> UnoSolver. Optimizer (preset= " funnelsqp" ), add_bridges= false )
381+ direct = true
382+ hessian = true
383+ transcription = MultipleShooting ()
384+ mhe_pendulum_uno_currhms = MovingHorizonEstimator (
385+ model; He, σQ, σR, nint_u, σQint_u, optim, direct, hessian, transcription
386+ )
387+ mhe_pendulum_uno_currhms = setconstraint! (mhe_pendulum_uno_currhms; v̂min, v̂max)
388+ JuMP. unset_time_limit_sec (mhe_pendulum_uno_currhms. optim)
355389
356390samples, evals, seconds = 25 , 1 , 15 * 60
357- CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Current form" ] =
358- @benchmarkable (
359- sim! ($ mhe_pendulum_ipopt_curr, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
360- samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
361- )
391+ # CASE_ESTIM["Pendulum"]["MovingHorizonEstimator"]["Ipopt"]["Current form"] =
392+ # @benchmarkable(
393+ # sim!($mhe_pendulum_ipopt_curr, $N, $u; plant=$plant, x_0=$x_0, x̂_0=$x̂_0, progress=false),
394+ # samples=samples, evals=evals, seconds=seconds, setup=GC.gc()
395+ # )
362396CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Current form (Hessian)" ] =
363397 @benchmarkable (
364398 sim! ($ mhe_pendulum_ipopt_currh, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
365399 samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
366400 )
367- CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Prediction form" ] =
401+ CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Current form (Hessian, MultipleShooting) " ] =
368402 @benchmarkable (
369- sim! ($ mhe_pendulum_ipopt_pred , $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
403+ sim! ($ mhe_pendulum_ipopt_currhms , $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
370404 samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
371405 )
406+ # CASE_ESTIM["Pendulum"]["MovingHorizonEstimator"]["Ipopt"]["Prediction form"] =
407+ # @benchmarkable(
408+ # sim!($mhe_pendulum_ipopt_pred, $N, $u; plant=$plant, x_0=$x_0, x̂_0=$x̂_0, progress=false),
409+ # samples=samples, evals=evals, seconds=seconds, setup=GC.gc()
410+ # )
372411CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Prediction form (Hessian)" ] =
373412 @benchmarkable (
374413 sim! ($ mhe_pendulum_ipopt_predh, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
375414 samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
376415 )
416+ CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Prediction form (Hessian, MultipleShooting)" ] =
417+ @benchmarkable (
418+ sim! ($ mhe_pendulum_ipopt_predhms, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
419+ samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
420+ )
377421CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" MadNLP" ][" Current form (Hessian)" ] =
378422 @benchmarkable (
379423 sim! ($ mhe_pendulum_madnlp_currh, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
@@ -383,4 +427,14 @@ CASE_ESTIM["Pendulum"]["MovingHorizonEstimator"]["MadNLP"]["Prediction form (Hes
383427 @benchmarkable (
384428 sim! ($ mhe_pendulum_madnlp_predh, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
385429 samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
386- )
430+ )
431+ CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Uno" ][" Current form (Hessian)" ] =
432+ @benchmarkable (
433+ sim! ($ mhe_pendulum_uno_currh, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
434+ samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
435+ )
436+ CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Uno" ][" Current form (Hessian, MultipleShooting)" ] =
437+ @benchmarkable (
438+ sim! ($ mhe_pendulum_uno_currhms, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
439+ samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
440+ )
0 commit comments