# RobustAndOptimalControl.jl Uncertain Time Delays For State Space Models

**URL:** <https://discourse.julialang.org/t/robustandoptimalcontrol-jl-uncertain-time-delays-for-state-space-models/104514>\
**Category:** Modelling & Simulations\
**Tags:** controlsystems\
**Created:** [October 2, 2023, 10:22pm UTC](https://discourse.julialang.org/t/robustandoptimalcontrol-jl-uncertain-time-delays-for-state-space-models/104514 "2023-10-02T22:22:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthew3245](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@matthew3245](https://discourse.julialang.org/u/matthew3245)\
**Post date:** [October 2, 2023, 10:22pm UTC](https://discourse.julialang.org/t/robustandoptimalcontrol-jl-uncertain-time-delays-for-state-space-models/104514/1 "2023-10-02T22:22:28Z")

</div>

I can’t get uncertain time delays for state space models to work. For example, the following code:

```julia
julia> using LinearAlgebra, ControlSystems, RobustAndOptimalControl, MonteCarloMeasurements
julia> P = ss(-1, 1, I, 0)
julia> P * delay(0.1 .. 0.3)

ERROR: TypeError: in new, expected ControlSystemsBase.PartitionedStateSpace{Continuous, StateSpace{Continuous, Particles{Float64, 2000}}}, got a value of type ControlSystemsBase.PartitionedStateSpace{Continuous, StateSpace{Continuous, Int64}}
Stacktrace:
 [1] DelayLtiSystem{Particles{Float64, 2000}, Particles{Float64, 2000}}(P::StateSpace{Continuous, Int64}, Tau::Vector{Float64})
   @ ControlSystemsBase ~/.julia/packages/ControlSystemsBase/CUXI9/src/types/DelayLtiSystem.jl:8
 [2] DelayLtiSystem{Particles{Float64, 2000}, Particles{Float64, 2000}}(sys::StateSpace{Continuous, Int64})
   @ ControlSystemsBase ~/.julia/packages/ControlSystemsBase/CUXI9/src/types/DelayLtiSystem.jl:21
 [3] convert(#unused#::Type{DelayLtiSystem{Particles{Float64, 2000}, Particles{Float64, 2000}}}, sys::StateSpace{Continuous, Int64})
   @ ControlSystemsBase ~/.julia/packages/ControlSystemsBase/CUXI9/src/types/DelayLtiSystem.jl:52
 [4] _promote
   @ ./promotion.jl:358 [inlined]
 [5] promote
   @ ./promotion.jl:381 [inlined]
 [6] *(sys1::StateSpace{Continuous, Int64}, sys2::DelayLtiSystem{Particles{Float64, 2000}, Particles{Float64, 2000}})
   @ ControlSystemsBase ~/.julia/packages/ControlSystemsBase/CUXI9/src/types/Lti.jl:4
 [7] top-level scope
   @ REPL[5]:1

```

The above code for the exact same system works for transfer functions however:

```julia
julia> using LinearAlgebra, ControlSystems, RobustAndOptimalControl, MonteCarloMeasurements
julia> P = tf(1, [1, 1])
julia> P * delay(0.1 .. 0.3)

DelayLtiSystem{Particles{Float64, 2000}, Particles{Float64, 2000}}

P: StateSpace{Continuous, Particles{Float64, 2000}}
A = 
 -1.0
B = 
 0.0 1.0
C = 
 1.0
 0.0
D = 
 0.0 0.0
 1.0 0.0

Continuous-time state-space model

Delays: Particles{Float64, 2000}[0.2 ± 0.058]

```

Does anyone know why one method works and not the other? Ideally I want to use state space models for my project.

Cheers.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [October 3, 2023, 9:20am UTC](https://discourse.julialang.org/t/robustandoptimalcontrol-jl-uncertain-time-delays-for-state-space-models/104514/2 "2023-10-03T09:20:28Z")

</div>

Fixed by [fix DelaySS conversion with special number type by baggepinnen · Pull Request #878 · JuliaControl/ControlSystems.jl · GitHub](https://github.com/JuliaControl/ControlSystems.jl/pull/878)

---

<div class="post-metadata">

**Author:** ![matthew3245](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@matthew3245](https://discourse.julialang.org/u/matthew3245)\
**Post date:** [October 3, 2023, 11:50am UTC](https://discourse.julialang.org/t/robustandoptimalcontrol-jl-uncertain-time-delays-for-state-space-models/104514/3 "2023-10-03T11:50:06Z")

</div>

Thanks mate! Appreciate the help!
