Skip to content

Commit df3a52a

Browse files
committed
Merge branch 'debug_mhe_tc' into orthocolloc_mhe
2 parents 8d5cf9d + 2d34426 commit df3a52a

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎src/estimator/mhe/transcription.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ function con_nonlinprogeq_mhe!(
15591559
x̂dnext .+= ŵd
15601560
ŝdnext .= @. x̂dnext - x̂dnext_Z̃
15611561
end
1562-
Nk < He && (geq[nx̂*Nk+1:end] .= 0)
1562+
Nk < He && (geq[nx*Nk+1:end] .= 0)
15631563
return geq
15641564
end
15651565

@@ -1638,7 +1638,7 @@ function con_nonlinprogeq_mhe!(
16381638
ŝdnext .= @. x̂d_Z̃ - x̂dnext_Z̃ + 0.5*Ts*(k̇1 + k̇2)
16391639
ŝdnext .+= ŵd
16401640
end
1641-
Nk < He && (geq[nx̂*Nk+1:end] .= 0)
1641+
Nk < He && (geq[nx*Nk+1:end] .= 0)
16421642
return geq
16431643
end
16441644

‎test/2_test_state_estim.jl‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ end
11451145
using .SetupMPCtests, ControlSystemsBase, LinearAlgebra, ForwardDiff
11461146
using JuMP, Ipopt, DifferentiationInterface, SparseMatrixColorings, SparseConnectivityTracer
11471147
import ForwardDiff
1148+
11481149
linmodel = LinModel(sys,Ts,i_u=[1,2], i_d=[3])
11491150
linmodel = setop!(linmodel, uop=[10,50], yop=[50,30], dop=[5])
11501151
f(x,u,d,model) = model.A*x + model.Bu*u + model.Bd*d
@@ -1237,7 +1238,13 @@ end
12371238
end
12381239
preparestate!(mhe3, [50, 30], [5])
12391240
@test mhe3([5]) ≈ [50, 30] atol=1e-3
1240-
1241+
initstate!(mhe3, [10, 50], [50, 30], [5])
1242+
setstate!(mhe3, [0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
1243+
preparestate!(mhe3, [50, 30], [5])
1244+
updatestate!(mhe3, [10, 50], [50, 30], [5])
1245+
info = getinfo(mhe3) # test getinfo when Nk<He
1246+
@test info[:Ŵ] ≈ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
1247+
@test info[:V̂] ≈ [0.0, 0.0]
12411248

12421249
Q̂ = diagm([1/4, 1/4, 1/4, 1/4].^2)
12431250
R̂ = diagm([1, 1].^2)
@@ -1267,6 +1274,7 @@ end
12671274
end
12681275
preparestate!(mhe6, [13])
12691276
@test mhe6() ≈ [13] atol=1e-3
1277+
12701278
transcription = TrapezoidalCollocation(1)
12711279
mhe7 = MovingHorizonEstimator(
12721280
nonlinmodel_c; He=3, direct=true, transcription
@@ -1277,6 +1285,12 @@ end
12771285
end
12781286
preparestate!(mhe7, [13])
12791287
@test mhe7() ≈ [13] atol=1e-3
1288+
initstate!(mhe7, [0.0], [0.0])
1289+
setstate!(mhe7, [0.0, 0.0])
1290+
preparestate!(mhe7, [0.0])
1291+
info = getinfo(mhe7) # test getinfo when Nk<He
1292+
@test info[:Ŵ] ≈ [0.0, 0.0]
1293+
@test info[:V̂] ≈ [0.0]
12801294

12811295
# coverage of the branch with error termination status (with an infeasible problem):
12821296
mhe_infeas = MovingHorizonEstimator(nonlinmodel, He=1, Cwt=Inf)

0 commit comments

Comments
 (0)