Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions test/2_test_state_estim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2154,14 +2154,13 @@ end
end

@testitem "MHE LinModel v.s. NonLinModel" setup=[SetupMPCtests] begin
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra, JuMP, Ipopt
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra
linmodel = setop!(LinModel(sys,Ts,i_d=[3]), uop=[10,50], yop=[50,30], dop=[20])
f = (x,u,d,model) -> model.A*x + model.Bu*u + model.Bd*d
h = (x,d,model) -> model.C*x + model.Dd*d
nonlinmodel = NonLinModel(f, h, Ts, 2, 4, 2, 1, p=linmodel, solver=nothing)
nonlinmodel = setop!(nonlinmodel, uop=[10,50], yop=[50,30], dop=[20])
optim = JuMP.Model(optimizer_with_attributes(Ipopt.Optimizer, "sb" => "yes"))
mhe_lin = MovingHorizonEstimator(linmodel, He=5, nint_ym=0, direct=true, optim=optim)
mhe_lin = MovingHorizonEstimator(linmodel, He=5, nint_ym=0, direct=true)
mhe_lin = setconstraint!(
mhe_lin, x̂min=[-100, -100, -100, -100], ŵmin=[10,10,10,10]
)
Expand All @@ -2180,8 +2179,8 @@ end
updatestate!(mhe_lin, [11, 50], y, [25])
updatestate!(mhe_nonlin, [11, 50], y, [25])
end
@test X̂_lin ≈ X̂_nonlin atol=1e-3 rtol=1e-3
mhe2_lin = MovingHorizonEstimator(linmodel, He=5, nint_ym=0, direct=false, optim=optim)
@test X̂_lin ≈ X̂_nonlin atol=5e-3 rtol=5e-3
mhe2_lin = MovingHorizonEstimator(linmodel, He=5, nint_ym=0, direct=false)
mhe2_lin = setconstraint!(
mhe2_lin, x̂min=[-100, -100, -100, -100], ŵmin=[10,10,10,10]
)
Expand All @@ -2200,7 +2199,7 @@ end
updatestate!(mhe2_lin, [11, 50], y, [25])
updatestate!(mhe2_nonlin, [11, 50], y, [25])
end
@test X̂_lin ≈ X̂_nonlin atol=1e-3 rtol=1e-3
@test X̂_lin ≈ X̂_nonlin atol=5e-3 rtol=5e-3
end

@testitem "Manual construction" setup=[SetupMPCtests] begin
Expand Down
Loading