Skip to content

Commit e0f60db

Browse files
committed
ternary operator in initstate!
1 parent a7bae6c commit e0f60db

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/estimator/internal_model.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ The deterministic state `estim.x̂d` initialization method is identical to
166166
"""
167167
function initstate!(estim::InternalModel, u, ym, d=Float64[])
168168
model = estim.model
169-
if isa(model, LinModel)
170-
x̂d = steadystate(model, u, d)
171-
else
172-
x̂d = estim.x̂[1:model.nx]
173-
end
169+
x̂d = isa(model, LinModel) ? steadystate(model, u, d) : estim.x̂[1:model.nx]
174170
estim.x̂d[:] = x̂d
175171
# TODO: best method to initialize internal model stochastic states ? not sure...
176172
estim.x̂s[:] = zeros(estim.nxs)

src/state_estim.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,7 @@ julia> x̂ = initstate!(estim, [1], [3 - 0.1])
197197
function initstate!(estim::StateEstimator, u, ym, d=Float64[])
198198
model = estim.model
199199
# --- deterministic model states ---
200-
x̂d = estim.x̂[1:model.nx]
201-
if isa(model, LinModel)
202-
# init deterministic state with steady-states at current input and disturbance :
203-
x̂d = steadystate(model, u, d)
204-
end
200+
x̂d = isa(model, LinModel) ? steadystate(model, u, d) : estim.x̂[1:model.nx]
205201
# --- stochastic model states (integrators) ---
206202
ŷd = model.h(x̂d, d - model.dop) + model.yop
207203
ŷsm = ym - ŷd[estim.i_ym]

0 commit comments

Comments
 (0)