|
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 = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer, "nlp_scaling_max_gradient"=>1.0)) |
| 614 | + mhe10 = MovingHorizonEstimator(nonlinmodel, He=5, optim=optim) |
| 615 | + @test solver_name(mhe10.optim) == "Ipopt" |
615 | 616 |
|
616 | 617 | mhe11 = MovingHorizonEstimator(nonlinmodel, He=5, Cwt=1e3) |
617 | 618 | @test size(mhe11.Ẽ, 2) == 6*mhe11.nx̂ + 1 |
@@ -673,12 +674,14 @@ end |
673 | 674 | x̂ = updatestate!(mhe3, [0], [0]) |
674 | 675 | @test x̂ ≈ [0, 0] atol=1e-3 |
675 | 676 | @test isa(x̂, Vector{Float32}) |
| 677 | + |
| 678 | + mhe4 = setconstraint!(MovingHorizonEstimator(nonlinmodel, He=1, nint_ym=0), v̂max=[50,50]) |
676 | 679 |
|
677 | | - mhe4 = setconstraint!(MovingHorizonEstimator(nonlinmodel, He=1, nint_ym=0), x̂max=[50,50,50,50]) |
678 | | - g_X̂max_end = mhe4.optim.nlp_model.operators.registered_multivariate_operators[end].f |
679 | | - @test g_X̂max_end((1.0, 1.0, 1.0, 1.0)) ≤ 0.0 # test gfunc_i(i,::NTuple{N, Float64}) |
| 680 | + g_V̂max_end = mhe4.optim[:g_V̂max_2].func |
| 681 | + # test gfunc_i(i,::NTuple{N, Float64}) |
| 682 | + @test g_V̂max_end(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ≤ 0.0 |
680 | 683 | # test gfunc_i(i,::NTuple{N, ForwardDiff.Dual}) : |
681 | | - @test ForwardDiff.gradient(g_X̂max_end, [1.0, 1.0, 1.0, 1.0]) ≈ [0.0, 0.0, 0.0, 0.0] |
| 684 | + @test ForwardDiff.gradient(vec->g_V̂max_end(vec...), zeros(8)) ≈ zeros(8) |
682 | 685 | end |
683 | 686 |
|
684 | 687 | @testset "MovingHorizonEstimator set constraints" begin |
|
0 commit comments