JuliaReach / Reachability.jl

Reachability and Safety of Nondeterministic Dynamical Systems
MIT License
50 stars 4 forks source link

Fix crashes in Schur transformation #689

Closed schillic closed 4 years ago

schillic commented 5 years ago

My test below shows that there is still something missing to back-transform the result. But I think this PR still improves the state by not crashing anymore.

using SparseArrays, MathematicalSystems, Reachability

A = sparse([1, 1, 2, 2], [1, 2, 1, 2], [3., -9., 4., -3.])
B = reshape([0.0, -1.0], (2, 1))
U = Singleton([1.0])
inv = Universe(2)
model = ConstrainedLinearControlContinuousSystem(A, B, inv, ConstantInput(U))
X0 = Hyperrectangle(low=[10.0, 0.0], high=[10.2, 0.0])
problem = InitialValueProblem(model, X0)

𝑂_original = Options(:T => 20.0, :mode => "reach")
𝑂_op_original = Options(:vars => [1, 2], :partition => [[1], [2]], :δ => 0.003)
sol_original = solve(problem, 𝑂_original, op=BFFPSV18(𝑂_op_original))

𝑂_transform = merge(𝑂_original, Options(:coordinate_transformation => "schur"))
𝑂_op_transform = merge(𝑂_op_original, Options())
sol_transform = solve(problem, 𝑂_transform, op=BFFPSV18(𝑂_op_transform))

using Plots
plot(sol_original)
plot(sol_transform)

original transform

EDIT: side note: There is something very wrong with our axis labels :smile:

schillic commented 4 years ago

The second commit adds a backtransformation. We actually never had that functionality, but thanks to a recent refactoring it was very simple.

schur

Note that the transformed flowpipe is the orange one, so for this system it is more precise to do the computations in the transformed system.