Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes in Schur transformation #689

Merged
merged 2 commits into from
Oct 16, 2019
Merged

Fix crashes in Schur transformation #689

merged 2 commits into from
Oct 16, 2019

Conversation

schillic
Copy link
Member

@schillic schillic commented Oct 3, 2019

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 😄

@schillic schillic requested a review from mforets October 3, 2019 16:25
@@ -79,6 +88,17 @@ function schur_transform(problem::InitialValueProblem{PT, ST}
invariant_new = Universe(n)
end

system_new = (A_new, I(n), invariant_new, U_new)
return InitialValueProblem(PT(system_new), X0_new)
system_new = _wrap_system(PT, A_new, B_new, invariant_new, U_new)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper function _wrap_system is necessary because the type parameters of PT may change. For instance, B could be an IdentityMultiple, but then its transformation is a proper Matrix.

@schillic
Copy link
Member Author

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.


The transformation is implemented with a lazy `LinearMap`.
"""
function backtransform(Rsets, options::Options)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type of Rsets should be ReachSolution, but that type is not available in this module because it is only defined later in the ReachSets module.

@JuliaReach JuliaReach deleted a comment from codecov-io Oct 13, 2019
@schillic schillic merged commit d0eae9f into master Oct 16, 2019
@schillic schillic deleted the schillic/schur branch October 16, 2019 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants