@@ -610,16 +610,22 @@ end
610
610
@test mhe9. Q̂ ≈ I (6 )
611
611
@test mhe9. R̂ ≈ I (2 )
612
612
613
- mhe10 = MovingHorizonEstimator (nonlinmodel, He= 5 , optim= Model (OSQP. Optimizer))
614
- @test solver_name (mhe10. optim) == " OSQP"
613
+ optim = Model (Ipopt. Optimizer)
614
+ covestim = ExtendedKalmanFilter (nonlinmodel, 1 : 2 , 0 , [1 , 1 ], I_6, I_6, I_2)
615
+ mhe10 = MovingHorizonEstimator (
616
+ nonlinmodel, 5 , 1 : 2 , 0 , [1 , 1 ], I_6, I_6, I_2, Inf , optim, covestim
617
+ )
618
+
619
+ mhe11 = MovingHorizonEstimator (nonlinmodel, He= 5 , optim= Model (OSQP. Optimizer))
620
+ @test solver_name (mhe11. optim) == " OSQP"
615
621
616
- mhe11 = MovingHorizonEstimator (nonlinmodel, He= 5 , Cwt= 1e3 )
617
- @test size (mhe11 . Ẽ, 2 ) == 6 * mhe11 . nx̂ + 1
618
- @test mhe11 . C == 1e3
622
+ mhe12 = MovingHorizonEstimator (nonlinmodel, He= 5 , Cwt= 1e3 )
623
+ @test size (mhe12 . Ẽ, 2 ) == 6 * mhe12 . nx̂ + 1
624
+ @test mhe12 . C == 1e3
619
625
620
626
linmodel2 = LinModel {Float32} (0.5 * ones (1 ,1 ), ones (1 ,1 ), ones (1 ,1 ), zeros (1 ,0 ), zeros (1 ,0 ), 1.0 )
621
- mhe11 = MovingHorizonEstimator (linmodel2, He= 5 )
622
- @test isa (mhe11 , MovingHorizonEstimator{Float32})
627
+ mhe13 = MovingHorizonEstimator (linmodel2, He= 5 )
628
+ @test isa (mhe13 , MovingHorizonEstimator{Float32})
623
629
624
630
@test_throws ArgumentError MovingHorizonEstimator (linmodel1)
625
631
@test_throws ArgumentError MovingHorizonEstimator (linmodel1, He= 0 )
679
685
@test g_X̂max_end ((1.0 , 1.0 , 1.0 , 1.0 )) ≤ 0.0 # test gfunc_i(i,::NTuple{N, Float64})
680
686
# test gfunc_i(i,::NTuple{N, ForwardDiff.Dual}) :
681
687
@test ForwardDiff. gradient (g_X̂max_end, [1.0 , 1.0 , 1.0 , 1.0 ]) ≈ [0.0 , 0.0 , 0.0 , 0.0 ]
688
+
689
+ Q̂ = diagm ([1 / 4 , 1 / 4 , 1 / 4 , 1 / 4 ]. ^ 2 )
690
+ R̂ = diagm ([1 , 1 ]. ^ 2 )
691
+ optim = Model (Ipopt. Optimizer)
692
+ covestim = ExtendedKalmanFilter (nonlinmodel, 1 : 2 , 0 , 0 , Q̂, Q̂, R̂)
693
+ mhe5 = MovingHorizonEstimator (nonlinmodel, 1 , 1 : 2 , 0 , 0 , Q̂, Q̂, R̂, Inf , optim, covestim)
694
+ x̂ = updatestate! (mhe5, [10 , 50 ], [50 , 30 ], [5 ])
695
+ @test x̂ ≈ zeros (4 ) atol= 1e-9
696
+ @test mhe5. x̂ ≈ zeros (4 ) atol= 1e-9
697
+ @test evaloutput (mhe5, [5 ]) ≈ mhe5 ([5 ]) ≈ [50 , 30 ]
698
+ info = getinfo (mhe5)
699
+ @test info[:x̂ ] ≈ x̂ atol= 1e-9
700
+ @test info[:Ŷ ][end - 1 : end ] ≈ [50 , 30 ] atol= 1e-9
682
701
end
683
702
684
703
@testset " MovingHorizonEstimator set constraints" begin
0 commit comments