Skip to content

Commit d607150

Browse files
committed
debug: do not convert P̂_0 if isnothing
1 parent 63b4387 commit d607150

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/controller/construct.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ function ControllerWeights(
9191
model::SimModel{NT}, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt=Inf, Ewt=0
9292
) where {NT<:Real}
9393
validate_weights(model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt, Ewt)
94-
return ControllerWeights{NT}(NT.(M_Hp), NT.(N_Hc), NT.(L_Hp), Cwt, Ewt)
94+
M_Hp, N_Hc, L_Hp = NT.(M_Hp), NT.(N_Hc), NT.(L_Hp)
95+
return ControllerWeights{NT}(M_Hp, N_Hc, L_Hp, Cwt, Ewt)
9596
end
9697

9798
"Validate predictive controller weight and horizon specified values."

src/estimator/construct.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct KalmanCovariances{
5353
invQ̂_He::Hermitian{NT, Q̂C}
5454
invR̂_He::Hermitian{NT, R̂C}
5555
function KalmanCovariances{NT}(
56-
model, i_ym, nint_u, nint_ym, ::Q̂C, R̂::R̂C, P̂_0=nothing, He=1
56+
::Q̂C, R̂::R̂C, P̂_0, He
5757
) where {NT<:Real, Q̂C<:AbstractMatrix{NT}, R̂C<:AbstractMatrix{NT}}
5858
if isnothing(P̂_0)
5959
P̂_0 = zeros(NT, 0, 0)
@@ -104,7 +104,9 @@ function KalmanCovariances(
104104
model::SimModel{NT}, i_ym, nint_u, nint_ym, Q̂, R̂, P̂_0=nothing, He=1
105105
) where {NT<:Real}
106106
validate_kfcov(model, i_ym, nint_u, nint_ym, Q̂, R̂, P̂_0)
107-
return KalmanCovariances{NT}(model, i_ym, nint_u, nint_ym, NT.(Q̂), NT.(R̂), NT.(P̂_0), He)
107+
Q̂, R̂ = NT.(Q̂), NT.(R̂)
108+
!isnothing(P̂_0) && (P̂_0 .= NT.(P̂_0))
109+
return KalmanCovariances{NT}(Q̂, R̂, P̂_0, He)
108110
end
109111

110112
"""

test/3_test_predictive_control.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,6 @@ end
822822
preparestate!(nmpc11, y, [0])
823823
moveinput!(nmpc11, [10], [0])
824824
ΔU_diff = diff(getinfo(nmpc11)[:U])
825-
println(ΔU_diff)
826825
@test ΔU_diff[[2, 4, 5, 7, 8, 9]] zeros(6) atol=1e-9
827826

828827
@test_nowarn ModelPredictiveControl.info2debugstr(info)

0 commit comments

Comments
 (0)