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

Interval set type #270

Closed
schillic opened this issue Mar 1, 2018 · 20 comments
Closed

Interval set type #270

schillic opened this issue Mar 1, 2018 · 20 comments
Assignees
Labels
feature ➕ A new feature
Milestone

Comments

@schillic
Copy link
Member

schillic commented Mar 1, 2018

We need:

  • multiply interval vs interval
  • multiply interval vs scalar
  • take Minkowski sum of interval and interval
  • overapproximate (no-op)
  • decompose
@schillic schillic added the feature ➕ A new feature label Mar 1, 2018
@schillic schillic added this to the TAC milestone Mar 1, 2018
@mforets
Copy link
Member

mforets commented Mar 2, 2018

we can approach this by: treating a real interval as a numeric type, and the no-ops can be defined for scalars.

@schillic
Copy link
Member Author

schillic commented Mar 2, 2018

It is not clear to me what you mean by numeric type. Do we want to have BallInf{Interval}?
The no-op can simply be achieved by defining overapproximate(I::Interval) = I.

@mforets
Copy link
Member

mforets commented Mar 2, 2018

i mean to not add a new set type; just use them as scalars. all the operations of above work out of the box; the no-op is overapproximate(x::N) = x where {N <:Real}

@schillic
Copy link
Member Author

schillic commented Mar 2, 2018

But we call overapproximate for sets and the result needs to be a set again.

@mforets
Copy link
Member

mforets commented Mar 2, 2018

well, that is a problem of overloading functions names, overapproximate is doing nothing!

@schillic
Copy link
Member Author

schillic commented Mar 2, 2018

But the result for Reachability is a CartesianProduct of ... intervals, right? For this they must subtype LazySet.

@mforets
Copy link
Member

mforets commented Mar 2, 2018

ultimately we'll see if we hit some issue doing #74

@mforets
Copy link
Member

mforets commented Mar 2, 2018

But the result is a CartesianProduct of ... intervals, right? For this they must subtype LazySet.

point taken. let's do one LazySet extension (wrapper) around an existing interval arithmetic element 👍

@mforets
Copy link
Member

mforets commented Mar 5, 2018

type proposal:

@require IntervalArithmetic begin

import IntervalArithmetic.AbstractInterval

"""
    IA = IntervalArithmetic

Name alias for the interval arithmetic library.
"""
const IA = IntervalArithmetic

export Interval, IA

struct Interval{N, IN <: AbstractInterval{N}} <: AbstractPointSymmetricPolytope{N}
   dat::IN
end
# type-less convenience constructor
Interval{N, IN <: AbstractInterval{N}}(interval::IN) = Interval{N, IN}(interval)
# TODO: adapt show method

end

Questions:

  • is subtyping AbstractPointSymmetricPolytope a good choice?

@schillic
Copy link
Member Author

schillic commented Mar 5, 2018

Looks good. It could also be an AbstractPolygon. Implementing AbstractPointSymmetricPolytope is simpler. Apart from that I do not see any arguments for one choice over the other.

@schillic
Copy link
Member Author

schillic commented Mar 5, 2018

What does dat stand for? Maybe just in or X?

@mforets
Copy link
Member

mforets commented Mar 5, 2018

Looks good. It could also be an AbstractPolygon. Implementing AbstractPointSymmetricPolytope is simpler.

yes, and actually dim(P::AbstractPolygon) = 2 so let's go for AbstractPointSymmetricPolytope.

What does dat stand for?

the field name with the data but we could use another name. should be used only internally.

@schillic
Copy link
Member Author

schillic commented Mar 5, 2018

Is dim(I::Interval) not 2?

@schillic
Copy link
Member Author

schillic commented Mar 5, 2018

Maybe import IntervalArithmetic.AbstractInterval to avoid the namespace stuff.

@mforets
Copy link
Member

mforets commented Mar 5, 2018

think about it as a unidimensional interval over the real line.

the definition in the library is:

abstract type AbstractInterval{T} <: Real end

struct Interval{T<:Real} <: AbstractInterval{T}
    lo :: T
    hi :: T

    function Interval{T}(a::Real, b::Real) where T<:Real

        if validity_check

            if is_valid_interval(a, b)
                new(a, b)

            else
                throw(ArgumentError("Interval of form [$a, $b] not allowed. Must have a ≤ b to construct interval(a, b)."))
            end

        end

        new(a, b)

    end
end

@schillic
Copy link
Member Author

schillic commented Mar 5, 2018

Oh, silly me, it is 1D of course 👍

@mforets
Copy link
Member

mforets commented Mar 5, 2018

i've updated the previous comment within @require block. that type can be used as

julia> using LazySets, IntervalArithmetic
INFO: Precompiling module LazySets.

julia> x = LazySets.Interval(IA.Interval(0.0, 1.0))

LazySets.Interval{Float64,IntervalArithmetic.Interval{Float64}}([0, 1])

what i dislike is that one needs to use the LazySets and IA at each time you create the object, but i don't see another approach.

@schillic
Copy link
Member Author

schillic commented Mar 5, 2018

You can define a type alias for each of them.

const IN = IA.Interval
const ITV = LazySets.Interval

But I agree that this is bogus.
Maybe also add a constructor that takes two numbers.

@mforets
Copy link
Member

mforets commented Mar 5, 2018

Maybe also add a constructor that takes two numbers.

that's a good idea.

@schillic
Copy link
Member Author

schillic commented Mar 5, 2018

And while you are at it, one from a vector :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ➕ A new feature
Projects
None yet
Development

No branches or pull requests

2 participants