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

Conflict with states (DifferentialEquations and HybridSystems) #542

Closed
schillic opened this issue Aug 4, 2021 · 0 comments · Fixed by #539
Closed

Conflict with states (DifferentialEquations and HybridSystems) #542

schillic opened this issue Aug 4, 2021 · 0 comments · Fixed by #539
Assignees
Labels
bug Something isn't working

Comments

@schillic
Copy link
Member

schillic commented Aug 4, 2021

Using the model from https://github.com/JuliaReach/ReachabilityAnalysis.jl/blob/5279c0195c2954b96292ba34c853c12c3eaa5d3a/test/models/hybrid/thermostat.jl and initial_condition = X0:

using ReachabilityAnalysis
using HybridSystems, MathematicalSystems, LazySets, LinearAlgebra
using LazySets: HalfSpace  # resolve name-space conflicts with Polyhedra

function thermostat()
    c_a = 0.1

    # automaton structure
    automaton = LightAutomaton(2)

    # mode on
    A = hcat(c_a)
    inv = HalfSpace([1.0], 22.0)  # x ≤ 22
    # @vars x v
    # @set x ≤ 22
    m_on = ConstrainedLinearContinuousSystem(A, inv)

    # mode off
    A = hcat(-c_a)
    inv = HalfSpace([-1.0], -18.0)  # x ≥ 18
    m_off = ConstrainedLinearContinuousSystem(A, inv)

    # modes
    modes = [m_on, m_off]

    # transition from on to off
    add_transition!(automaton, 1, 2, 1)
    guard = HalfSpace([-1.0], -21.0)  # x ≥ 21
    t_on2off = ConstrainedIdentityMap(2, guard)

    # transition from off to on
    add_transition!(automaton, 2, 1, 2)
    guard = HalfSpace([1.0], 19.0)  # x ≤ 19
    t_off2on = ConstrainedIdentityMap(2, guard)

    # transition annotations
    resetmaps = [t_on2off, t_off2on]

    # switching
    switchings = [AutonomousSwitching()]

    ℋ = HybridSystem(automaton, modes, resetmaps, switchings)

    # initial condition
    X0 = Singleton([18.0])
    initial_condition = X0

    return InitialValueProblem(ℋ, initial_condition)
end;

S = thermostat();
T = 5.0;

sol = solve(S, T=T);  # works fine

If we instead first load DifferentialEquations, there is a conflict that leads to a crash:

julia> import DifferentialEquations
julia> using ReachabilityAnalysis

[...]

julia> sol = solve(S, T=T);
WARNING: both DifferentialEquations and HybridSystems export "states"; uses of it in module ReachabilityAnalysis must be qualified
ERROR: UndefVarError: states not defined
@schillic schillic added the bug Something isn't working label Aug 4, 2021
@schillic schillic self-assigned this Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant