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

solve a system with control input #595

Closed
ga72kud opened this issue Dec 14, 2021 · 2 comments
Closed

solve a system with control input #595

ga72kud opened this issue Dec 14, 2021 · 2 comments

Comments

@ga72kud
Copy link

ga72kud commented Dec 14, 2021

I am new to reachability analysis.jl package and wondering why there are only autonomous systems without control input

\dot{x}=Ax+Bu
or
\dot{x}=Ax+u

I am looking how I would write following example from here:
https://juliareach.github.io/LazySets.jl/dev/man/reach_zonotopes/

with tools from reachabilityAnalysis.jl

@mforets
Copy link
Member

mforets commented Dec 21, 2021

For the first example,

using ReachabilityAnalysis, Plots

A = [-1 -4; 4 -1.0]
X0 = Zonotope([1.0, 0.0], Matrix(0.1*I, 2, 2))
μ = 0.05
δ = 0.02
T = 2.
U = BallInf(zeros(2), μ)

prob = @ivp(x' = A*x + u, x(0)  X0, u  U, x  Universe(2))
sol = solve(prob, alg=GLGM06=δ), T=T);

plot(sol, vars=(1, 2), fillalpha=0.1)

The second example can be defined similarly. Moreover, note that the projection is handled automatically by the plot command, i.e. plot(sol, vars=(1, 5)) should work.

@ga72kud
Copy link
Author

ga72kud commented Dec 21, 2021

I have tested the program with two examples. It worked thank you a lot.

using ReachabilityAnalysis, Plots
#example 1
A = [-1 -4; 4 -1.0]
X0 = Zonotope([1.0, 0.0], Matrix(0.1*I, 2, 2))
μ = 0.05
δ = 0.02
T = 2.
U = BallInf(zeros(2), μ)

prob = @ivp(x' = A*x + u, x(0)  X0, u  U, x  Universe(2))
sol = solve(prob, alg=GLGM06=δ), T=T);

plot(sol, vars=(1, 2), fillalpha=0.1)

#example 2
A = Matrix{Float64}([-1 -4 0 0 0;
                      4 -1 0 0 0;
                      0 0 -3 1 0;
                      0 0 -1 -3 0;
                      0 0 0 0 -2])
X0 = Zonotope([1.0, 0.0, 0.0, 0.0, 0.0], Matrix(0.1*I, 5, 5))
μ = 0.01
δ = 0.005
T = 1.
U = BallInf(zeros(5), μ)

prob = @ivp(x' = A*x + u, x(0)  X0, u  U, x  Universe(5))
sol = solve(prob, alg=GLGM06=δ), T=T);
plot(sol, vars=(1, 3))


#double integrator with ẋ=Ax+Bu
A = [0 0 1.0 0; 0 0 1.0 0; 0 0 0 0; 0 0 0 0]
B = [1.0 0; 1.0 0; 0 1.0; 0 1.0]
X0 = Zonotope([1.0, 0.0, 0.0, 0.0], Matrix(0.1*I, 4, 4))
μ = 0.05
δ = 0.02
T = 2.
U = BallInf(zeros(2), μ)
prob = @ivp(x' = A*x + B*u, x(0)  X0, u  U, x  Universe(4))
sol = solve(prob, alg=GLGM06=δ), T=T);
plot(sol, vars=(1, 2), fillalpha=0.1)

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

No branches or pull requests

2 participants