Reachability.jl icon indicating copy to clipboard operation
Reachability.jl copied to clipboard

Fix system creation with SparseMatrixExp matrix type

Open schillic opened this issue 6 years ago • 1 comments

When running the FOM model, the discrete-system creation fails with the following message.

ERROR: MethodError: Cannot `convert` an object of type Array{Float64,2} to an object of type LazySets.SparseMatrixExp{Float64}

schillic avatar Dec 04 '18 15:12 schillic

The FOM model uses the lazy matrix exponential during discretization. The problem here is the automatic conversion of the B matrix to the same type as A. (B does not exist here, but that is not the point.)

DiscreteSystem(A::AbstractMatrix, X0::LazySet, U::ConstantInput) =
    IVP(CLCDS(A,
              convert(typeof(A), convert(typeof(A), Matrix{eltype(A)}(I, size(A)))),
              nothing, U),
        X0)

(On a side note, I wonder why we need to convert to the type of A twice :smiley:) The simplest solution is to wait until https://github.com/JuliaReach/MathematicalSystems.jl/issues/40 is fixed and then remove these conversions altogether.

schillic avatar Dec 15 '18 19:12 schillic