Interval
LazySets.Interval
— Type.Interval{N<:Real, IN<:AbstractInterval{N}} <: AbstractHyperrectangle{N}
Type representing an interval on the real line. Mathematically, it is of the form
Fields
dat
– data container for the given interval
Notes
This type relies on the IntervalArithmetic.jl library for representation of intervals and arithmetic operations.
Examples
Unidimensional intervals are symbolic representations of a real closed interval.
We can create intervals in different ways, the simpler way is to pass a pair of numbers:
julia> x = Interval(0.0, 1.0)
Interval{Float64,IntervalArithmetic.Interval{Float64}}([0, 1])
or a 2-vector:
julia> x = Interval([0.0, 1.0])
Interval{Float64,IntervalArithmetic.Interval{Float64}}([0, 1])
Note that if the package IntervalArithmetic
is loaded in the current scope, you have to prepend LazySets.
to the Interval
type since there is a name conflict otherwise.
julia> using IntervalArithmetic
WARNING: using IntervalArithmetic.Interval in module Main conflicts with an existing identifier.
julia> x = Interval(IntervalArithmetic.Interval(0.0, 1.0))
Interval{Float64,IntervalArithmetic.Interval{Float64}}([0, 1])
julia> dim(x)
1
julia> center(x)
1-element Array{Float64,1}:
0.5
This type is such that the usual pairwise arithmetic operators +
, -
, *
trigger the corresponding interval arithmetic backend method, and return a new Interval
object. For the symbolic Minkowksi sum, use MinkowskiSum
or ⊕
.
Interval of other numeric types can be created as well, eg. a rational interval:
julia> Interval(0//1, 2//1)
Interval{Rational{Int64},AbstractInterval{Rational{Int64}}}([0//1, 2//1])
LazySets.dim
— Method.dim(x::Interval)
Return the ambient dimension of an interval.
Input
x
– interval
Output
The integer 1.
LazySets.σ
— Method.σ(d::AbstractVector{N}, x::Interval{N}) where {N<:Real}
Return the support vector of an interval in a given direction.
Input
d
– directionx
– interval
Output
Support vector in the given direction.
LazySets.ρ
— Method.ρ(d::AbstractVector{N}, x::Interval{N}) where {N<:Real}
Evaluate the support function of an interval in a given direction.
Input
d
– directionx
– interval
Output
Evaluation of the support function in the given direction.
Base.:∈
— Method.∈(v::AbstractVector{N}, x::Interval{N}) where {N<:Real})
Return whether a vector is contained in the interval.
Input
v
– one-dimensional vectorx
– interval
Output
true
iff x
contains v
's first component.
Base.:∈
— Method.∈(v::N, x::Interval{N}) where {N<:Real}
Return whether a number is contained in the interval.
Input
v
– scalarx
– interval
Output
true
iff x
contains v
.
LazySets.an_element
— Method.an_element(x::Interval{N}) where {N<:Real}
Return some element of an interval.
Input
x
– interval
Output
The left border (min(x)
) of the interval.
LazySets.vertices_list
— Method.vertices_list(x::Interval{N}) where {N<:Real}
Return the list of vertices of this interval.
Input
x
– interval
Output
The list of vertices of the interval represented as two one-dimensional vectors.
LazySets.translate
— Method.translate(x::Interval{N}, v::AbstractVector{N}) where {N<:Real}
Translate (i.e., shift) an interval by a given vector.
Input
x
– intervalv
– translation vector
Output
A translated interval.
Algorithm
We add the vector to the left and right of the interval.
LazySets.center
— Method.center(x::Interval{N}) where {N<:Real}
Return the interval's center.
Input
x
– interval
Output
The center, or midpoint, of $x$.
Base.min
— Method.min(x::Interval{N}) where {N<:Real}
Return the lower component of an interval.
Input
x
– interval
Output
The lower (lo
) component of the interval.
Base.max
— Method.max(x::Interval{N}) where {N<:Real}
Return the higher or upper component of an interval.
Input
x
– interval
Output
The higher (hi
) component of the interval.
LazySets.low
— Method.low(x::Interval{N}) where {N<:Real}
Return the lower coordinate of an interval set.
Input
x
– interval
Output
A vector with the lower coordinate of the interval.
LazySets.high
— Method.high(x::Interval{N}) where {N<:Real}
Return the higher coordinate of an interval set.
Input
x
– interval
Output
A vector with the higher coordinate of the interval.
LazySets.radius_hyperrectangle
— Method.radius_hyperrectangle(x::Interval{N}) where {N<:Real}
Return the box radius of an interval in every dimension.
Input
x
– interval
Output
The box radius of the interval (a one-dimensional vector).
LazySets.radius_hyperrectangle
— Method.radius_hyperrectangle(x::Interval{N}, i::Int) where {N<:Real}
Return the box radius of an interval in a given dimension.
Input
x
– intervali
– dimension index (must be1
)
Output
The box radius in the given dimension.
Base.:-
— Method.-(x::Interval{N}, y::Interval{N}) where {N<:Real}
Return the difference of the intervals.
Input
x
– intervaly
– interval
Output
The difference of the intervals as a new Interval
set.
Base.:*
— Method. *(x::Interval{N}, y::Interval{N}) where {N<:Real}
Return the product of the intervals.
Input
x
– intervaly
– interval
Output
The product of the intervals as a new Interval
set.
Base.rand
— Method.rand(::Type{Interval}; [N]::Type{<:Real}=Float64, [dim]::Int=2,
[rng]::AbstractRNG=GLOBAL_RNG, [seed]::Union{Int, Nothing}=nothing)
Create a random interval.
Input
Interval
– type for dispatchN
– (optional, default:Float64
) numeric typedim
– (optional, default: 1) dimensionrng
– (optional, default:GLOBAL_RNG
) random number generatorseed
– (optional, default:nothing
) seed for reseeding
Output
A random interval.
Algorithm
All numbers are normally distributed with mean 0 and standard deviation 1.
LazySets.isflat
— Method.isflat(I::Interval)
Determine whether an interval is flat, i.e. whether its extreme values coincide.
Input
I
– interval
Output
A boolean which is true
if the interval is flat and false
otherwise.
Notes
For robustness with respect to floating-point inputs, this function relies on the result of isapproxzero
when applied to the diameter of the interval. Hence, this function depends on the absolute zero tolerance ABSZTOL
.
LazySets.plot_recipe
— Method.plot_recipe(I::Interval{N}, [ε]::N=zero(N)) where {N<:Real}
Convert an interval to a pair (x, y)
of points for plotting.
Input
I
– intervalε
– (optional, default:0
) ignored, used for dispatch
Output
A pair (x, y)
of two points that can be plotted.
Notes
We consider the interval as a line segment with y coordinate equal to zero.
LazySets.linear_map
— Method.linear_map(M::AbstractMatrix{N}, x::Interval{N}) where {N<:Real}
Concrete linear map of an interval.
Input
M
– matrixx
– interval
Output
Either an interval or a zonotope, depending on the leading dimension (i.e. the number of rows) of M
:
- If
size(M, 1) == 1
, the output is an interval obtained by scalingx
by the matrixM
. - If
size(M, 1) > 1
, the output is a zonotope whose center isM * center(x)
and it has the single generator,M * g
, whereg = (high(x)-low(x))/2
.
LazySets.scale
— Method.scale(α::N, x::Interval{N}) where {N<:Real}
Concrete scaling of an interval.
Input
α
– scalarx
– interval
Output
The interval obtained by applying the numerical scale to the given interval.
LazySets.constraints_list
— Method.constraints_list(x::Interval{N}) where {N<:Real}
Return the list of constraints of the given interval.
Input
x
– interval
Output
The list of constraints of the interval represented as two one-dimensional half-spaces.
LazySets.center
— Method.center(H::Interval{N}, i::Int) where {N<:Real}
Return the center along a given dimension of a interval.
Input
x
– intervali
– dimension of interest
Output
The center along a given dimension of the interval.
Inherited from LazySet
:
Inherited from AbstractPolytope
:
Inherited from AbstractCentrallySymmetricPolytope
:
Inherited from AbstractZonotope
:
Inherited from AbstractHyperrectangle
: