Skip to content

Commit

Permalink
Merge pull request #3378 from JuliaReach/schillic/bump
Browse files Browse the repository at this point in the history
IntervalArithmetic v0.21 (and RangeEnclosures v0.2 in tests)
  • Loading branch information
schillic authored Aug 26, 2023
2 parents 55965d5 + e662ea1 commit 78b6a52
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"

[compat]
GLPK = "0.11 - 0.15, 1"
IntervalArithmetic = "0.15 - 0.20"
IntervalArithmetic = "0.15 - 0.21"
JuMP = "0.21 - 0.23, 1"
ReachabilityBase = "0.2"
RecipesBase = "0.6 - 0.8, 1"
Expand Down
2 changes: 1 addition & 1 deletion src/Approximations/overapproximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ function overapproximate(P::SimpleSparsePolynomialZonotope,
::Type{<:UnionSetArray{Zonotope}};
nsdiv=10, partition=nothing)
q = nparams(P)
dom = IA.IntervalBox(IA.Interval(-1, 1), q)
dom = IA.IntervalBox(IA.interval(-1, 1), q)
cells = IA.mince(dom, isnothing(partition) ? nsdiv : partition)
return UnionSetArray([overapproximate(P, Zonotope, c) for c in cells])
end
Expand Down
18 changes: 9 additions & 9 deletions src/Approximations/overapproximate_zonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ A zonotope.
"""
function overapproximate(P::SimpleSparsePolynomialZonotope, ::Type{<:Zonotope},
dom::IA.IntervalBox)
@assert dom IA.IntervalBox(IA.Interval(-1, 1), nparams(P)) "dom should " *
@assert dom IA.IntervalBox(IA.interval(-1, 1), nparams(P)) "dom should " *
"be a subset of [-1, 1]^q"

G = genmat(P)
Expand All @@ -276,7 +276,7 @@ function overapproximate(P::SimpleSparsePolynomialZonotope, ::Type{<:Zonotope},
@inbounds for (j, g) in enumerate(eachcol(G))
# monomial value over the domain
# α = mapreduce(x -> _fast_interval_pow(x[1], x[2]), *, zip(dom, E[:, i]))
α = IA.Interval(1, 1)
α = IA.interval(1, 1)
for (i, vi) in enumerate(dom)
α *= fast_interval_pow(vi, E[i, j])
end
Expand Down Expand Up @@ -409,13 +409,13 @@ function load_taylormodels_overapproximation()
julia> const IA = IntervalArithmetic;
julia> I = IA.Interval(-0.5, 0.5) # interval remainder
julia> I = IA.interval(-0.5, 0.5) # interval remainder
[-0.5, 0.5]
julia> x₀ = IA.Interval(0.0) # expansion point
julia> x₀ = IA.interval(0.0) # expansion point
[0, 0]
julia> D = IA.Interval(-3.0, 1.0)
julia> D = IA.interval(-3.0, 1.0)
[-3, 1]
julia> p1 = Taylor1([2.0, 1.0], 2) # define a linear polynomial
Expand Down Expand Up @@ -570,19 +570,19 @@ function load_taylormodels_overapproximation()
1.0 x₁ + 𝒪(‖x‖⁹)
1.0 x₂ + 𝒪(‖x‖⁹)
julia> x₀ = IntervalBox(0..0, 2) # expansion point
julia> x₀ = IA.IntervalBox(0..0, 2) # expansion point
[0, 0]²
julia> Dx₁ = IA.Interval(0.0, 3.0) # domain for x₁
julia> Dx₁ = IA.interval(0.0, 3.0) # domain for x₁
[0, 3]
julia> Dx₂ = IA.Interval(-1.0, 1.0) # domain for x₂
julia> Dx₂ = IA.interval(-1.0, 1.0) # domain for x₂
[-1, 1]
julia> D = Dx₁ × Dx₂ # take the Cartesian product of the domain on each variable
[0, 3] × [-1, 1]
julia> r = IA.Interval(-0.5, 0.5) # interval remainder
julia> r = IA.interval(-0.5, 0.5) # interval remainder
[-0.5, 0.5]
julia> p1 = 1 + x₁^2 - x₂
Expand Down
2 changes: 1 addition & 1 deletion src/ConcreteOperations/difference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ confused with the *set difference*. For example,
julia> X = Interval(0, 2); Y = Interval(1, 4);
julia> X \\ Y # computing the set difference
Interval{Float64, IntervalArithmetic.Interval{Float64}}([0, 1])
Interval{Float64}([0, 1])
julia> X.dat \\ Y.dat # computing the left division
[0.5, ∞]
Expand Down
6 changes: 3 additions & 3 deletions src/Initialization/init_IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ function fast_interval_pow(a::IA.Interval, n::Int)
if iszero(n)
return one(a)
elseif isodd(n)
return IA.Interval(a.lo^n, a.hi^n)
return IA.interval(a.lo^n, a.hi^n)
else
if 0 a
return IA.Interval(zero(a.lo), max(abs(a.lo), abs(a.hi))^n)
return IA.interval(zero(a.lo), max(abs(a.lo), abs(a.hi))^n)
else
lon = a.lo^n
hin = a.hi^n
return IA.Interval(min(lon, hin), max(lon, hin))
return IA.interval(min(lon, hin), max(lon, hin))
end
end
end
2 changes: 1 addition & 1 deletion src/LazyOperations/CartesianProduct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ julia> I2 = Interval(2, 4);
julia> I12 = I1 × I2;
julia> typeof(I12)
CartesianProduct{Float64, Interval{Float64, IntervalArithmetic.Interval{Float64}}, Interval{Float64, IntervalArithmetic.Interval{Float64}}}
CartesianProduct{Float64, Interval{Float64}, Interval{Float64}}
```
A hyperrectangle is the Cartesian product of intervals, so we can convert `I12`
to a `Hyperrectangle` type:
Expand Down
2 changes: 1 addition & 1 deletion src/LazySets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using LinearAlgebra, RecipesBase, Reexport, Requires, SparseArrays
import GLPK, JuMP, Random, ReachabilityBase
import IntervalArithmetic as IA

using IntervalArithmetic: AbstractInterval, mince
using IntervalArithmetic: mince
import IntervalArithmetic: radius,
using LinearAlgebra: checksquare
import LinearAlgebra: norm, ×, normalize, normalize!
Expand Down
22 changes: 11 additions & 11 deletions src/Sets/Interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export Interval,
constraints_list

"""
Interval{N, IN<:AbstractInterval{N}} <: AbstractHyperrectangle{N}
Interval{N} <: AbstractHyperrectangle{N}
Type representing an interval on the real line.
Mathematically, it is of the form
Expand Down Expand Up @@ -36,13 +36,13 @@ of numbers:
```jldoctest interval_constructor
julia> x = Interval(0.0, 1.0)
Interval{Float64, IntervalArithmetic.Interval{Float64}}([0, 1])
Interval{Float64}([0, 1])
```
A 2-vector is also possible:
```jldoctest interval_constructor
julia> x = Interval([0.0, 1.0])
Interval{Float64, IntervalArithmetic.Interval{Float64}}([0, 1])
Interval{Float64}([0, 1])
```
An interval can also be constructed from an `IntervalArithmetic.Interval`.
Expand All @@ -55,7 +55,7 @@ julia> using IntervalArithmetic
WARNING: using IntervalArithmetic.Interval in module Main conflicts with an existing identifier.
julia> x = LazySets.Interval(IntervalArithmetic.Interval(0.0, 1.0))
Interval{Float64, IntervalArithmetic.Interval{Float64}}([0, 1])
Interval{Float64}([0, 1])
julia> dim(x)
1
Expand All @@ -74,23 +74,23 @@ interval:
```jldoctest interval_constructor
julia> Interval(0//1, 2//1)
Interval{Rational{Int64}, IntervalArithmetic.Interval{Rational{Int64}}}([0//1, 2//1])
Interval{Rational{Int64}}([0//1, 2//1])
```
"""
struct Interval{N,IN<:AbstractInterval{N}} <: AbstractHyperrectangle{N}
dat::IN
struct Interval{N} <: AbstractHyperrectangle{N}
dat::IA.Interval{N}

function Interval(dat::IN) where {N,IN<:AbstractInterval{N}}
function Interval(dat::IA.Interval{N}) where {N}
@assert isfinite(dat.lo) && isfinite(dat.hi) "intervals must be bounded"

return new{N,IN}(dat)
return new{N}(dat)
end
end

# constructor from two numbers with type promotion
function Interval(lo::N1, hi::N2) where {N1,N2}
N = promote_type(N1, N2)
return Interval(IA.Interval(N(lo), N(hi)))
return Interval(IA.interval(N(lo), N(hi)))
end

# constructor from a vector
Expand All @@ -102,7 +102,7 @@ end

# constructor from a single number
function Interval(x::Real)
return Interval(IA.Interval(x))
return Interval(IA.interval(x))
end

isoperationtype(::Type{<:Interval}) = false
Expand Down
4 changes: 2 additions & 2 deletions src/Sets/SparsePolynomialZonotope.jl
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ function _load_rho_range_enclosures()

f(x) = sum(d' * gi * prod(x .^ ei) for (gi, ei) in zip(eachcol(G), eachcol(E)))

dom = IA.IntervalBox(IA.Interval(-1, 1), n)
res += sup(enclose(f, dom, method))
dom = IA.IntervalBox(IA.interval(-1, 1), n)
res += IA.sup(enclose(f, dom, method))
return res
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ An interval.
```jldoctest
julia> convert(Interval, Hyperrectangle([0.5], [0.5]))
Interval{Float64, IntervalArithmetic.Interval{Float64}}([0, 1])
Interval{Float64}([0, 1])
```
"""
function convert(::Type{Interval}, X::LazySet)
Expand Down
10 changes: 5 additions & 5 deletions test/Approximations/overapproximate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,12 @@ for N in [Float64]
# Zonotope overapprox. of a Taylor model
# =======================================
x₁, x₂, x₃ = set_variables(N, ["x₁", "x₂", "x₃"]; order=5)
Dx₁ = IA.Interval(N(1.0), N(3.0))
Dx₂ = IA.Interval(N(-1.0), N(1.0))
Dx₃ = IA.Interval(N(-1.0), N(0.0))
Dx₁ = interval(N(1.0), N(3.0))
Dx₂ = interval(N(-1.0), N(1.0))
Dx₃ = interval(N(-1.0), N(0.0))
D = Dx₁ × Dx₂ × Dx₃ # domain
x0 = IntervalBox(IA.mid.(D)...)
I = IA.Interval(N(0.0), N(0.0)) # interval remainder
I = interval(N(0.0), N(0.0)) # interval remainder
p₁ = 1 + x₁ - x₂
p₂ = x₃ - x₁
vTM = [TaylorModels.TaylorModelN(pi, I, x0, D) for pi in [p₁, p₂]]
Expand Down Expand Up @@ -515,7 +515,7 @@ for N in [Float64]

# NOTE: ICP currently leads to unsatisfiable package requirements
# overapproximate a nonlinear constraint with an HPolyhedron
# dom = IntervalBox(IA.Interval(-2, 2), IA.Interval(-2, 2))
# dom = IntervalBox(interval(-2, 2), interval(-2, 2))
# C = @constraint x^2 + y^2 <= 1
# p = pave(C, dom, 0.01)
# dirs = OctDirections(2)
Expand Down
4 changes: 2 additions & 2 deletions test/ConcreteOperations/isdisjoint.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
for N in [Float64, Float32, Rational{Int}]
# using IA types
X = IA.interval(N(0), N(1)) # IA
X = interval(N(0), N(1)) # IA
Y = Interval(N(-1), N(2))
Z = Interval(N(2), N(3))
res, w = isdisjoint(X, Y, true)
@test !isdisjoint(X, Y) && !isdisjoint(Y, X) && !res && w Interval(X) && w Y
res, w = isdisjoint(X, Z, true)
@test isdisjoint(X, Z) && isdisjoint(Z, X) && res && w == N[]

X = IntervalBox(IA.interval(N(0), N(1)), IA.interval(N(0), N(1)))
X = IntervalBox(interval(N(0), N(1)), interval(N(0), N(1)))
Y = Hyperrectangle(; low=[N(-1), N(-1)], high=[N(2), N(2)])
@test !isdisjoint(X, Y)
@test !isdisjoint(Y, X)
Expand Down
4 changes: 2 additions & 2 deletions test/ConcreteOperations/issubset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ for N in [Float64, Float32, Rational{Int}]
end

