From 7342e9fe5bd52525322203b1ba987a9fb1fb387b Mon Sep 17 00:00:00 2001 From: schillic Date: Wed, 6 Mar 2024 22:35:25 +0100 Subject: [PATCH] replace relpath macro by ReachabilityBase.current_path --- Project.toml | 4 ++ models/ARCH/AFF/Building/building.jl | 2 +- .../ARCH/AFF/Building/building_benchmark.jl | 8 ++-- .../AFF/Platooning/Platooning_benchmark.jl | 4 +- .../SpacecraftRendezvous_benchmark.jl | 4 +- models/ARCH/AFF/SpaceStation/iss.jl | 2 +- models/ARCH/AFF/SpaceStation/iss_benchmark.jl | 4 +- .../NLN/LaubLoomis/laubloomis_benchmark.jl | 8 ++-- .../ARCH/NLN/Quadrotor/quadrotor_benchmark.jl | 2 +- .../ARCH/NLN/VanDerPol/vanderpol_benchmark.jl | 6 +-- models/ARCH2020/AFF/Building/building.jl | 2 +- .../AFF/Building/building_benchmark.jl | 20 ++++----- .../BouncingBall/bouncingBallNonlinear_run.jl | 4 +- models/Crane/crane_run.jl | 4 +- models/FiveDimSys/fiveDimSys_run.jl | 4 +- models/Helicopter/helicopter_run.jl | 4 +- .../LinearSwitching/linearSwitching_model.jl | 4 +- models/LinearSwitching/linearSwitching_run.jl | 4 +- models/Lorenz/lorenz_run.jl | 4 +- models/Projectile/projectile_run.jl | 4 +- models/SLICOT/beam/beam_model.jl | 2 +- models/SLICOT/beam/beam_run.jl | 4 +- models/SLICOT/building/building_model.jl | 2 +- models/SLICOT/building/building_run.jl | 4 +- models/SLICOT/cdplayer/cdplayer_model.jl | 2 +- models/SLICOT/cdplayer/cdplayer_run.jl | 4 +- models/SLICOT/fom/fom_model.jl | 2 +- models/SLICOT/fom/fom_run.jl | 4 +- models/SLICOT/fom/fom_specifications.jl | 2 +- models/SLICOT/heat/heat_model.jl | 2 +- models/SLICOT/heat/heat_run.jl | 4 +- models/SLICOT/iss/iss_model.jl | 2 +- models/SLICOT/iss/iss_run.jl | 4 +- models/SLICOT/iss/iss_specifications.jl | 2 +- models/SLICOT/mna1/mna1_model.jl | 2 +- models/SLICOT/mna1/mna1_run.jl | 4 +- models/SLICOT/mna5/mna5_model.jl | 2 +- models/SLICOT/mna5/mna5_run.jl | 4 +- models/SLICOT/motor/motor_run.jl | 4 +- models/SLICOT/pde/pde_model.jl | 2 +- models/SLICOT/pde/pde_run.jl | 4 +- models/SLICOT/pde/pde_specifications.jl | 2 +- models/SpikingNeuron/spikingNeuron_run.jl | 4 +- src/ReachabilityBenchmarks.jl | 12 ++--- src/benchmark_all.jl | 24 +++++----- src/check_1D_dense.jl | 4 +- src/check_1D_discrete.jl | 4 +- src/check_kD_dense.jl | 4 +- src/check_kD_discrete.jl | 4 +- src/io.jl | 45 ------------------- src/reach_1D_all.jl | 6 +-- src/reach_1D_single.jl | 6 +-- src/reach_2D_box_two.jl | 6 +-- src/reach_2D_eps_two.jl | 6 +-- src/reach_kD_all.jl | 6 +-- test/runtests.jl | 5 --- 56 files changed, 123 insertions(+), 175 deletions(-) delete mode 100644 src/io.jl diff --git a/Project.toml b/Project.toml index f117c5aa..6623f64a 100644 --- a/Project.toml +++ b/Project.toml @@ -2,5 +2,9 @@ name = "ReachabilityBenchmarks" uuid = "a4785ef3-4c78-58ec-bbba-68644ee365c0" version = "0.0.1" +[deps] +ReachabilityBase = "379f33d0-9447-4353-bd03-d664070e549f" + [compat] +ReachabilityBase = "0.2.5" julia = "1.2" diff --git a/models/ARCH/AFF/Building/building.jl b/models/ARCH/AFF/Building/building.jl index e824b020..a34267bd 100644 --- a/models/ARCH/AFF/Building/building.jl +++ b/models/ARCH/AFF/Building/building.jl @@ -9,7 +9,7 @@ using ReachabilityBenchmarks, Reachability, MathematicalSystems, SX, # ============================== # Load model # ============================== -file = @relpath "SX/Building_more_decimals.xml" +file = @current_path "SX/Building_more_decimals.xml" H = readsxmodel(file; ST=ConstrainedLinearControlContinuousSystem) # =================== diff --git a/models/ARCH/AFF/Building/building_benchmark.jl b/models/ARCH/AFF/Building/building_benchmark.jl index 07e6042f..15be4420 100644 --- a/models/ARCH/AFF/Building/building_benchmark.jl +++ b/models/ARCH/AFF/Building/building_benchmark.jl @@ -49,7 +49,7 @@ plot(res; size=(1000, 1000)) plot_dashed_line!(4e-3) plot_dashed_line!(5.1e-3) -savefig(@relpath "BLDF01_time_horizon_1.png") +savefig(@current_path "BLDF01_time_horizon_1.png") plot(res; tickfont=font(30, "Times"), guidefontsize=45, @@ -61,7 +61,7 @@ plot(res; size=(1000, 1000)) plot_dashed_line!(4e-3) plot_dashed_line!(5.1e-3) -savefig(@relpath "BLDF01_time_horizon_20.png") +savefig(@current_path "BLDF01_time_horizon_20.png") š¯‘‚_BLDC01[:mode] = "reach" š¯‘‚_BLDC01[:plot_vars] = [0, 25] @@ -78,7 +78,7 @@ plot(res; size=(1000, 1000)) plot_dashed_line!(4e-3) plot_dashed_line!(5.1e-3) -savefig(@relpath "BLDC01_time_horizon_1.png") +savefig(@current_path "BLDC01_time_horizon_1.png") plot(res; tickfont=font(30, "Times"), guidefontsize=45, @@ -90,4 +90,4 @@ plot(res; size=(1000, 1000)) plot_dashed_line!(4e-3) plot_dashed_line!(5.1e-3) -savefig(@relpath "BLDC01_time_horizon_20.png") +savefig(@current_path "BLDC01_time_horizon_20.png") diff --git a/models/ARCH/AFF/Platooning/Platooning_benchmark.jl b/models/ARCH/AFF/Platooning/Platooning_benchmark.jl index c439c1e4..25f71fe3 100644 --- a/models/ARCH/AFF/Platooning/Platooning_benchmark.jl +++ b/models/ARCH/AFF/Platooning/Platooning_benchmark.jl @@ -103,7 +103,7 @@ plot(res; bottom_margin=6mm, left_margin=2mm, size=(1000, 1000)) plot_dashed_line!(-42.0) -savefig(@relpath "PLAD01_BND42.png") +savefig(@current_path "PLAD01_BND42.png") options_PLAN01_UNB50[:mode] = "reach" options_PLAN01_UNB50[:plot_vars] = [0, 1] @@ -118,4 +118,4 @@ plot(res; bottom_margin=6mm, left_margin=2mm, size=(1000, 1000)) plot_dashed_line!(-50.0, time_horizon) -savefig(@relpath "PLAN01_UNB50.png") +savefig(@current_path "PLAN01_UNB50.png") diff --git a/models/ARCH/AFF/Rendezvous/SpacecraftRendezvous_benchmark.jl b/models/ARCH/AFF/Rendezvous/SpacecraftRendezvous_benchmark.jl index bfda0045..ddb56382 100644 --- a/models/ARCH/AFF/Rendezvous/SpacecraftRendezvous_benchmark.jl +++ b/models/ARCH/AFF/Rendezvous/SpacecraftRendezvous_benchmark.jl @@ -155,7 +155,7 @@ plot(res; xlims=(-1000.0, 0.0), ylims=(-500.0, 100.0), bottom_margin=10mm, left_margin=10mm, top_margin=3mm, size=(1000, 1000)) -savefig(@relpath "SRNA01_SR02.png") +savefig(@current_path "SRNA01_SR02.png") res = solve(SRA01, options, opC_dense, opD) plot(res; @@ -166,4 +166,4 @@ plot(res; xlims=(-1000.0, 400.0), ylims=(-500.0, 100.0), bottom_margin=10mm, left_margin=10mm, top_margin=3mm, size=(1000, 1000)) -savefig(@relpath "SRA01_SR02.png") +savefig(@current_path "SRA01_SR02.png") diff --git a/models/ARCH/AFF/SpaceStation/iss.jl b/models/ARCH/AFF/SpaceStation/iss.jl index 5d2a54c5..d3223da0 100644 --- a/models/ARCH/AFF/SpaceStation/iss.jl +++ b/models/ARCH/AFF/SpaceStation/iss.jl @@ -9,7 +9,7 @@ using ReachabilityBenchmarks, MAT, Reachability, MathematicalSystems, # ============================== # Load model # ============================== -file = matopen(@relpath "iss.mat") +file = matopen(@current_path "iss.mat") A = sparse(read(file, "A")) B = read(file, "B") C = Matrix(read(file, "C")[3, :]') diff --git a/models/ARCH/AFF/SpaceStation/iss_benchmark.jl b/models/ARCH/AFF/SpaceStation/iss_benchmark.jl index 6e0f9cb7..8986a076 100644 --- a/models/ARCH/AFF/SpaceStation/iss_benchmark.jl +++ b/models/ARCH/AFF/SpaceStation/iss_benchmark.jl @@ -57,7 +57,7 @@ plot(res; size=(1000, 1000)) plot_dashed_lines!(0.0005) plot_dashed_lines!(0.0007) -savefig(@relpath "ISSF01.png") +savefig(@current_path "ISSF01.png") š¯‘‚_ISS02[:mode] = "reach" š¯‘‚_ISS02[:projection_matrix] = projection_matrix @@ -80,4 +80,4 @@ plot(res; bottom_margin=6mm, left_margin=2mm, right_margin=2mm, size=(1000, 1000)) plot_dashed_lines!(0.00017) -savefig(@relpath "ISSC01.png") +savefig(@current_path "ISSC01.png") diff --git a/models/ARCH/NLN/LaubLoomis/laubloomis_benchmark.jl b/models/ARCH/NLN/LaubLoomis/laubloomis_benchmark.jl index 0539cae8..4215fcd1 100644 --- a/models/ARCH/NLN/LaubLoomis/laubloomis_benchmark.jl +++ b/models/ARCH/NLN/LaubLoomis/laubloomis_benchmark.jl @@ -101,7 +101,7 @@ plot(sol_case_1; size=(1000, 1000), linecolor="blue") plot!(x -> x, x -> 4.5, 0.0, 20.0; line=2, color="red", linestyle=:dash, legend=nothing) -savefig(@relpath "laubloomis_case_1.png") +savefig(@current_path "laubloomis_case_1.png") plot(sol_case_2; tickfont=font(30, "Times"), guidefontsize=45, @@ -114,7 +114,7 @@ plot(sol_case_2; size=(1000, 1000), linecolor="blue") plot!(x -> x, x -> 5.0, 0.0, 20.0; line=2, color="red", linestyle=:dash, legend=nothing) -savefig(@relpath "laubloomis_case_2.png") +savefig(@current_path "laubloomis_case_2.png") plot(sol_case_3; tickfont=font(30, "Times"), guidefontsize=45, @@ -127,7 +127,7 @@ plot(sol_case_3; size=(1000, 1000), linecolor="blue") plot!(x -> x, x -> 5.0, 0.0, 20.0; line=2, color="red", linestyle=:dash, legend=nothing) -savefig(@relpath "laubloomis_case_3.png") +savefig(@current_path "laubloomis_case_3.png") plot(sol_case_1; color="red") @@ -145,4 +145,4 @@ plot!(sol_case_3; alpha=0.2, plot!(x -> x, x -> 5.0, 0.0, 20.0; line=2, color="red", linestyle=:dash, legend=nothing) plot!(x -> x, x -> 4.5, 0.0, 20.0; line=2, color="red", linestyle=:dash, legend=nothing) -savefig(@relpath "laubloomis_case_all.png") +savefig(@current_path "laubloomis_case_all.png") diff --git a/models/ARCH/NLN/Quadrotor/quadrotor_benchmark.jl b/models/ARCH/NLN/Quadrotor/quadrotor_benchmark.jl index fd495b98..bb4fc6ac 100644 --- a/models/ARCH/NLN/Quadrotor/quadrotor_benchmark.jl +++ b/models/ARCH/NLN/Quadrotor/quadrotor_benchmark.jl @@ -57,4 +57,4 @@ plot!(x -> x, x -> 0.98, 0.0, 5.0; line=2, color="red", linestyle=:dash, legend= plot!(x -> x, x -> 1.02, 0.0, 5.0; line=2, color="red", linestyle=:dash, legend=nothing) plot!(x -> x, x -> 0.9, 0.0, 5.0; line=2, color="red", linestyle=:dash, legend=nothing) -savefig(@relpath "quadrotor.png") +savefig(@current_path "quadrotor.png") diff --git a/models/ARCH/NLN/VanDerPol/vanderpol_benchmark.jl b/models/ARCH/NLN/VanDerPol/vanderpol_benchmark.jl index 72990aeb..3e776ca3 100644 --- a/models/ARCH/NLN/VanDerPol/vanderpol_benchmark.jl +++ b/models/ARCH/NLN/VanDerPol/vanderpol_benchmark.jl @@ -95,7 +95,7 @@ plot(sol_1; size=(1000, 1000), linecolor="red", color="red") plot!(x -> x, x -> 2.75, -3.0, 3.0; line=2, color="red", linestyle=:dash, legend=nothing) -savefig(@relpath "vanderpol_case_1.png") +savefig(@current_path "vanderpol_case_1.png") # -------------------------- # Case 2 @@ -114,7 +114,7 @@ for i in 1:nsplits_x size=(1000, 1000), color="blue", linewidth=0.0, linecolor="blue", alpha=0.5) end -savefig(plot_2, @relpath "vanderpol_case_2.png") +savefig(plot_2, @current_path "vanderpol_case_2.png") # -------------------------- # Cases 1 and 2 overlapped @@ -143,4 +143,4 @@ plot!(plot_all, sol_1; tickfont=font(30, "Times"), guidefontsize=45, plot!(plot_all, x -> x, x -> 2.75, -2.5, 2.5; line=2, color="red", linestyle=:dash, legend=nothing) -savefig(plot_all, @relpath "vanderpol_case_all.png") +savefig(plot_all, @current_path "vanderpol_case_all.png") diff --git a/models/ARCH2020/AFF/Building/building.jl b/models/ARCH2020/AFF/Building/building.jl index 010154ff..cdf78c75 100644 --- a/models/ARCH2020/AFF/Building/building.jl +++ b/models/ARCH2020/AFF/Building/building.jl @@ -9,7 +9,7 @@ using ReachabilityBenchmarks, ReachabilityAnalysis, MathematicalSystems, SX, # ============================== # Load model # ============================== -file = @relpath "SpaceEx/Building_more_decimals.xml" +file = @current_path "SpaceEx/Building_more_decimals.xml" H = readsxmodel(file; ST=ConstrainedLinearControlContinuousSystem) # =================== diff --git a/models/ARCH2020/AFF/Building/building_benchmark.jl b/models/ARCH2020/AFF/Building/building_benchmark.jl index 96c4efe2..9fb19163 100644 --- a/models/ARCH2020/AFF/Building/building_benchmark.jl +++ b/models/ARCH2020/AFF/Building/building_benchmark.jl @@ -15,13 +15,13 @@ include("building_GLGM06.jl") # # tune parameters # tune!(SUITE) -# +# # # run the benchmarks # results = run(SUITE, verbose=false) -# +# # # return the sample with the smallest time value in each test # println("minimum: ", minimum(results)) -# +# # # return the median for each test # println("median: ", median(results)) @@ -49,7 +49,7 @@ plot(res; size=(1000, 1000)) plot_dashed_line!(4e-3) plot_dashed_line!(5.1e-3) -savefig(@relpath "BLDF01_time_horizon_1.png") +savefig(@current_path "BLDF01_time_horizon_1.png") # plot(res, # vars=plot_vars, @@ -62,10 +62,10 @@ savefig(@relpath "BLDF01_time_horizon_1.png") # size=(1000, 1000)) # plot_dashed_line!(4e-3) # plot_dashed_line!(5.1e-3) -# savefig(@relpath "BLDF01_time_horizon_20.png") -# +# savefig(@current_path "BLDF01_time_horizon_20.png") +# # res = solve(build_CONST, algo=algo_dense, T=time_horizon) -# +# # plot(res, # vars=plot_vars, # tickfont=font(30, "Times"), guidefontsize=45, @@ -77,8 +77,8 @@ savefig(@relpath "BLDF01_time_horizon_1.png") # size=(1000, 1000)) # plot_dashed_line!(4e-3) # plot_dashed_line!(5.1e-3) -# savefig(@relpath "BLDC01_time_horizon_1.png") -# +# savefig(@current_path "BLDC01_time_horizon_1.png") +# # plot(res, # vars=plot_vars, # tickfont=font(30, "Times"), guidefontsize=45, @@ -90,4 +90,4 @@ savefig(@relpath "BLDF01_time_horizon_1.png") # size=(1000, 1000)) # plot_dashed_line!(4e-3) # plot_dashed_line!(5.1e-3) -# savefig(@relpath "BLDC01_time_horizon_20.png") +# savefig(@current_path "BLDC01_time_horizon_20.png") diff --git a/models/BouncingBall/bouncingBallNonlinear_run.jl b/models/BouncingBall/bouncingBallNonlinear_run.jl index 0253114f..0d5d9f48 100644 --- a/models/BouncingBall/bouncingBallNonlinear_run.jl +++ b/models/BouncingBall/bouncingBallNonlinear_run.jl @@ -1,8 +1,8 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, TaylorIntegration, Plots -include(@relpath "bouncingBallNonlinear_model.jl") -include(@relpath "bouncingBallNonlinear_specifications.jl") +include(@current_path "bouncingBallNonlinear_model.jl") +include(@current_path "bouncingBallNonlinear_specifications.jl") S = bouncingBallNonlinear_model() X0, options = bouncingBallNonlinear_specification() diff --git a/models/Crane/crane_run.jl b/models/Crane/crane_run.jl index 619bf7c3..bfd63144 100644 --- a/models/Crane/crane_run.jl +++ b/models/Crane/crane_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "crane_model.jl") -include(@relpath "crane_specifications.jl") +include(@current_path "crane_model.jl") +include(@current_path "crane_specifications.jl") S = crane_model() X0, options = crane_specification() diff --git a/models/FiveDimSys/fiveDimSys_run.jl b/models/FiveDimSys/fiveDimSys_run.jl index 2726b753..e8840532 100644 --- a/models/FiveDimSys/fiveDimSys_run.jl +++ b/models/FiveDimSys/fiveDimSys_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "fiveDimSys_model.jl") -include(@relpath "fiveDimSys_specifications.jl") +include(@current_path "fiveDimSys_model.jl") +include(@current_path "fiveDimSys_specifications.jl") S = fiveDimSys_model() X0, options = fiveDimSys_specification() diff --git a/models/Helicopter/helicopter_run.jl b/models/Helicopter/helicopter_run.jl index 2390f3b3..c1c832e0 100644 --- a/models/Helicopter/helicopter_run.jl +++ b/models/Helicopter/helicopter_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "helicopter_model.jl") -include(@relpath "helicopter_specifications.jl") +include(@current_path "helicopter_model.jl") +include(@current_path "helicopter_specifications.jl") S = helicopter_model() X0, options = helicopter_specification() diff --git a/models/LinearSwitching/linearSwitching_model.jl b/models/LinearSwitching/linearSwitching_model.jl index 0a04554a..e25edcda 100644 --- a/models/LinearSwitching/linearSwitching_model.jl +++ b/models/LinearSwitching/linearSwitching_model.jl @@ -8,7 +8,7 @@ # transitions: 5 # # The model is taken from [1]. -# +# # [1] https://ths.rwth-aachen.de/research/projects/hypro/5-dimensional-switching-linear-system/ # ============================================================================== using HybridSystems, MathematicalSystems, LazySets, SymEngine @@ -24,7 +24,7 @@ function linearSwitching_model() HA = GraphAutomaton(5) # SpaceEx model - file = @relpath "SpaceEx/model.xml" + file = @current_path "SpaceEx/model.xml" model = readsxmodel(file; raw_dict=true) variables = convert.(Basic, [f.args[1].args[1] for f in model["flows"][1]]) inputs = [convert(Basic, :u)] diff --git a/models/LinearSwitching/linearSwitching_run.jl b/models/LinearSwitching/linearSwitching_run.jl index 10f1dab3..a3d165e3 100644 --- a/models/LinearSwitching/linearSwitching_run.jl +++ b/models/LinearSwitching/linearSwitching_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "linearSwitching_model.jl") -include(@relpath "linearSwitching_specifications.jl") +include(@current_path "linearSwitching_model.jl") +include(@current_path "linearSwitching_specifications.jl") S = linearSwitching_model() X0, options = linearSwitching_specification() diff --git a/models/Lorenz/lorenz_run.jl b/models/Lorenz/lorenz_run.jl index ab80c363..41272f72 100644 --- a/models/Lorenz/lorenz_run.jl +++ b/models/Lorenz/lorenz_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "lorenz_model.jl") -include(@relpath "lorenz_specifications.jl") +include(@current_path "lorenz_model.jl") +include(@current_path "lorenz_specifications.jl") S = lorenz_model() X0, options = lorenz_specification() diff --git a/models/Projectile/projectile_run.jl b/models/Projectile/projectile_run.jl index 1644314c..436ee82f 100644 --- a/models/Projectile/projectile_run.jl +++ b/models/Projectile/projectile_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "projectile_model.jl") -include(@relpath "projectile_specifications.jl") +include(@current_path "projectile_model.jl") +include(@current_path "projectile_specifications.jl") S = projectile_model() X0, options = projectile_specification() diff --git a/models/SLICOT/beam/beam_model.jl b/models/SLICOT/beam/beam_model.jl index 4ff90b7c..eaa9b23c 100644 --- a/models/SLICOT/beam/beam_model.jl +++ b/models/SLICOT/beam/beam_model.jl @@ -8,7 +8,7 @@ using ReachabilityBenchmarks, MathematicalSystems, LazySets, MAT function beam_model() - file = matopen(@relpath "beam.mat") + file = matopen(@current_path "beam.mat") # system matrix A = read(file, "A") diff --git a/models/SLICOT/beam/beam_run.jl b/models/SLICOT/beam/beam_run.jl index 820abcba..ba96b183 100644 --- a/models/SLICOT/beam/beam_run.jl +++ b/models/SLICOT/beam/beam_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "beam_model.jl") -include(@relpath "beam_specifications.jl") +include(@current_path "beam_model.jl") +include(@current_path "beam_specifications.jl") S = beam_model() X0, options = beam_specification() diff --git a/models/SLICOT/building/building_model.jl b/models/SLICOT/building/building_model.jl index f1b77343..1cf639ab 100644 --- a/models/SLICOT/building/building_model.jl +++ b/models/SLICOT/building/building_model.jl @@ -8,7 +8,7 @@ using ReachabilityBenchmarks, MathematicalSystems, LazySets, MAT function building_model() - file = matopen(@relpath "building.mat") + file = matopen(@current_path "building.mat") # system matrix A = read(file, "A") diff --git a/models/SLICOT/building/building_run.jl b/models/SLICOT/building/building_run.jl index 1d8b7410..6f2452a1 100644 --- a/models/SLICOT/building/building_run.jl +++ b/models/SLICOT/building/building_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "building_model.jl") -include(@relpath "building_specifications.jl") +include(@current_path "building_model.jl") +include(@current_path "building_specifications.jl") S = building_model() X0, options = building_specification() diff --git a/models/SLICOT/cdplayer/cdplayer_model.jl b/models/SLICOT/cdplayer/cdplayer_model.jl index bff21fed..add8893b 100644 --- a/models/SLICOT/cdplayer/cdplayer_model.jl +++ b/models/SLICOT/cdplayer/cdplayer_model.jl @@ -8,7 +8,7 @@ using ReachabilityBenchmarks, MathematicalSystems, LazySets, MAT function cdplayer_model() - file = matopen(@relpath "cdplayer.mat") + file = matopen(@current_path "cdplayer.mat") # system matrix A = read(file, "A") diff --git a/models/SLICOT/cdplayer/cdplayer_run.jl b/models/SLICOT/cdplayer/cdplayer_run.jl index 6dcb8e85..803cf339 100644 --- a/models/SLICOT/cdplayer/cdplayer_run.jl +++ b/models/SLICOT/cdplayer/cdplayer_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "cdplayer_model.jl") -include(@relpath "cdplayer_specifications.jl") +include(@current_path "cdplayer_model.jl") +include(@current_path "cdplayer_specifications.jl") S = cdplayer_model() X0, options = cdplayer_specification() diff --git a/models/SLICOT/fom/fom_model.jl b/models/SLICOT/fom/fom_model.jl index bb58da91..33853534 100644 --- a/models/SLICOT/fom/fom_model.jl +++ b/models/SLICOT/fom/fom_model.jl @@ -8,7 +8,7 @@ using ReachabilityBenchmarks, MathematicalSystems, LazySets, MAT function fom_model() - file = matopen(@relpath "fom.mat") + file = matopen(@current_path "fom.mat") # system matrix A = float(read(file, "A")) # the matrix has Int entries diff --git a/models/SLICOT/fom/fom_run.jl b/models/SLICOT/fom/fom_run.jl index 11e829a3..52190744 100644 --- a/models/SLICOT/fom/fom_run.jl +++ b/models/SLICOT/fom/fom_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "fom_model.jl") -include(@relpath "fom_specifications.jl") +include(@current_path "fom_model.jl") +include(@current_path "fom_specifications.jl") S = fom_model() X0, options = fom_specification() diff --git a/models/SLICOT/fom/fom_specifications.jl b/models/SLICOT/fom/fom_specifications.jl index 86d1f993..7fbfb13c 100644 --- a/models/SLICOT/fom/fom_specifications.jl +++ b/models/SLICOT/fom/fom_specifications.jl @@ -5,7 +5,7 @@ function fom_specification() X0 = Hyperrectangle(zeros(1006), [fill(0.0001, 400); zeros(606)]) # safety property: y ā‰¤ 185 for linear combination y (defined in out.mat) - y = read(matopen(@relpath "out.mat"), "M")[1, :] + y = read(matopen(@current_path "out.mat"), "M")[1, :] property = is_contained_in(HalfSpace(y, 185.0)) # time horizon: 20 time units diff --git a/models/SLICOT/heat/heat_model.jl b/models/SLICOT/heat/heat_model.jl index e2aed9c4..0e627876 100644 --- a/models/SLICOT/heat/heat_model.jl +++ b/models/SLICOT/heat/heat_model.jl @@ -8,7 +8,7 @@ using ReachabilityBenchmarks, MathematicalSystems, LazySets, MAT, SparseArrays function heat_model() - file = matopen(@relpath "heat.mat") + file = matopen(@current_path "heat.mat") # system matrix A = read(file, "A") diff --git a/models/SLICOT/heat/heat_run.jl b/models/SLICOT/heat/heat_run.jl index 3b2511fb..45bb9a9b 100644 --- a/models/SLICOT/heat/heat_run.jl +++ b/models/SLICOT/heat/heat_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "heat_model.jl") -include(@relpath "heat_specifications.jl") +include(@current_path "heat_model.jl") +include(@current_path "heat_specifications.jl") S = heat_model() X0, options = heat_specification() diff --git a/models/SLICOT/iss/iss_model.jl b/models/SLICOT/iss/iss_model.jl index 5e875383..8dc2d1e7 100644 --- a/models/SLICOT/iss/iss_model.jl +++ b/models/SLICOT/iss/iss_model.jl @@ -8,7 +8,7 @@ using ReachabilityBenchmarks, MathematicalSystems, LazySets, MAT function iss_model() - file = matopen(@relpath "iss.mat") + file = matopen(@current_path "iss.mat") # system matrix A = read(file, "A") diff --git a/models/SLICOT/iss/iss_run.jl b/models/SLICOT/iss/iss_run.jl index 7c2c556c..845e04ea 100644 --- a/models/SLICOT/iss/iss_run.jl +++ b/models/SLICOT/iss/iss_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "iss_model.jl") -include(@relpath "iss_specifications.jl") +include(@current_path "iss_model.jl") +include(@current_path "iss_specifications.jl") S = iss_model() X0, options = iss_specification() diff --git a/models/SLICOT/iss/iss_specifications.jl b/models/SLICOT/iss/iss_specifications.jl index 9c4a4b88..55e77792 100644 --- a/models/SLICOT/iss/iss_specifications.jl +++ b/models/SLICOT/iss/iss_specifications.jl @@ -5,7 +5,7 @@ function iss_specification() X0 = BallInf(zeros(270), 1e-4) # safety property: y ā‰¤ 7e-4 for linear combination y (defined in out.mat) - y = read(matopen(@relpath "out.mat"), "M")[1, :] + y = read(matopen(@current_path "out.mat"), "M")[1, :] property = is_contained_in(HalfSpace(y, 7e-4)) # time horizon: 20 time units diff --git a/models/SLICOT/mna1/mna1_model.jl b/models/SLICOT/mna1/mna1_model.jl index cbf91c19..4d9d3f15 100644 --- a/models/SLICOT/mna1/mna1_model.jl +++ b/models/SLICOT/mna1/mna1_model.jl @@ -7,7 +7,7 @@ using ReachabilityBenchmarks, MathematicalSystems, MAT, SparseArrays function mna1_model() - file = matopen(@relpath "mna1.mat") + file = matopen(@current_path "mna1.mat") # system matrix A = sparse(read(file, "A")) diff --git a/models/SLICOT/mna1/mna1_run.jl b/models/SLICOT/mna1/mna1_run.jl index 7e4ae4a0..00a6a7a8 100644 --- a/models/SLICOT/mna1/mna1_run.jl +++ b/models/SLICOT/mna1/mna1_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "mna1_model.jl") -include(@relpath "mna1_specifications.jl") +include(@current_path "mna1_model.jl") +include(@current_path "mna1_specifications.jl") S = mna1_model() X0, options = mna1_specification() diff --git a/models/SLICOT/mna5/mna5_model.jl b/models/SLICOT/mna5/mna5_model.jl index d18ff1db..e9acb3e6 100644 --- a/models/SLICOT/mna5/mna5_model.jl +++ b/models/SLICOT/mna5/mna5_model.jl @@ -7,7 +7,7 @@ using ReachabilityBenchmarks, MathematicalSystems, MAT, SparseArrays function mna5_model() - file = matopen(@relpath "mna5.mat") + file = matopen(@current_path "mna5.mat") # system matrix A = sparse(read(file, "A")) diff --git a/models/SLICOT/mna5/mna5_run.jl b/models/SLICOT/mna5/mna5_run.jl index 29f7ecbf..93fc2e5a 100644 --- a/models/SLICOT/mna5/mna5_run.jl +++ b/models/SLICOT/mna5/mna5_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "mna5_model.jl") -include(@relpath "mna5_specifications.jl") +include(@current_path "mna5_model.jl") +include(@current_path "mna5_specifications.jl") S = mna5_model() X0, options = mna5_specification() diff --git a/models/SLICOT/motor/motor_run.jl b/models/SLICOT/motor/motor_run.jl index ef6f9b0e..37b0f0e7 100644 --- a/models/SLICOT/motor/motor_run.jl +++ b/models/SLICOT/motor/motor_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "motor_model.jl") -include(@relpath "motor_specifications.jl") +include(@current_path "motor_model.jl") +include(@current_path "motor_specifications.jl") S = motor_model() X0, options = motor_specification() diff --git a/models/SLICOT/pde/pde_model.jl b/models/SLICOT/pde/pde_model.jl index 4204e0bd..172a054c 100644 --- a/models/SLICOT/pde/pde_model.jl +++ b/models/SLICOT/pde/pde_model.jl @@ -8,7 +8,7 @@ using ReachabilityBenchmarks, MathematicalSystems, LazySets, MAT function pde_model() - file = matopen(@relpath "pde.mat") + file = matopen(@current_path "pde.mat") # system matrix A = float(read(file, "A")) # the matrix has Int entries diff --git a/models/SLICOT/pde/pde_run.jl b/models/SLICOT/pde/pde_run.jl index f35e151f..b656e320 100644 --- a/models/SLICOT/pde/pde_run.jl +++ b/models/SLICOT/pde/pde_run.jl @@ -1,7 +1,7 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, Plots -include(@relpath "pde_model.jl") -include(@relpath "pde_specifications.jl") +include(@current_path "pde_model.jl") +include(@current_path "pde_specifications.jl") S = pde_model() X0, options = pde_specification() diff --git a/models/SLICOT/pde/pde_specifications.jl b/models/SLICOT/pde/pde_specifications.jl index dda3689b..ed1ff334 100644 --- a/models/SLICOT/pde/pde_specifications.jl +++ b/models/SLICOT/pde/pde_specifications.jl @@ -9,7 +9,7 @@ function pde_specification() high=[zeros(64); fill(0.0015, 16); fill(-0.0015, 4)]) # safety property: y ā‰¤ 12 for linear combination y (defined in out.mat) - y = read(matopen(@relpath "out.mat"), "M")[1, :] + y = read(matopen(@current_path "out.mat"), "M")[1, :] property = is_contained_in(HalfSpace(y, 12.0)) # time horizon: 20 time units diff --git a/models/SpikingNeuron/spikingNeuron_run.jl b/models/SpikingNeuron/spikingNeuron_run.jl index d38f96f7..804b9d6a 100644 --- a/models/SpikingNeuron/spikingNeuron_run.jl +++ b/models/SpikingNeuron/spikingNeuron_run.jl @@ -1,8 +1,8 @@ using ReachabilityBenchmarks, MathematicalSystems, Reachability, TaylorIntegration, Plots -include(@relpath "spikingNeuron_model.jl") -include(@relpath "spikingNeuron_specifications.jl") +include(@current_path "spikingNeuron_model.jl") +include(@current_path "spikingNeuron_specifications.jl") S = spikingNeuron_model() X0, options = spikingNeuron_specification() diff --git a/src/ReachabilityBenchmarks.jl b/src/ReachabilityBenchmarks.jl index 7880d43c..717bfc68 100644 --- a/src/ReachabilityBenchmarks.jl +++ b/src/ReachabilityBenchmarks.jl @@ -1,13 +1,7 @@ module ReachabilityBenchmarks -# ======== -# Exports -# ======== -export @relpath +using ReachabilityBase.CurrentPath: @current_path -# ================================ -# Input/Output functionality -# ================================ -include("io.jl") +export @current_path -end +end # module diff --git a/src/benchmark_all.jl b/src/benchmark_all.jl index 930e4cfb..ca1da407 100644 --- a/src/benchmark_all.jl +++ b/src/benchmark_all.jl @@ -15,25 +15,25 @@ models = String["motor", "mna5"] # load models and benchmark scripts -model_library = include(@relpath "model_library.jl") +model_library = include(@current_path "model_library.jl") for model in models - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) end -include(@relpath "reach_1D_single.jl") -include(@relpath "reach_1D_all.jl") -include(@relpath "reach_2D_box_two.jl") -include(@relpath "reach_2D_eps_two.jl") -include(@relpath "reach_kD_all.jl") -include(@relpath "check_1D_discrete.jl") -include(@relpath "check_kD_discrete.jl") -include(@relpath "check_1D_dense.jl") -include(@relpath "check_kD_dense.jl") +include(@current_path "reach_1D_single.jl") +include(@current_path "reach_1D_all.jl") +include(@current_path "reach_2D_box_two.jl") +include(@current_path "reach_2D_eps_two.jl") +include(@current_path "reach_kD_all.jl") +include(@current_path "check_1D_discrete.jl") +include(@current_path "check_kD_discrete.jl") +include(@current_path "check_1D_dense.jl") +include(@current_path "check_kD_dense.jl") # create plots (option)? create_plots = true if create_plots - include(@relpath "plot_reach.jl") + include(@current_path "plot_reach.jl") end # run benchmarks diff --git a/src/check_1D_dense.jl b/src/check_1D_dense.jl index 257d093b..aec6de94 100644 --- a/src/check_1D_dense.jl +++ b/src/check_1D_dense.jl @@ -9,9 +9,9 @@ function check_1D_dense(models::Vector{String}, deltas::Vector{Float64}) for model in models if !isdefined(Main, Symbol(model)) if !models_loaded - model_library = include(@relpath "model_library.jl") + model_library = include(@current_path "model_library.jl") end - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) models_loaded = true end diff --git a/src/check_1D_discrete.jl b/src/check_1D_discrete.jl index 7b55e2ff..770231ce 100644 --- a/src/check_1D_discrete.jl +++ b/src/check_1D_discrete.jl @@ -9,9 +9,9 @@ function check_1D_discrete(models::Vector{String}) for model in models if !isdefined(Main, Symbol(model)) if !models_loaded - model_library = include(@relpath "model_library.jl") + model_library = include(@current_path "model_library.jl") end - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) models_loaded = true end diff --git a/src/check_kD_dense.jl b/src/check_kD_dense.jl index 0cf651e8..b51e87ea 100644 --- a/src/check_kD_dense.jl +++ b/src/check_kD_dense.jl @@ -9,9 +9,9 @@ function check_kD_dense(models::Vector{String}, deltas::Vector{Float64}) for model in models if !isdefined(Main, Symbol(model)) if !models_loaded - model_library = include(@relpath "model_library.jl") + model_library = include(@current_path "model_library.jl") end - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) models_loaded = true end diff --git a/src/check_kD_discrete.jl b/src/check_kD_discrete.jl index a64974b9..162af113 100644 --- a/src/check_kD_discrete.jl +++ b/src/check_kD_discrete.jl @@ -9,9 +9,9 @@ function check_kD_discrete(models::Vector{String}) for model in models if !isdefined(Main, Symbol(model)) if !models_loaded - model_library = include(@relpath "model_library.jl") + model_library = include(@current_path "model_library.jl") end - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) models_loaded = true end diff --git a/src/io.jl b/src/io.jl deleted file mode 100644 index 7c6d6185..00000000 --- a/src/io.jl +++ /dev/null @@ -1,45 +0,0 @@ -""" - @relpath(name) - -Return the absolute path to file `name` relative to the executingĀ script. - -### Input - -- `name` -- file name - -### Output - -A string. - -### Notes - -This macro is equivalent to `joinpath(@__DIR__, name)`. - -The `@relpath` macro is used in model scripts to load data files relative to the -location of the model, without having to change the directory of the Julia session. - -For instance, suppose that the folder `/home/projects/models` contains the script -`my_model.jl`, and suppose that the data file `my_data.dat` located in the same -directory is required to be loaded by `my_model.jl`. -Then, - -```julia -# suppose the working directory is /home/julia/ and so we ran the script as -# julia -e "include("../projects/models/my_model.jl")" - -# in the model file /home/projects/models/my_model.jl we write: -d = open(@relpath "my_data.dat") -# do stuff with d -``` -In this example, the macro `@relpath "my_data.dat"` evaluates to the string -`/home/projects/models/my_data.dat`. If the script `my_model.jl` only had -`d = open("my_data.dat")`, without `@relpath`, this command would fail as julia -would have looked for `my_data.dat` in the *working* directory, resulting in an -error that the file `/home/julia/my_data.dat` is not found. -""" -macro relpath(name::String) - __source__.file === nothing && return nothing - _dirname = dirname(String(__source__.file)) - dir = isempty(_dirname) ? pwd() : abspath(_dirname) - return joinpath(dir, name) -end diff --git a/src/reach_1D_all.jl b/src/reach_1D_all.jl index a1df47aa..6c661497 100644 --- a/src/reach_1D_all.jl +++ b/src/reach_1D_all.jl @@ -9,16 +9,16 @@ function reach_1D_all(models::Vector{String}, create_plots::Bool=false) for model in models if !isdefined(Main, Symbol(model)) if !models_loaded - model_library = include(@relpath "model_library.jl") + model_library = include(@current_path "model_library.jl") end - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) models_loaded = true end end plots_loaded = false if create_plots && !isdefined(Main, :plot_reach) - include(@relpath "plot_reach.jl") + include(@current_path "plot_reach.jl") plots_loaded = true end if models_loaded diff --git a/src/reach_1D_single.jl b/src/reach_1D_single.jl index 7e267829..0b28a4fe 100644 --- a/src/reach_1D_single.jl +++ b/src/reach_1D_single.jl @@ -9,16 +9,16 @@ function reach_1D_single(models::Vector{String}, create_plots::Bool=false) for model in models if !isdefined(Main, Symbol(model)) if !models_loaded - model_library = include(@relpath "model_library.jl") + model_library = include(@current_path "model_library.jl") end - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) models_loaded = true end end plots_loaded = false if create_plots && !isdefined(Main, :plot_reach) - include(@relpath "plot_reach.jl") + include(@current_path "plot_reach.jl") plots_loaded = true end if models_loaded diff --git a/src/reach_2D_box_two.jl b/src/reach_2D_box_two.jl index 5ddd4abd..71e74dc3 100644 --- a/src/reach_2D_box_two.jl +++ b/src/reach_2D_box_two.jl @@ -9,16 +9,16 @@ function reach_2D_box_two(models::Vector{String}, create_plots::Bool=false) for model in models if !isdefined(Main, Symbol(model)) if !models_loaded - model_library = include(@relpath "model_library.jl") + model_library = include(@current_path "model_library.jl") end - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) models_loaded = true end end plots_loaded = false if create_plots && !isdefined(Main, :plot_reach) - include(@relpath "plot_reach.jl") + include(@current_path "plot_reach.jl") plots_loaded = true end if models_loaded diff --git a/src/reach_2D_eps_two.jl b/src/reach_2D_eps_two.jl index a20fa6aa..96fdba62 100644 --- a/src/reach_2D_eps_two.jl +++ b/src/reach_2D_eps_two.jl @@ -9,16 +9,16 @@ function reach_2D_eps_two(models::Vector{String}, create_plots::Bool=false) for model in models if !isdefined(Main, Symbol(model)) if !models_loaded - model_library = include(@relpath "model_library.jl") + model_library = include(@current_path "model_library.jl") end - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) models_loaded = true end end plots_loaded = false if create_plots && !isdefined(Main, :plot_reach) - include(@relpath "plot_reach.jl") + include(@current_path "plot_reach.jl") plots_loaded = true end if models_loaded diff --git a/src/reach_kD_all.jl b/src/reach_kD_all.jl index ef1e885b..4548b997 100644 --- a/src/reach_kD_all.jl +++ b/src/reach_kD_all.jl @@ -9,16 +9,16 @@ function reach_kD_all(models::Vector{String}, create_plots::Bool=false) for model in models if !isdefined(Main, Symbol(model)) if !models_loaded - model_library = include(@relpath "model_library.jl") + model_library = include(@current_path "model_library.jl") end - path = (@relpath "../") * model_library[model] + path = (@current_path "../") * model_library[model] include(path) models_loaded = true end end plots_loaded = false if create_plots && !isdefined(Main, :plot_reach) - include(@relpath "plot_reach.jl") + include(@current_path "plot_reach.jl") plots_loaded = true end if models_loaded diff --git a/test/runtests.jl b/test/runtests.jl index d5fb7c61..4c4e0d58 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,8 +1,3 @@ using Test, ReachabilityBenchmarks -@testset "Relative path macro" begin - file = @relpath "my_data.dat" - @test file == joinpath(@__DIR__, "my_data.dat") -end - include("Aqua.jl")