@@ -294,15 +294,17 @@ N = 35;
294294
295295x_0 = [0.1 , 0.1 ]; x̂_0 = [0 , 0 , 0 ]; u = [0.5 ]
296296
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+
297306optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
298307direct = true
299- mhe_pendulum_ipopt_curr = MovingHorizonEstimator (
300- model; He, σQ, σR, nint_u, σQint_u, optim, direct
301- )
302- mhe_pendulum_ipopt_curr = setconstraint! (mhe_pendulum_ipopt_curr; v̂min, v̂max)
303- JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_curr. optim)
304- JuMP. set_attribute (mhe_pendulum_ipopt_curr. optim, " tol" , 1e-7 )
305-
306308hessian = true
307309mhe_pendulum_ipopt_currh = MovingHorizonEstimator (
308310 model; He, σQ, σR, nint_u, σQint_u, optim, direct, hessian
@@ -311,21 +313,42 @@ mhe_pendulum_ipopt_currh = setconstraint!(mhe_pendulum_ipopt_currh; v̂min, v̂m
311313JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_currh. optim)
312314
313315optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
314- direct = false
315- mhe_pendulum_ipopt_pred = MovingHorizonEstimator (
316- 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
317321)
318- mhe_pendulum_ipopt_pred = setconstraint! (mhe_pendulum_ipopt_pred; v̂min, v̂max)
319- JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_pred. optim)
320- 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)
321333
334+ optim = JuMP. Model (optimizer_with_attributes (Ipopt. Optimizer," sb" => " yes" ), add_bridges= false )
335+ direct = false
322336hessian = true
323337mhe_pendulum_ipopt_predh = MovingHorizonEstimator (
324338 model; He, σQ, σR, nint_u, σQint_u, optim, direct, hessian
325339)
326340mhe_pendulum_ipopt_predh = setconstraint! (mhe_pendulum_ipopt_predh; v̂min, v̂max)
327341JuMP. unset_time_limit_sec (mhe_pendulum_ipopt_predh. optim)
328- 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)
329352
330353optim = JuMP. Model (MadNLP. Optimizer, add_bridges= false )
331354direct = true
@@ -335,7 +358,6 @@ mhe_pendulum_madnlp_currh = MovingHorizonEstimator(
335358)
336359mhe_pendulum_madnlp_currh = setconstraint! (mhe_pendulum_madnlp_currh; v̂min, v̂max)
337360JuMP. unset_time_limit_sec (mhe_pendulum_madnlp_currh. optim)
338- JuMP. set_attribute (mhe_pendulum_madnlp_currh. optim, " tol" , 1e-7 )
339361
340362optim = JuMP. Model (MadNLP. Optimizer, add_bridges= false )
341363direct = false
@@ -345,29 +367,38 @@ mhe_pendulum_madnlp_predh = MovingHorizonEstimator(
345367)
346368mhe_pendulum_madnlp_pred = setconstraint! (mhe_pendulum_madnlp_predh; v̂min, v̂max)
347369JuMP. unset_time_limit_sec (mhe_pendulum_madnlp_predh. optim)
348- JuMP. set_attribute (mhe_pendulum_madnlp_predh. optim, " tol" , 1e-7 )
349370
350371samples, evals, seconds = 25 , 1 , 15 * 60
351- CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Current form" ] =
352- @benchmarkable (
353- sim! ($ mhe_pendulum_ipopt_curr, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
354- samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
355- )
372+ # CASE_ESTIM["Pendulum"]["MovingHorizonEstimator"]["Ipopt"]["Current form"] =
373+ # @benchmarkable(
374+ # sim!($mhe_pendulum_ipopt_curr, $N, $u; plant=$plant, x_0=$x_0, x̂_0=$x̂_0, progress=false),
375+ # samples=samples, evals=evals, seconds=seconds, setup=GC.gc()
376+ # )
356377CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Current form (Hessian)" ] =
357378 @benchmarkable (
358379 sim! ($ mhe_pendulum_ipopt_currh, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
359380 samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
360381 )
361- CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Prediction form" ] =
382+ CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Current form (Hessian, MultipleShooting) " ] =
362383 @benchmarkable (
363- sim! ($ mhe_pendulum_ipopt_pred , $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
384+ sim! ($ mhe_pendulum_ipopt_currhms , $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
364385 samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
365386 )
387+ # CASE_ESTIM["Pendulum"]["MovingHorizonEstimator"]["Ipopt"]["Prediction form"] =
388+ # @benchmarkable(
389+ # sim!($mhe_pendulum_ipopt_pred, $N, $u; plant=$plant, x_0=$x_0, x̂_0=$x̂_0, progress=false),
390+ # samples=samples, evals=evals, seconds=seconds, setup=GC.gc()
391+ # )
366392CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Prediction form (Hessian)" ] =
367393 @benchmarkable (
368394 sim! ($ mhe_pendulum_ipopt_predh, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
369395 samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
370396 )
397+ CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" Ipopt" ][" Prediction form (Hessian, MultipleShooting)" ] =
398+ @benchmarkable (
399+ sim! ($ mhe_pendulum_ipopt_predhms, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
400+ samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
401+ )
371402CASE_ESTIM[" Pendulum" ][" MovingHorizonEstimator" ][" MadNLP" ][" Current form (Hessian)" ] =
372403 @benchmarkable (
373404 sim! ($ mhe_pendulum_madnlp_currh, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
@@ -377,4 +408,4 @@ CASE_ESTIM["Pendulum"]["MovingHorizonEstimator"]["MadNLP"]["Prediction form (Hes
377408 @benchmarkable (
378409 sim! ($ mhe_pendulum_madnlp_predh, $ N, $ u; plant= $ plant, x_0= $ x_0, x̂_0= $ x̂_0, progress= false ),
379410 samples= samples, evals= evals, seconds= seconds, setup= GC. gc ()
380- )
411+ )
0 commit comments