# using IA types
X = IA.interval(N(0), N(1)) # IA
X = interval(N(0), N(1)) # IA
Y = Interval(N(-1), N(2))
@test X Y
@test !(Y X)

X = IntervalBox(IA.interval(N(0), N(1)), IA.interval(N(0), N(1)))
X = IntervalBox(interval(N(0), N(1)), interval(N(0), N(1)))
Y = Hyperrectangle(; low=[N(-1), N(-1)], high=[N(2), N(2)])
@test X Y
@test !(Y X)
Expand Down
4 changes: 2 additions & 2 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Expokit = "0.2"
ExponentialUtilities = "1"
GLPK = "0.11 - 0.15, 1"
GR = "0"
IntervalArithmetic = "0.15 - 0.20"
IntervalArithmetic = "0.15 - 0.21"
IntervalMatrices = "0.8"
Ipopt = "1"
Javis = "0.5 - 0.9"
Expand All @@ -47,7 +47,7 @@ MiniQhull = "0.1 - 0.4"
Optim = "0.15 - 0.22, 1"
PkgVersion = "0.3"
Polyhedra = "0.6 - 0.7"
RangeEnclosures = "0.1.1"
RangeEnclosures = "0.1.1, 0.2"
RecipesBase = "0.6 - 0.8, 1"
SCS = "1"
SetProg = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions test/Sets/Hyperrectangle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ for N in [Float64, Rational{Int}, Float32]
HalfSpace(N[-1, 0], N(1)), HalfSpace(N[0, -1], N(1))])

