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

Use current_path from ReachabilityBase in examples and revise examples #780

Merged
merged 4 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LazySets = "b4f0291d-fe17-52bc-9479-3d1a343d9043"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
MathematicalSystems = "d14a8603-c872-5ed3-9ece-53e0e82e39da"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ReachabilityBase = "379f33d0-9447-4353-bd03-d664070e549f"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"

[compat]
Expand All @@ -24,4 +25,5 @@ LazySets = "2"
Literate = "2"
MathematicalSystems = "0.11 - 0.13"
Plots = "1"
ReachabilityBase = "0.2.3"
Symbolics = "5"
6 changes: 5 additions & 1 deletion docs/generate.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Literate
import ReachabilityBase.CurrentPath: @current_path

source_dir = joinpath(@__DIR__, "..", "examples")
# target directory for script files (*.jl) (used in the tests)
Expand All @@ -13,7 +14,6 @@ MODELS = [
"Building",
"DuffingOscillator",
"EMBrake",
"Heat3D",
"ISS",
"LaubLoomis",
"Lorenz",
Expand All @@ -30,6 +30,10 @@ MODELS = [
#
]

macro current_path(prefix::String, filename::String)
return joinpath(source_dir, prefix, filename)
end

for model in MODELS
model_path = abspath(joinpath(source_dir, model))
for file in readdir(model_path)
Expand Down
12 changes: 6 additions & 6 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ CLOCKED_SYSTEMS = ["Clocked systems" => [
#
]]

BACKWARDS_REACHABILITY = ["Backwards reachability" => [
#
"Introduction" => "tutorials/backwards_reachability/introduction.md",
"Projectile motion" => "generated_examples/Projectile.md"
#
]]
# BACKWARDS_REACHABILITY = ["Backwards reachability" => [
# #
# "Introduction" => "tutorials/backwards_reachability/introduction.md",
# "Projectile motion" => "generated_examples/Projectile.md"
# #
# ]]

# LINEAR_PDE = ["Linear PDEs" => [
# #
Expand Down
9 changes: 4 additions & 5 deletions examples/Building/Building.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@
# In both cases the input set $\mathcal{U}$ is the interval $[0.8, 1.0]$ is,
# and the initial states are taken from Table 2.2 in [^TLT16].

using ReachabilityAnalysis, SparseArrays, JLD2
using ReachabilityAnalysis, SparseArrays, JLD2, ReachabilityBase.CurrentPath

LazySets.set_ztol(Float64, 1e-14)

const x25 = [zeros(24); 1.0; zeros(23)]
const x25e = vcat(x25, 0.0)

examples_dir = normpath(@__DIR__, "..", "..", "..", "examples")
building_path = joinpath(examples_dir, "Building", "building.jld2")
path = @current_path("Building", "building.jld2")

function building_BLDF01()
@load building_path A B
@load path A B
n = size(A, 1)
U = Interval(0.8, 1.0)
S = @system(x' = Ax + Bu, u ∈ U, x ∈ Universe(n))
Expand All @@ -66,7 +65,7 @@ end
using ReachabilityAnalysis: add_dimension

function building_BLDC01()
@load building_path A B
@load path A B
n = size(A, 1)
U = Interval(0.8, 1.0)

Expand Down
5 changes: 2 additions & 3 deletions examples/Heat3D/Heat3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# - *(constant inputs):* The inputs are uncertain only in their initial value, and
# constant over time: ``u(0)\in \mathcal{U}``, ``\dot u (t)= 0``.

using ReachabilityAnalysis, SparseArrays, JLD2
using ReachabilityAnalysis, SparseArrays, JLD2, ReachabilityBase.CurrentPath

examples_dir = normpath(@__DIR__, "..", "..", "..", "examples")
HEAT01_path = joinpath(examples_dir, "Heat3D", "HEAT01.jld2")
path = @current_path("Heat3D", "HEAT01.jld2")
11 changes: 5 additions & 6 deletions examples/ISS/ISS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
# such `.mat` file has been converted to the [JLD2 format](https://github.com/JuliaIO/JLD2.jl)
# and stored in the file `iss.jld2`.

using ReachabilityAnalysis, JLD2
using ReachabilityAnalysis, JLD2, ReachabilityBase.CurrentPath
using ReachabilityAnalysis: add_dimension

LazySets.set_ztol(Float64, 1e-15);

examples_dir = normpath(@__DIR__, "..", "..", "..", "examples")
ISS_path = joinpath(examples_dir, "ISS", "ISS.jld2")
path = @current_path("ISS", "ISS.jld2")

@load ISS_path C;
@load path C;
const C3 = C[3, :]; # variable y₃
const C3_ext = vcat(C3, fill(0.0, 3));

Expand Down Expand Up @@ -99,7 +98,7 @@ const C3_ext = vcat(C3, fill(0.0, 3));
# to the given input range ``U``.

function ISSF01()
@load ISS_path A B
@load path A B

U = Hyperrectangle(; low=[0.0, 0.8, 0.9], high=[0.1, 1.0, 1.0])
X0 = BallInf(zeros(size(A, 1)), 0.0001)
Expand Down Expand Up @@ -156,7 +155,7 @@ fig
# value and constant over time.

function ISSC01()
@load ISS_path A B
@load path A B

A_ext = add_dimension(A, 3)
A_ext[1:270, 271:273] = B
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ to load models that can be used like this:
```julia
using ReachabilityModels, Plots

prob = load_model("building"); # initial-value problem for the Van der Pol modeld
prob = load_model("building"); # initial-value problem

sol = solve(prob, tspan=(0, 5)); # solve it using default options

Expand Down
Loading