Skip to content

Commit

Permalink
Merge pull request #326 from JuliaReach/schillic/models
Browse files Browse the repository at this point in the history
Update models and add new patch version
  • Loading branch information
schillic authored Aug 28, 2022
2 parents 301f936 + 5316b3e commit 99638e1
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ClosedLoopReachability"
uuid = "73c0b437-a350-4e9b-97ac-9adb151c271b"
version = "0.2.3"
version = "0.2.4"

[deps]
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
Expand Down
5 changes: 3 additions & 2 deletions models/AttitudeControl/AttitudeControl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ print_timed(res);
# Finally we plot the results:

using Plots
import DisplayAs

function plot_helper(fig, vars; show_simulation::Bool=true)
plot!(fig, sol, vars=vars, color=:yellow, lab="")
Expand All @@ -124,13 +125,13 @@ function plot_helper(fig, vars; show_simulation::Bool=true)
if show_simulation
plot_simulation!(fig, sim; vars=vars, color=:black, lab="")
end
fig = DisplayAs.Text(DisplayAs.PNG(fig))
end

vars = (1, 2)
fig = plot(xlab="ω₁", ylab="ω₂")
plot_helper(fig, vars)

savefig("AttitudeControl-x1-x2.png")
# savefig("AttitudeControl-x1-x2.png")

#-

Expand Down
5 changes: 3 additions & 2 deletions models/Quadrotor/Quadrotor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ print_timed(res);
# Finally we plot the results:

using Plots
import DisplayAs

function plot_helper(fig, vars; show_simulation::Bool=true)
plot!(fig, sol, vars=vars, color=:white, lab="") # to set the plot limits
Expand All @@ -237,13 +238,13 @@ function plot_helper(fig, vars; show_simulation::Bool=true)
if show_simulation
plot_simulation!(fig, sim; vars=vars, color=:black, lab="")
end
fig = DisplayAs.Text(DisplayAs.PNG(fig))
end

vars = (0, 3)
fig = plot(xlab="t", ylab="x₃")
plot_helper(fig, vars)

savefig("Quadrotor-t-x3.png")
# savefig("Quadrotor-t-x3.png")

end #jl
nothing #jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module TORA_ReluTanh #jl

using ClosedLoopReachability, MAT
using ClosedLoopReachability: UniformAdditivePostprocessing
using ClosedLoopReachability: LinearMapPostprocessing