# conversion to and from IntervalArithmetic's IntervalBox type
B = IntervalBox(IA.Interval(0, 1), IA.Interval(0, 1))
B = IntervalBox(interval(0, 1), interval(0, 1))
H = convert(Hyperrectangle, B)
@test convert(IntervalBox, H) == B

# conversion to and from IntervalArithmetic's Interval type
I = IA.Interval(0, 1)
I = interval(0, 1)
H = convert(Hyperrectangle, I)
@test convert(IA.Interval, H) == I

Expand Down
4 changes: 2 additions & 2 deletions test/Sets/Interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ for N in [Float64, Float32, Rational{Int}]
rand(Interval)

# constructor from IntervalArithmetic.Interval
x = Interval(IA.Interval(N(0), N(1)))
x = Interval(interval(N(0), N(1)))

# constructor from a vector
x = Interval(N[0, 1])
Expand Down Expand Up @@ -220,7 +220,7 @@ for N in [Float64, Float32, Rational{Int}]
@test rectify(x) == x

# list of vertices of IA types
b = IA.IntervalBox(IA.Interval(0, 1), IA.Interval(0, 1))
b = IntervalBox(interval(0, 1), interval(0, 1))
vlistIB = vertices_list(b)
@test is_cyclic_permutation(vlistIB,
[SA[N(1), N(1)], SA[N(0), N(1)], SA[N(1), N(0)], SA[N(0), N(0)]])
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Random.seed!(1234)
import Distributions, ExponentialUtilities, Expokit, IntervalMatrices, Ipopt,
MiniQhull, Optim, PkgVersion, RangeEnclosures, SCS, SetProg, TaylorModels
import IntervalArithmetic as IA
using IntervalArithmetic: IntervalBox
using IntervalArithmetic: IntervalBox, interval
using IntervalMatrices: ±, IntervalMatrix
using TaylorModels: set_variables, TaylorModelN
# ICP currently leads to unsatisfiable package requirements
Expand Down

0 comments on commit 78b6a52

Please sign in to comment.