Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions src/estimator/mhe/transcription.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1083,9 +1083,12 @@ function reset_warmstart!(estim::MovingHorizonEstimator, ::TrapezoidalCollocatio
end
return nothing
end
function reset_warmstart!(estim::MovingHorizonEstimator, ::OrthogonalCollocation)
function reset_warmstart!(estim::MovingHorizonEstimator, transcription::OrthogonalCollocation)
model = estim.model
nx, nx̂, nx̃, nε, He, na = model.nx, estim.nx̂, estim.nx̃, estim.nε, estim.He, get_na(model)
no = transcription.no
nx, nx̂, nx̃, nε, He = model.nx, estim.nx̂, estim.nx̃, estim.nε, estim.He
na = get_na(model)
nā, nk̄ = get_nā(model, transcription), get_nk̄(model, transcription)
as_0 = get_as_0(model)
x0s = model.buffer.x
x0s .= model.xs_0 .- model.xop
Expand All @@ -1096,9 +1099,11 @@ function reset_warmstart!(estim::MovingHorizonEstimator, ::OrthogonalCollocation
for j in 1:He
estim.Z̃[(nx̃+(j-1)*nx̂+1):(nx̃+(j-1)*nx̂+nx)] .= x0s
estim.Z̃[(nx̃+nx̂*He+na+(j-1)*na+1):(nx̃+nx̂*He+na+j*na)] .= a0s
estim.Z̃[(nx̃+nx̂*He+na+na*He+(j-1)*nx+1):(nx̃+nx̂*He+na+na*He+j*nx)] .= x0s
estim.Z̃[(nx̃+nx̂*He+na+na*He+nx*He+(j-1)*na+1):(nx̃+nx̂*He+na+na*He+nx*He+j*na)] .= a0s
end
K̄ = @views estim.Z̃[(nx̃+nx̂*He+na+na*He+1):(nx̃+nx̂*He+na+na*He+nk̄*He)]
repeat!(K̄, x0s, no*He)
Ā = @views estim.Z̃[(nx̃+nx̂*He+na+na*He+nk̄*He+1):(nx̃+nx̂*He+na+na*He+nk̄*He+nā*He)]
repeat!(Ā, a0s, no*He)
return nothing
end
function reset_warmstart!(estim::MovingHorizonEstimator, ::SingleShooting)
Expand Down
6 changes: 4 additions & 2 deletions test/2_test_state_estim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1524,8 +1524,10 @@ end
@test mhe2.Z̃[2:2] ≈ mhe2.Z̃[4:4] ≈ mhe2.Z̃[6:6] ≈ xs_0 # xd in X̂0
@test mhe2.Z̃[3:3] ≈ mhe2.Z̃[5:5] ≈ mhe2.Z̃[7:7] ≈ [0.0] # xs in X̂0
@test mhe2.Z̃[8:8] ≈ mhe2.Z̃[9:9] ≈ mhe2.Z̃[10:10] ≈ as_0 # â0 in Â0
@test mhe2.Z̃[11:11] ≈ mhe2.Z̃[12:12] ≈ xs_0 # xd in K̄
@test mhe2.Z̃[13:13] ≈ mhe2.Z̃[14:14] ≈ as_0 # a in Ā
@test mhe2.Z̃[11:11] ≈ mhe2.Z̃[12:12] ≈ xs_0 # xd in 1st k̄
@test mhe2.Z̃[13:13] ≈ mhe2.Z̃[14:14] ≈ xs_0 # xd in 2nd k̄
@test mhe2.Z̃[15:15] ≈ mhe2.Z̃[16:16] ≈ as_0 # a in 1st ā
@test mhe2.Z̃[17:17] ≈ mhe2.Z̃[18:18] ≈ as_0 # a in 2nd ā
end

@testitem "MHE estim. with unfilled window" setup=[SetupMPCtests] begin
Expand Down
Loading