Skip to content

Commit ff3359e

Browse files
committed
removed isa in InternalModel constructor
1 parent 67cf703 commit ff3359e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/estimator/internal_model.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ struct InternalModel{M<:SimModel} <: StateEstimator
1818
function InternalModel{M}(model::M, i_ym, Asm, Bsm, Csm, Dsm) where {M<:SimModel}
1919
nu, ny = model.nu, model.ny
2020
nym, nyu = length(i_ym), ny - length(i_ym)
21-
if isa(model, LinModel)
22-
poles = eigvals(model.A)
23-
if any(abs.(poles) .≥ 1)
24-
error("InternalModel does not support integrating or unstable model")
25-
end
26-
end
21+
validate_internalmodel(model)
2722
validate_ym(model, i_ym)
2823
if size(Csm,1) nym || size(Dsm,1) nym
2924
error("Stochastic model output quantity ($(size(Csm,1))) is different from "*
@@ -51,7 +46,6 @@ struct InternalModel{M<:SimModel} <: StateEstimator
5146
end
5247
end
5348

54-
5549
@doc raw"""
5650
InternalModel(model::SimModel; i_ym=1:model.ny, stoch_ym=ss(1,1,1,1,model.Ts).*I)
5751
@@ -92,9 +86,7 @@ function InternalModel(
9286
i_ym::IntRangeOrVector = 1:model.ny,
9387
stoch_ym::Union{StateSpace, TransferFunction} = ss(1,1,1,1,model.Ts).*I(length(i_ym))
9488
) where {M<:SimModel}
95-
if isa(stoch_ym, TransferFunction)
96-
stoch_ym = minreal(ss(stoch_ym))
97-
end
89+
stoch_ym = minreal(ss(stoch_ym))
9890
if iscontinuous(stoch_ym)
9991
stoch_ym = c2d(stoch_ym, model.Ts, :tustin)
10092
else
@@ -108,6 +100,14 @@ function InternalModel(
108100
return InternalModel{M}(model, i_ym, stoch_ym.A, stoch_ym.B, stoch_ym.C, stoch_ym.D)
109101
end
110102

103+
"Validate if `model` is asymptotically stable for [`LinModel`](@ref)."
104+
function validate_internalmodel(model::LinModel)
105+
poles = eigvals(model.A)
106+
if any(abs.(poles) .≥ 1)
107+
error("InternalModel does not support integrating or unstable model")
108+
end
109+
end
110+
validate_internalmodel(::SimModel) = nothing
111111

112112
@doc raw"""
113113
init_internalmodel(As, Bs, Cs, Ds)

0 commit comments

Comments
 (0)