Skip to content

Commit e15b12c

Browse files
committed
changed: renamed xi to kand Xi to K
1 parent eedcade commit e15b12c

File tree

16 files changed

+154
-154
lines changed

16 files changed

+154
-154
lines changed

src/controller/execute.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,22 @@ julia> round.(getinfo(mpc)[:Ŷ], digits=3)
114114
"""
115115
function getinfo(mpc::PredictiveController{NT}) where NT<:Real
116116
model, buffer, transcription = mpc.estim.model, mpc.buffer, mpc.transcription
117-
nΔŨ, nXi = mpc.Hc*model.nu + mpc.nϵ, mpc.Hp*model.nxi
117+
nΔŨ, nK = mpc.Hc*model.nu + mpc.nϵ, mpc.Hp*model.nk
118118
nŶe, nUe = (mpc.Hp+1)*model.ny, (mpc.Hp+1)*model.nu
119119
nX̂0, nÛ0 = mpc.estim.nx̂*mpc.Hp, model.nu*mpc.Hp
120120
= mpc.
121121
info = Dict{Symbol, Any}()
122122
ΔŨ = Vector{NT}(undef, nΔŨ)
123123
x̂0end = similar(mpc.estim.x̂0)
124-
X0i = Vector{NT}(undef, nXi)
124+
K0 = Vector{NT}(undef, nK)
125125
Ue, Ŷe = Vector{NT}(undef, nUe), Vector{NT}(undef, nŶe)
126126
U0, Ŷ0 = similar(mpc.Uop), similar(mpc.Yop)
127127
Û0, X̂0 = Vector{NT}(undef, nÛ0), Vector{NT}(undef, nX̂0)
128128
U, Ŷ = buffer.U, buffer.
129129
= buffer.
130130
U0 = getU0!(U0, mpc, Z̃)
131131
ΔŨ = getΔŨ!(ΔŨ, mpc, transcription, Z̃)
132-
Ŷ0, x̂0end = predict!(Ŷ0, x̂0end, X̂0, Û0, X0i, mpc, model, transcription, U0, Z̃)
132+
Ŷ0, x̂0end = predict!(Ŷ0, x̂0end, X̂0, Û0, K0, mpc, model, transcription, U0, Z̃)
133133
Ue, Ŷe = extended_vectors!(Ue, Ŷe, mpc, U0, Ŷ0)
134134
U .= U0 .+ mpc.Uop
135135
Ŷ .= Ŷ0 .+ mpc.Yop

src/controller/nonlinmpc.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -578,17 +578,17 @@ Inspired from: [User-defined operators with vector outputs](@extref JuMP User-de
578578
function get_optim_functions(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JNT<:Real
579579
# ----- common cache for Jfunc, gfuncs, geqfuncs called with floats -------------------
580580
model = mpc.estim.model
581-
nu, ny, nx̂, nϵ, nxi = model.nu, model.ny, mpc.estim.nx̂, mpc.nϵ, model.nxi
581+
nu, ny, nx̂, nϵ, nk = model.nu, model.ny, mpc.estim.nx̂, mpc.nϵ, model.nk
582582
Hp, Hc = mpc.Hp, mpc.Hc
583583
ng, nc, neq = length(mpc.con.i_g), mpc.con.nc, mpc.con.neq
584-
nZ̃, nU, nŶ, nX̂, nXi = length(mpc.Z̃), Hp*nu, Hp*ny, Hp*nx̂, Hp*nxi
584+
nZ̃, nU, nŶ, nX̂, nK = length(mpc.Z̃), Hp*nu, Hp*ny, Hp*nx̂, Hp*nk
585585
nΔŨ, nUe, nŶe = nu*Hc + nϵ, nU + nu, nŶ + ny
586586
strict = Val(true)
587587
myNaN = convert(JNT, NaN) # NaN to force update_simulations! at first call:
588588
::Vector{JNT} = fill(myNaN, nZ̃)
589589
ΔŨ::Vector{JNT} = zeros(JNT, nΔŨ)
590590
x̂0end::Vector{JNT} = zeros(JNT, nx̂)
591-
X0i::Vector{JNT} = zeros(JNT, nXi)
591+
K0::Vector{JNT} = zeros(JNT, nK)
592592
Ue::Vector{JNT}, Ŷe::Vector{JNT} = zeros(JNT, nUe), zeros(JNT, nŶe)
593593
U0::Vector{JNT}, Ŷ0::Vector{JNT} = zeros(JNT, nU), zeros(JNT, nŶ)
594594
Û0::Vector{JNT}, X̂0::Vector{JNT} = zeros(JNT, nU), zeros(JNT, nX̂)
@@ -598,18 +598,18 @@ function get_optim_functions(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JNT
598598
function Jfunc(Z̃arg::Vararg{T, N}) where {N, T<:Real}
599599
if isdifferent(Z̃arg, Z̃)
600600
Z̃ .= Z̃arg
601-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g, geq, mpc, Z̃)
601+
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃)
602602
end
603603
return obj_nonlinprog!(Ŷ0, U0, mpc, model, Ue, Ŷe, ΔŨ)::T
604604
end
605-
function Jfunc!(Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g, geq)
606-
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g, geq, mpc, Z̃)
605+
function Jfunc!(Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq)
606+
update_predictions!(ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃)
607607
return obj_nonlinprog!(Ŷ0, U0, mpc, model, Ue, Ŷe, ΔŨ)
608608
end
609609
Z̃_∇J = fill(myNaN, nZ̃)
610610
∇J_context = (
611611
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
612-
Cache(Û0), Cache(X0i), Cache(X̂0),
612+
Cache(Û0), Cache(K0), Cache(X̂0),
613613
Cache(gc), Cache(g), Cache(geq),
614614
)
615615
∇J_prep = prepare_gradient(Jfunc!, mpc.gradient, Z̃_∇J, ∇J_context...; strict)
@@ -634,22 +634,22 @@ function get_optim_functions(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JNT
634634
if isdifferent(Z̃arg, Z̃)
635635
Z̃ .= Z̃arg
636636
update_predictions!(
637-
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g, geq, mpc, Z̃
637+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃
638638
)
639639
end
640640
return g[i]::T
641641
end
642642
gfuncs[i] = gfunc_i
643643
end
644-
function gfunc!(g, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, geq)
644+
function gfunc!(g, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, geq)
645645
return update_predictions!(
646-
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g, geq, mpc, Z̃
646+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃
647647
)
648648
end
649649
Z̃_∇g = fill(myNaN, nZ̃)
650650
∇g_context = (
651651
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
652-
Cache(Û0), Cache(X0i), Cache(X̂0),
652+
Cache(Û0), Cache(K0), Cache(X̂0),
653653
Cache(gc), Cache(geq),
654654
)
655655
# temporarily enable all the inequality constraints for sparsity detection:
@@ -685,22 +685,22 @@ function get_optim_functions(mpc::NonLinMPC, ::JuMP.GenericModel{JNT}) where JNT
685685
if isdifferent(Z̃arg, Z̃)
686686
Z̃ .= Z̃arg
687687
update_predictions!(
688-
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g, geq, mpc, Z̃
688+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃
689689
)
690690
end
691691
return geq[i]::T
692692
end
693693
geqfuncs[i] = geqfunc_i
694694
end
695-
function geqfunc!(geq, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g)
695+
function geqfunc!(geq, Z̃, ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g)
696696
return update_predictions!(
697-
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g, geq, mpc, Z̃
697+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc, Z̃
698698
)
699699
end
700700
Z̃_∇geq = fill(myNaN, nZ̃)
701701
∇geq_context = (
702702
Cache(ΔŨ), Cache(x̂0end), Cache(Ue), Cache(Ŷe), Cache(U0), Cache(Ŷ0),
703-
Cache(Û0), Cache(X0i), Cache(X̂0),
703+
Cache(Û0), Cache(K0), Cache(X̂0),
704704
Cache(gc), Cache(g)
705705
)
706706
∇geq_prep = prepare_jacobian(geqfunc!, geq, mpc.jacobian, Z̃_∇geq, ∇geq_context...; strict)
@@ -726,7 +726,7 @@ end
726726

727727
"""
728728
update_predictions!(
729-
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g, geq,
729+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq,
730730
mpc::PredictiveController, Z̃
731731
) -> nothing
732732
@@ -735,17 +735,17 @@ Update in-place all vectors for the predictions of `mpc` controller at decision
735735
The method mutates all the arguments before the `mpc` argument.
736736
"""
737737
function update_predictions!(
738-
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, X0i, X̂0, gc, g, geq, mpc::PredictiveController, Z̃
738+
ΔŨ, x̂0end, Ue, Ŷe, U0, Ŷ0, Û0, K0, X̂0, gc, g, geq, mpc::PredictiveController, Z̃
739739
)
740740
model, transcription = mpc.estim.model, mpc.transcription
741741
U0 = getU0!(U0, mpc, Z̃)
742742
ΔŨ = getΔŨ!(ΔŨ, mpc, transcription, Z̃)
743-
Ŷ0, x̂0end = predict!(Ŷ0, x̂0end, X̂0, Û0, X0i, mpc, model, transcription, U0, Z̃)
743+
Ŷ0, x̂0end = predict!(Ŷ0, x̂0end, X̂0, Û0, K0, mpc, model, transcription, U0, Z̃)
744744
Ue, Ŷe = extended_vectors!(Ue, Ŷe, mpc, U0, Ŷ0)
745745
ϵ = getϵ(mpc, Z̃)
746746
gc = con_custom!(gc, mpc, Ue, Ŷe, ϵ)
747747
g = con_nonlinprog!(g, mpc, model, transcription, x̂0end, Ŷ0, gc, ϵ)
748-
geq = con_nonlinprogeq!(geq, X̂0, Û0, X0i, mpc, model, transcription, U0, Z̃)
748+
geq = con_nonlinprogeq!(geq, X̂0, Û0, K0, mpc, model, transcription, U0, Z̃)
749749
return nothing
750750
end
751751

src/controller/transcription.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,31 +1052,31 @@ end
10521052

10531053
@doc raw"""
10541054
predict!(
1055-
Ŷ0, x̂0end, X̂0, Û0, X0i,
1055+
Ŷ0, x̂0end, X̂0, Û0, K0,
10561056
mpc::PredictiveController, model::NonLinModel, transcription::SingleShooting,
10571057
U0, _
10581058
) -> Ŷ0, x̂0end
10591059
10601060
Compute vectors if `model` is a [`NonLinModel`](@ref) and for [`SingleShooting`](@ref).
10611061
1062-
The method mutates `Ŷ0`, `x̂0end`, `X̂0`, `Û0` and `X0i` arguments.
1062+
The method mutates `Ŷ0`, `x̂0end`, `X̂0`, `Û0` and `K0` arguments.
10631063
"""
10641064
function predict!(
1065-
Ŷ0, x̂0end, X̂0, Û0, X0i,
1065+
Ŷ0, x̂0end, X̂0, Û0, K0,
10661066
mpc::PredictiveController, model::NonLinModel, ::SingleShooting,
10671067
U0, _
10681068
)
1069-
nu, nx̂, ny, nd, nxi = model.nu, mpc.estim.nx̂, model.ny, model.nd, model.nxi
1069+
nu, nx̂, ny, nd, nk = model.nu, mpc.estim.nx̂, model.ny, model.nd, model.nk
10701070
Hp, Hc = mpc.Hp, mpc.Hc
10711071
D̂0 = mpc.D̂0
10721072
x̂0 = @views mpc.estim.x̂0[1:nx̂]
10731073
d0 = @views mpc.d0[1:nd]
10741074
for j=1:Hp
1075-
u0 = @views U0[(1 + nu*(j-1)):(nu*j)]
1076-
û0 = @views Û0[(1 + nu*(j-1)):(nu*j)]
1077-
x0i = @views X0i[(1 + nxi*(j-1)):(nxi*j)]
1078-
x̂0next = @views X̂0[(1 + nx̂*(j-1)):(nx̂*j)]
1079-
f̂!(x̂0next, û0, x0i, mpc.estim, model, x̂0, u0, d0)
1075+
u0 = @views U0[(1 + nu*(j-1)):(nu*j)]
1076+
û0 = @views Û0[(1 + nu*(j-1)):(nu*j)]
1077+
k0 = @views K0[(1 + nk*(j-1)):(nk*j)]
1078+
x̂0next = @views X̂0[(1 + nx̂*(j-1)):(nx̂*j)]
1079+
f̂!(x̂0next, û0, k0, mpc.estim, model, x̂0, u0, d0)
10801080
x̂0next .+= mpc.estim.f̂op .- mpc.estim.x̂op
10811081
x̂0 = @views X̂0[(1 + nx̂*(j-1)):(nx̂*j)]
10821082
d0 = @views D̂0[(1 + nd*(j-1)):(nd*j)]
@@ -1206,19 +1206,19 @@ end
12061206

12071207
"""
12081208
con_nonlinprogeq!(
1209-
geq, X̂0, Û0, X0i
1209+
geq, X̂0, Û0, K0
12101210
mpc::PredictiveController, model::NonLinModel, ::MultipleShooting, U0, Z̃
12111211
)
12121212
12131213
Nonlinear equality constrains for [`NonLinModel`](@ref) and [`MultipleShooting`](@ref).
12141214
1215-
The method mutates the `geq`, `X̂0`, `Û0` and `X0i` vectors in argument.
1215+
The method mutates the `geq`, `X̂0`, `Û0` and `K0` vectors in argument.
12161216
"""
12171217
function con_nonlinprogeq!(
1218-
geq, X̂0, Û0, X0i,
1218+
geq, X̂0, Û0, K0,
12191219
mpc::PredictiveController, model::NonLinModel, ::MultipleShooting, U0, Z̃
12201220
)
1221-
nu, nx̂, ny, nd, nxi = model.nu, mpc.estim.nx̂, model.ny, model.nd, model.nxi
1221+
nu, nx̂, ny, nd, nk = model.nu, mpc.estim.nx̂, model.ny, model.nd, model.nk
12221222
Hp, Hc = mpc.Hp, mpc.Hc
12231223
nΔU, nX̂ = nu*Hc, nx̂*Hp
12241224
D̂0 = mpc.D̂0
@@ -1230,8 +1230,8 @@ function con_nonlinprogeq!(
12301230
u0 = @views U0[(1 + nu*(j-1)):(nu*j)]
12311231
û0 = @views Û0[(1 + nu*(j-1)):(nu*j)]
12321232
x̂0next = @views X̂0[(1 + nx̂*(j-1)):(nx̂*j)]
1233-
x0i = @views X0i[(1 + nxi*(j-1)):(nxi*j)]
1234-
f̂!(x̂0next, û0, x0i, mpc.estim, model, x̂0, u0, d0)
1233+
k0 = @views K0[(1 + nk*(j-1)):(nk*j)]
1234+
f̂!(x̂0next, û0, k0, mpc.estim, model, x̂0, u0, d0)
12351235
x̂0next .+= mpc.estim.f̂op .- mpc.estim.x̂op
12361236
x̂0next_Z̃ = @views X̂0_Z̃[(1 + nx̂*(j-1)):(nx̂*j)]
12371237
ŝnext = @views geq[(1 + nx̂*(j-1)):(nx̂*j)]

src/estimator/construct.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
struct StateEstimatorBuffer{NT<:Real}
22
u ::Vector{NT}
33
::Vector{NT}
4-
xi::Vector{NT}
4+
k::Vector{NT}
55
::Vector{NT}
66
::Matrix{NT}
77
::Matrix{NT}
@@ -14,18 +14,18 @@ struct StateEstimatorBuffer{NT<:Real}
1414
end
1515

1616
@doc raw"""
17-
StateEstimatorBuffer{NT}(nu::Int, nx̂::Int, nym::Int, ny::Int, nd::Int, nxi::Int=0)
17+
StateEstimatorBuffer{NT}(nu::Int, nx̂::Int, nym::Int, ny::Int, nd::Int, nk::Int=0)
1818
1919
Create a buffer for `StateEstimator` objects for estimated states and measured outputs.
2020
2121
The buffer is used to store intermediate results during estimation without allocating.
2222
"""
2323
function StateEstimatorBuffer{NT}(
24-
nu::Int, nx̂::Int, nym::Int, ny::Int, nd::Int, nxi::Int=0
24+
nu::Int, nx̂::Int, nym::Int, ny::Int, nd::Int, nk::Int=0
2525
) where NT <: Real
2626
u = Vector{NT}(undef, nu)
2727
= Vector{NT}(undef, nu)
28-
xi = Vector{NT}(undef, nxi)
28+
k = Vector{NT}(undef, nk)
2929
= Vector{NT}(undef, nx̂)
3030
= Matrix{NT}(undef, nx̂, nx̂)
3131
= Matrix{NT}(undef, nx̂, nx̂)
@@ -35,7 +35,7 @@ function StateEstimatorBuffer{NT}(
3535
= Vector{NT}(undef, ny)
3636
d = Vector{NT}(undef, nd)
3737
empty = Vector{NT}(undef, 0)
38-
return StateEstimatorBuffer{NT}(u, û, xi, x̂, P̂, Q̂, R̂, K̂, ym, ŷ, d, empty)
38+
return StateEstimatorBuffer{NT}(u, û, k, x̂, P̂, Q̂, R̂, K̂, ym, ŷ, d, empty)
3939
end
4040

4141
@doc raw"""

