Reachability.jl
Reachability.jl copied to clipboard
Fix system creation with SparseMatrixExp matrix type
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}
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.