@@ -1241,17 +1241,17 @@ end
12411241end
12421242
12431243@testitem " MHE estim. & getinfo (NonLinModel, SS)" setup= [SetupMPCtests] begin
1244- using . SetupMPCtests, ControlSystemsBase, LinearAlgebra, ForwardDiff
1244+ using . SetupMPCtests, ControlSystemsBase, LinearAlgebra
12451245 using JuMP, Ipopt, DifferentiationInterface, SparseMatrixColorings, SparseConnectivityTracer
1246- import ForwardDiff
1246+ import FiniteDiff
12471247
12481248 linmodel = LinModel (sys,Ts,i_u= [1 ,2 ], i_d= [3 ])
12491249 linmodel = setop! (linmodel, uop= [10 ,50 ], yop= [50 ,30 ], dop= [5 ])
12501250 f (x,u,d,model) = model. A* x + model. Bu* u + model. Bd* d
12511251 h (x,d,model) = model. C* x + model. Dd* d
12521252 nonlinmodel = NonLinModel (f, h, Ts, 2 , 4 , 2 , 1 , solver= nothing , p= linmodel)
12531253 nonlinmodel = setop! (nonlinmodel, uop= [10 ,50 ], yop= [50 ,30 ], dop= [5 ])
1254-
1254+ #=
12551255 mhe1 = MovingHorizonEstimator(nonlinmodel, He=3)
12561256 JuMP.set_attribute(mhe1.optim, "tol", 1e-7)
12571257 preparestate!(mhe1, [50, 30], [5])
@@ -1327,7 +1327,7 @@ end
13271327 end
13281328 preparestate!(mhe2, [50, 30], [5])
13291329 @test mhe2([5]) ≈ [50, 30] atol=5e-3
1330-
1330+ =#
13311331 Q̂ = diagm ([1 / 4 , 1 / 4 , 1 / 4 , 1 / 4 ]. ^ 2 )
13321332 R̂ = diagm ([1 , 1 ]. ^ 2 )
13331333 optim = Model (Ipopt. Optimizer)
@@ -1344,8 +1344,7 @@ end
13441344 @test info[:Ŷ ][end - 1 : end ] ≈ [50 , 30 ] atol= 1e-9
13451345
13461346 # coverage of the branch with error termination status (with an infeasible problem):
1347- mhe_infeas = MovingHorizonEstimator (nonlinmodel, He= 1 , Cwt= Inf )
1348- mhe_infeas = setconstraint! (mhe_infeas, v̂min= [1 , 1 ], v̂max= [- 1 , - 1 ])
1347+ mhe_infeas = setconstraint! (mhe5, v̂min= [1 , 1 ], v̂max= [- 1 , - 1 ])
13491348 @test_logs (
13501349 (:error , " MHE terminated without solution: estimation in open-loop " *
13511350 " (more info in debug log)" ),
@@ -1355,19 +1354,16 @@ end
13551354 @test_nowarn ModelPredictiveControl. info2debugstr (info)
13561355 @test_throws ErrorException setstate! (mhe1, [1 ,2 ,3 ,4 ,5 ,6 ], diagm (.1 : .1 : .6 ))
13571356
1358- hessian = AutoSparse (
1359- AutoForwardDiff ();
1360- sparsity_detector= TracerSparsityDetector (),
1361- coloring_algorithm= GreedyColoringAlgorithm (),
1362- )
1357+ hessian = AutoFiniteDiff ()
13631358
13641359 mhe8 = MovingHorizonEstimator (nonlinmodel; He= 2 , hessian)
1360+ @test mhe8. hessian isa AutoFiniteDiff
13651361 @test_logs (
13661362 (:warn , " NaN values in the MHE measurements ym: ignoring them in the objective" ),
13671363 preparestate! (mhe8, [50 , NaN ], [5 ])
13681364 )
13691365 @test mhe8. x̂0 ≈ zeros (6 ) atol= 1e-9
1370-
1366+ #=
13711367 function f!(ẋ, x, u, d, p)
13721368 ẋ[] = -p[] * (x[] - 0.2 * u[] - 0.2 * d[])
13731369 return nothing
@@ -1388,6 +1384,7 @@ end
13881384 @test mhe_foh([0.0]) ≈ [1.5]
13891385 info = getinfo(mhe_foh)
13901386 @test info[:x̂] ≈ x̂
1387+ =#
13911388end
13921389
13931390@testitem " MHE estim. & getinfo (NonLinModel, MS)" setup= [SetupMPCtests] begin
0 commit comments