src/estimator/execute.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function remove_op!(estim::StateEstimator, ym, d, u=nothing)
1818
end
1919

2020
@doc raw"""
21-
f̂!(x̂0next, û0, x0i, estim::StateEstimator, model::SimModel, x̂0, u0, d0) -> nothing
21+
f̂!(x̂0next, û0, k0, estim::StateEstimator, model::SimModel, x̂0, u0, d0) -> nothing
2222
2323
Mutating state function ``\mathbf{f̂}`` of the augmented model.
2424
@@ -31,13 +31,13 @@ function returns the next state of the augmented model, defined as:
3131
\end{aligned}
3232
```
3333
where ``\mathbf{x̂_0}(k+1)`` is stored in `x̂0next` argument. The method mutates `x̂0next`,
34-
`û0` and `x0i` in place. The argument `û0` is the input vector of the augmented model,
35-
computed by ``\mathbf{û_0 = u_0 + ŷ_{s_u}}``. The argument `x0i` is used to store the
34+
`û0` and `k0` in place. The argument `û0` is the input vector of the augmented model,
35+
computed by ``\mathbf{û_0 = u_0 + ŷ_{s_u}}``. The argument `k0` is used to store the
3636
intermediate stage values of `model.solver` (when applicable). The model parameter vector
3737
`model.p` is not included in the function signature for conciseness.
3838
"""
39-
function f̂!(x̂0next, û0, x0i, estim::StateEstimator, model::SimModel, x̂0, u0, d0)
40-
return f̂!(x̂0next, û0, x0i, model, estim.As, estim.Cs_u, x̂0, u0, d0)
39+
function f̂!(x̂0next, û0, k0, estim::StateEstimator, model::SimModel, x̂0, u0, d0)
40+
return f̂!(x̂0next, û0, k0, model, estim.As, estim.Cs_u, x̂0, u0, d0)
4141
end
4242