# This model consists of a cart attached to a wall with a spring. The cart is
# free to move on a friction-less surface. The car has a weight attached to an
Expand Down Expand Up @@ -55,7 +55,7 @@ vars_idx = Dict(:states=>1:4, :controls=>5)
ivp = @ivp(x' = TORA!(x), dim: 5, x(0) X₀ × U)

period = 0.5 # control period
control_postprocessing = UniformAdditivePostprocessing(-10.0) # control postprocessing
control_postprocessing = LinearMapPostprocessing(11.0) # control postprocessing

prob = ControlledPlant(ivp, controller, vars_idx, period;
postprocessing=control_postprocessing)
Expand All @@ -66,8 +66,7 @@ T_warmup = 2 * period # shorter time horizon for dry run

goal_states_x1x2 = Hyperrectangle(low=[-0.1, -0.9], high=[0.2, -0.6])
goal_states = cartesian_product(goal_states_x1x2, Universe(3))
predicate =
sol -> all(isdisjoint(project(R, [1, 2]), goal_states_x1x2) for F in sol for R in F);
predicate = sol -> project(sol[end][end], [1, 2]) goal_states_x1x2;

# ## Results

Expand All @@ -88,9 +87,9 @@ function benchmark(; T=T, silent::Bool=false)
silent || print_timed(res_pred)

if res_pred.value
silent || println("The property is violated.")
silent || println("The property is satisfied.")
else
silent || println("The property may be satisfied.")
silent || println("The property may be violated.")
end
return solz
end
Expand Down Expand Up @@ -125,6 +124,7 @@ function plot_helper(fig, vars)
plot!(fig, goal_states_projected, color=:cyan, lab="goal states")
plot!(fig, sol, vars=vars, color=:yellow, lab="")
plot_simulation!(fig, sim; vars=vars, color=:black, lab="")
lens!(fig, [0.0, 0.25], [-0.85, -0.7], inset = (1, bbox(0.4, 0.4, 0.3, 0.3)), lc=:black)
fig = DisplayAs.Text(DisplayAs.PNG(fig))
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module TORA_Sigmoid #jl

using ClosedLoopReachability, MAT
using ClosedLoopReachability: UniformAdditivePostprocessing
using ClosedLoopReachability: LinearMapPostprocessing

# This model consists of a cart attached to a wall with a spring. The cart is
# free to move on a friction-less surface. The car has a weight attached to an
Expand Down Expand Up @@ -55,7 +55,7 @@ vars_idx = Dict(:states=>1:4, :controls=>5)
ivp = @ivp(x' = TORA!(x), dim: 5, x(0) X₀ × U)

period = 0.5 # control period
control_postprocessing = UniformAdditivePostprocessing(-10.0) # control postprocessing
control_postprocessing = LinearMapPostprocessing(11.0) # control postprocessing

prob = ControlledPlant(ivp, controller, vars_idx, period;
postprocessing=control_postprocessing)
Expand All @@ -67,8 +67,7 @@ T_warmup = 2 * period # shorter time horizon for dry run
## The property for falsifying:
goal_states_x1x2 = Hyperrectangle(low=[-0.1, -0.9], high=[0.2, -0.6])
goal_states = cartesian_product(goal_states_x1x2, Universe(3))
predicate =
sol -> all(isdisjoint(project(R, [1, 2]), goal_states_x1x2) for F in sol for R in F);
predicate = sol -> project(sol[end][end], [1, 2]) goal_states_x1x2;

# ## Results

Expand All @@ -89,9 +88,9 @@ function benchmark(; T=T, silent::Bool=false)
silent || print_timed(res_pred)

if res_pred.value
silent || println("The property is violated.")
silent || println("The property is satisfied.")
else
silent || println("The property may be satisfied.")
silent || println("The property may be violated.")
end
return solz
end
Expand Down Expand Up @@ -126,6 +125,7 @@ function plot_helper(fig, vars)
plot!(fig, goal_states_projected, color=:cyan, lab="goal states")
plot!(fig, sol, vars=vars, color=:yellow, lab="")
plot_simulation!(fig, sim; vars=vars, color=:black, lab="")
lens!(fig, [0.1, 0.25], [-0.9, -0.8], inset = (1, bbox(0.4, 0.4, 0.3, 0.3)), lc=:black)
fig = DisplayAs.Text(DisplayAs.PNG(fig))
end

Expand Down
Binary file modified models/Sherlock-Benchmark-9-TORA/controllerToraReluTanh.mat
Binary file not shown.
Binary file modified models/Sherlock-Benchmark-9-TORA/controllerToraSigmoid.mat
Binary file not shown.
12 changes: 6 additions & 6 deletions models/Spacecraft/Spacecraft.jl
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function benchmark(; silent::Bool=false)
sol = res_sol.value
silent || print_timed(res_sol)

## Next we check the property for an overapproximated flowpipe:
## Next we check the property:
silent || println("property checking")
res_pred = @timed predicate_sol(sol)
silent || print_timed(res_pred)
Expand All @@ -130,7 +130,7 @@ print_timed(res);
import DifferentialEquations

println("simulation")
res = @timed simulate(prob, T=T, trajectories=10, include_vertices=true)
res = @timed simulate(prob, T=T, trajectories=1, include_vertices=true)
sim = res.value
print_timed(res);

Expand All @@ -153,27 +153,27 @@ print_timed(res);
# Finally we plot the results:

using Plots
import DisplayAs

function plot_helper(fig, vars; show_simulation::Bool=true)
plot!(fig, sol, vars=vars, color=:yellow, lab="")
if show_simulation
plot_simulation!(fig, sim; vars=vars, color=:black, lab="")
end
fig = DisplayAs.Text(DisplayAs.PNG(fig))
end

vars = (1, 2)
fig = plot(xlab="x", ylab="y")
plot_helper(fig, vars)

savefig("Spacecraft-x-y.png")
# savefig("Spacecraft-x-y.png")

#-

vars = (3, 4)
fig = plot(xlab="x'", ylab="y'")
plot_helper(fig, vars)

savefig("Spacecraft-x'-y'.png")
# savefig("Spacecraft-x'-y'.png")

#-

Expand Down
Binary file modified models/Spacecraft/model.mat
100755 → 100644
Binary file not shown.

2 comments on commit 99638e1

@schillic
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/67226

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.4 -m "<description of version>" 99638e18e200408cfa8fa3710566828d0057a5a1
git push origin v0.2.4

Please sign in to comment.