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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ModelPredictiveControl"
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
version = "2.16.5"
version = "2.16.6"
authors = ["Francis Gagnon"]

[deps]
Expand Down
8 changes: 7 additions & 1 deletion src/controller/construct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ function ControllerWeights(
model::SimModel{NT}, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt=Inf, Ewt=0
) where {NT<:Real}
validate_weights(model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt, Ewt)
M_Hp, N_Hc, L_Hp = NT.(M_Hp), NT.(N_Hc), NT.(L_Hp)
M_Hp = eltype(M_Hp) == NT ? M_Hp : NT.(M_Hp)
N_Hc = eltype(N_Hc) == NT ? N_Hc : NT.(N_Hc)
L_Hp = eltype(L_Hp) == NT ? L_Hp : NT.(L_Hp)
# Hermitian wrappers are added in the inner constructor, remove it to avoid duplicates:
M_Hp = M_Hp isa Hermitian ? parent(M_Hp) : M_Hp
N_Hc = N_Hc isa Hermitian ? parent(N_Hc) : N_Hc
L_Hp = L_Hp isa Hermitian ? parent(L_Hp) : L_Hp
return ControllerWeights{NT}(M_Hp, N_Hc, L_Hp, Cwt, Ewt)
end

Expand Down
11 changes: 9 additions & 2 deletions src/estimator/construct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,15 @@ function KalmanCovariances(
model::SimModel{NT}, i_ym, nint_u, nint_ym, Q̂, R̂, P̂_0=nothing, He=1
) where {NT<:Real}
validate_kfcov(model, i_ym, nint_u, nint_ym, Q̂, R̂, P̂_0)
Q̂, R̂ = NT.(Q̂), NT.(R̂)
!isnothing(P̂_0) && (P̂_0 = NT.(P̂_0))
Q̂ = eltype(Q̂) == NT ? Q̂ : NT.(Q̂)
R̂ = eltype(R̂) == NT ? R̂ : NT.(R̂)
# Hermitian wrappers are added in the inner constructor, remove it to avoid duplicates:
Q̂ = Q̂ isa Hermitian ? parent(Q̂) : Q̂
R̂ = R̂ isa Hermitian ? parent(R̂) : R̂
if !isnothing(P̂_0)
P̂_0 = eltype(P̂_0) == NT ? P̂_0 : NT.(P̂_0)
P̂_0 = P̂_0 isa Hermitian ? parent(P̂_0) : P̂_0
end
return KalmanCovariances{NT}(Q̂, R̂, P̂_0, He)
end

Expand Down