Skip to content

Commit e34f4ed

Browse files
committed
changed: validate weights in outer constructor
1 parent 6da55a5 commit e34f4ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/controller/construct.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@ struct ControllerWeights{
5353
iszero_E::Bool
5454
isinf_C ::Bool
5555
function ControllerWeights{NT}(
56-
model, Hp, Hc, M_Hp::MW, N_Hc::NW, L_Hp::LW, Cwt=Inf, Ewt=0
56+
M_Hp::MW, N_Hc::NW, L_Hp::LW, Cwt, Ewt
5757
) where {
5858
NT<:Real,
5959
MW<:AbstractMatrix{NT},
6060
NW<:AbstractMatrix{NT},
6161
LW<:AbstractMatrix{NT}
6262
}
63-
validate_weights(model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt, Ewt)
6463
nΔU = size(N_Hc, 1)
6564
C = Cwt
6665
isinf_C = isinf(C)
@@ -87,11 +86,12 @@ struct ControllerWeights{
8786
end
8887
end
8988

90-
"Outer constructor to convert weight matrix number type to `NT` if necessary."
89+
"Outer constructor to validate and convert weight matrices if necessary."
9190
function ControllerWeights(
9291
model::SimModel{NT}, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt=Inf, Ewt=0
9392
) where {NT<:Real}
94-
return ControllerWeights{NT}(model, Hp, Hc, NT.(M_Hp), NT.(N_Hc), NT.(L_Hp), Cwt, Ewt)
93+
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)
9595
end
9696

9797
"Include all the data for the constraints of [`PredictiveController`](@ref)"

0 commit comments

Comments
 (0)