Skip to content

Commit

Permalink
Merge pull request #221 from JuliaReach/schillic/SX
Browse files Browse the repository at this point in the history
Update old SX models
  • Loading branch information
schillic authored Jun 2, 2024
2 parents e42c9d3 + 33801c7 commit 88c3e26
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
15 changes: 7 additions & 8 deletions models/ARCH/AFF/Powertrain/old/runSXDriveTrain.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Drive train example
# ============================

using ReachabilityBenchmarks
using HybridSystems, MathematicalSystems, LazySets, Plots
import SX: is_halfspace, is_hyperplane, convert, parse_sxmath
import Polyhedra
using SpaceExParser: is_halfspace, is_hyperplane, convert, parse_sxmath, Basic, readsxmodel

HS = readsxmodel(@current_path "drivetrain_theta1_5percent_flat_manually.xml")

x1 = parse_sxmath("x1 - -0.0488 == 0.0005600000000000001 * (x4 - 20.0)")
x2 = parse_sxmath("x2 - -15.67 == 0.46699999999999997 * (x4 - 20.0)")
Expand All @@ -15,6 +19,7 @@ x8 = parse_sxmath("x8 - -0.0019199999999999998 == 0.00005999999999999998 * (x4 -
x9 = parse_sxmath("x9 - 20.0 == 1.0 * (x4 - 20.0)")
t = parse_sxmath("t == 0.0")

# initial condition in mode 1
expr_p = parse_sxmath("x1 - -0.0488 == 0.0005600000000000001 * (x4 - 20.0) & x2 - -15.67 == 0.46699999999999997 * (x4 - 20.0) & x3 == 0.0 & x5 == 0.0 & x6 - 20.0 == 1.0 * (x4 - 20.0) & x7 - 240.0 == 12.0 * (x4 - 20.0) & x8 - -0.0019199999999999998 == 0.00005999999999999998 * (x4 - 20.0) & x9 - 20.0 == 1.0 * (x4 - 20.0) & 20.0 <= x4 & x4 <= 40.0 & t == 0.0")
expr = [x1, x2, x3, x4, x5, x6, x7, x8, x9, t]
x0sets = []
Expand All @@ -27,19 +32,13 @@ for expr_i in expr_p
end
end

AFFINE_SYSTEM = ConstrainedLinearControlContinuousSystem
HS = readsxmodel("models/ARCH2018/Drivetrain/drivetrain_theta1_5percent_flat_manually.xml";
raw_dict=true)
# initial condition in mode 1
prob = InitialValueProblem(HS, x0sets)

# calculate reachable states up to time T
prob = InitialValueProblem(HS, x0sets)
input_options = Options(:mode => "reach")

problem_options = Options(:vars => [1, 3, 10], :T => 10.0, => 0.005, :plot_vars => [1, 3],
:verbosity => 1);
options_input = merge(problem_options, input_options)
using Polyhedra
sol = solve(HS, options_input);

plot(sol; indices=1:2:length(sol.Xk))
21 changes: 10 additions & 11 deletions models/FilteredOscillator/SX/runSX_filtered_oscillator.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Drive train example
# Filtered oscillator
# ============================

using ReachabilityBenchmarks
using HybridSystems, MathematicalSystems, LazySets, Plots
import SX: is_halfspace, is_hyperplane, convert, parse_sxmath
import LazySets.HalfSpace
import Polyhedra
using SpaceExParser: is_halfspace, is_hyperplane, convert, parse_sxmath, Basic, readsxmodel

AFFINE_SYSTEM = ConstrainedLinearControlContinuousSystem
HS = readsxmodel(@current_path "filtered_oscillator_flattened.xml"; ST=AFFINE_SYSTEM)

expr_p = parse_sxmath("0.2<=x & x<=0.3 & -0.1<=y & y<=0.1 & z==0 & x1==0 & x2==0 & x3==0")
#expr = [x,y,x1,x2,x3,z]
Expand All @@ -17,18 +21,13 @@ for expr_i in expr_p
end
end

AFFINE_SYSTEM = ConstrainedLinearControlContinuousSystem
HS = readsxmodel("models/SpaceEx/FilteredOscillator/filtered_oscillator_flattened.xml";
ST=AFFINE_SYSTEM)
prob = InitialValueProblem(HS, x0sets)

# calculate reachable states up to time T
prob = InitialValueProblem(HS, x0sets)
input_options = Options(:mode => "reach");

problem_options = Options(:vars => 1:system_dimension, :T => 5.0, => 0.05,
:plot_vars => [1, 2], :max_jumps => 1, :verbosity => 1, :init_loc => 3);
problem_options = Options(:vars => 1:system_dimension, :T => 5.0, => 0.05, :plot_vars => [1, 2],
:max_jumps => 1, :verbosity => 1, :init_loc => 3);
options_input = merge(problem_options, input_options)
using Polyhedra
sol = solve(prob, options_input);

plot(sol; indices=1:2:length(sol.Xk))

0 comments on commit 88c3e26

Please sign in to comment.