Skip to content

Commit 097f875

Browse files
committed
debug: support Hermitian weights in PredictiveController
Added a generic dispatch to support `M_Hp`, `N_Hc` and `L_Hp` of any types, including `Hermitian`
1 parent 61de78d commit 097f875

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/controller/construct.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ struct ControllerWeights{
8888
end
8989

9090
"Outer constructor to convert weight matrix number type to `NT` if necessary."
91-
function ControllerWeights{NT}(
92-
model, Hp, Hc, M_Hp::MW, N_Hc::NW, L_Hp::LW, Cwt=Inf, Ewt=0
93-
) where {NT<:Real, MW<:AbstractMatrix, NW<:AbstractMatrix, LW<:AbstractMatrix}
91+
function ControllerWeights(
92+
model::SimModel{NT}, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt=Inf, Ewt=0
93+
) where {NT<:Real}
9494
return ControllerWeights{NT}(model, Hp, Hc, NT.(M_Hp), NT.(N_Hc), NT.(L_Hp), Cwt, Ewt)
9595
end
9696

src/controller/explicitmpc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function ExplicitMPC(
169169
end
170170
nb = move_blocking(Hp, Hc)
171171
Hc = get_Hc(nb)
172-
weights = ControllerWeights{NT}(estim.model, Hp, Hc, M_Hp, N_Hc, L_Hp)
172+
weights = ControllerWeights(estim.model, Hp, Hc, M_Hp, N_Hc, L_Hp)
173173
return ExplicitMPC{NT}(estim, Hp, Hc, nb, weights)
174174
end
175175

src/controller/linmpc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ function LinMPC(
270270
end
271271
nb = move_blocking(Hp, Hc)
272272
Hc = get_Hc(nb)
273-
weights = ControllerWeights{NT}(estim.model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt)
273+
weights = ControllerWeights(estim.model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt)
274274
return LinMPC{NT}(estim, Hp, Hc, nb, weights, transcription, optim)
275275
end
276276

src/controller/nonlinmpc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ function NonLinMPC(
372372
Hc = get_Hc(nb)
373373
validate_JE(NT, JE)
374374
gc! = get_mutating_gc(NT, gc)
375-
weights = ControllerWeights{NT}(estim.model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt, Ewt)
375+
weights = ControllerWeights(estim.model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt, Ewt)
376376
return NonLinMPC{NT}(
377377
estim, Hp, Hc, nb, weights, JE, gc!, nc, p, transcription, optim, gradient, jacobian
378378
)

0 commit comments

Comments
 (0)