4343
"""
@@ -53,17 +53,17 @@ function f̂!(x̂0next, _ , _ , estim::StateEstimator, ::LinModel, x̂0, u0, d0)
5353
end
5454

5555
"""
56-
f̂!(x̂0next, û0, x0i, model::SimModel, As, Cs_u, x̂0, u0, d0)
56+
f̂!(x̂0next, û0, k0, model::SimModel, As, Cs_u, x̂0, u0, d0)
5757
5858
Same than [`f̂!`](@ref) for [`SimModel`](@ref) but without the `estim` argument.
5959
"""
60-
function f̂!(x̂0next, û0, x0i, model::SimModel, As, Cs_u, x̂0, u0, d0)
60+
function f̂!(x̂0next, û0, k0, model::SimModel, As, Cs_u, x̂0, u0, d0)
6161
# `@views` macro avoid copies with matrix slice operator e.g. [a:b]
6262
@views x̂d, x̂s = x̂0[1:model.nx], x̂0[model.nx+1:end]
6363
@views x̂d_next, x̂s_next = x̂0next[1:model.nx], x̂0next[model.nx+1:end]
6464
mul!(û0, Cs_u, x̂s) # ŷs_u = Cs_u * x̂s
6565
û0 .+= u0
66-
f!(x̂d_next, x0i, model, x̂d, û0, d0, model.p)
66+
f!(x̂d_next, k0, model, x̂d, û0, d0, model.p)
6767
mul!(x̂s_next, As, x̂s)
6868
return nothing
6969
end

src/estimator/internal_model.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct InternalModel{NT<:Real, SM<:SimModel} <: StateEstimator{NT}
3232
function InternalModel{NT}(
3333
model::SM, i_ym, Asm, Bsm, Csm, Dsm
3434
) where {NT<:Real, SM<:SimModel}
35-
nu, ny, nd, nxi = model.nu, model.ny, model.nd, model.nxi
35+
nu, ny, nd, nk = model.nu, model.ny, model.nd, model.nk
3636
nym, nyu = validate_ym(model, i_ym)
3737
validate_internalmodel(model, nym, Csm, Dsm)
3838
As, Bs, Cs, Ds = stoch_ym2y(model, i_ym, Asm, Bsm, Csm, Dsm)
@@ -48,7 +48,7 @@ struct InternalModel{NT<:Real, SM<:SimModel} <: StateEstimator{NT}
4848
ŷs = zeros(NT, ny)
4949
direct = true # InternalModel always uses direct transmission from ym
5050
corrected = [false]
51-
buffer = StateEstimatorBuffer{NT}(nu, nx̂, nym, ny, nd, nxi)
51+
buffer = StateEstimatorBuffer{NT}(nu, nx̂, nym, ny, nd, nk)
5252
return new{NT, SM}(
5353
model,
5454
lastu0, x̂op, f̂op, x̂0, x̂d, x̂s, ŷs, x̂snext,
@@ -284,8 +284,8 @@ function update_estimate!(estim::InternalModel, _ , d0, u0)
284284
model = estim.model
285285
x̂d, x̂s, ŷs = estim.x̂d, estim.x̂s, estim.ŷs
286286
# -------------- deterministic model ---------------------
287-
x̂dnext, x0i = estim.buffer.x̂, estim.buffer.xi
288-
f!(x̂dnext, x0i, model, x̂d, u0, d0, model.p)
287+
x̂dnext, k0 = estim.buffer.x̂, estim.buffer.k
288+
f!(x̂dnext, k0, model, x̂d, u0, d0, model.p)
289289
x̂d .= x̂dnext # this also updates estim.x̂0 (they are the same object)
290290
# --------------- stochastic model -----------------------
291291
x̂snext = estim.x̂snext

0 commit comments

Comments
 (0)