Skip to content

Commit 4ae6b07

Browse files
committed
fixed: LinMPC is now type-stable
1 parent 9f663d1 commit 4ae6b07

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/controller/construct.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct ControllerWeights{NT<:Real}
2727
end
2828

2929
"Include all the data for the constraints of [`PredictiveController`](@ref)"
30-
struct ControllerConstraint{NT<:Real, GCfunc<:Function}
30+
struct ControllerConstraint{NT<:Real, GCfunc<:Union{Nothing, Function}}
3131
ẽx̂ ::Matrix{NT}
3232
fx̂ ::Vector{NT}
3333
gx̂ ::Matrix{NT}
@@ -668,18 +668,17 @@ end
668668
"""
669669
init_defaultcon_mpc(
670670
estim, C, S, E, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂,
671-
gc!=(_,_,_,_,_,_)->nothing, nc=0
671+
gc!=nothing, nc=0
672672
) -> con, S̃, Ẽ
673673
674674
Init `ControllerConstraint` struct with default parameters based on estimator `estim`.
675675
676676
Also return `S̃` and `Ẽ` matrices for the the augmented decision vector `ΔŨ`.
677677
"""
678678
function init_defaultcon_mpc(
679-
estim::StateEstimator{NT},
680-
Hp, Hc, C, S, E, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂,
681-
gc!::GCfunc=(_,_,_,_,_,_)->nothing, nc=0
682-
) where {NT<:Real, GCfunc<:Function}
679+
estim::StateEstimator{NT}, Hp, Hc, C, S, E, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂,
680+
gc!::GCfunc=nothing, nc=0
681+
) where {NT<:Real, GCfunc<:Union{Nothing, Function}}
683682
model = estim.model
684683
nu, ny, nx̂ = model.nu, model.ny, estim.nx̂
685684
= isinf(C) ? 0 : 1

src/controller/linmpc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct LinMPC{
99
# note: `NT` and the number type `JNT` in `JuMP.GenericModel{JNT}` can be
1010
# different since solvers that support non-Float64 are scarce.
1111
optim::JM
12-
con::ControllerConstraint{NT}
12+
con::ControllerConstraint{NT, Nothing}
1313
ΔŨ::Vector{NT}
1414
::Vector{NT}
1515
Hp::Int

0 commit comments

Comments
 (0)