Skip to content

Commit

Permalink
Merge pull request #126 from JuliaReach/schillic/IA
Browse files Browse the repository at this point in the history
IntervalArithmetic v0.21, unexport libraries, v2.0
  • Loading branch information
schillic authored Aug 25, 2023
2 parents daf4ec3 + c4fb475 commit 408249b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 22 deletions.
6 changes: 2 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
name = "RangeEnclosures"
uuid = "1b4d18b6-9e5d-11e9-236c-f792b01831f8"
version = "0.1.4"
version = "0.2.0"

[deps]
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
ReachabilityBase = "379f33d0-9447-4353-bd03-d664070e549f"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]
ForwardDiff = "0.10"
IntervalArithmetic = "0.15 - 0.20"
IntervalArithmetic = "0.15 - 0.21"
ReachabilityBase = "0.1.1 - 0.2"
Reexport = "0.2, 1"
Requires = "0.5, 1"
julia = "1.6"
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
IntervalOptimisation = "c7c68f13-a4a2-5b9a-b424-07d005f8d9d2"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
3 changes: 3 additions & 0 deletions docs/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ Rh = enclose(h, Dh, BranchAndBoundEnclosure())
```

We can visualize the result with the following script.
For this we use the API of `IntervalArithmetic`, which must be loaded first.

```@example tutorial
using IntervalArithmetic
x = y = -5:0.1:5
f(x, y) = h([x, y])
plot(legend=:none, size=(800, 800), xlabel="x", ylabel="y", zlabel="h(x,y)",
Expand Down
12 changes: 7 additions & 5 deletions src/RangeEnclosures.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module RangeEnclosures

using Requires, Reexport
@reexport using ForwardDiff

@reexport using IntervalArithmetic
using Requires
using ForwardDiff
using IntervalArithmetic
const Interval_or_IntervalBox = Union{Interval,IntervalBox}

using ReachabilityBase.Require

include("algorithms.jl")
Expand Down Expand Up @@ -44,4 +42,8 @@ export enclose,
TaylorModelsEnclosure,
BranchAndBoundEnclosure

# standard ways from IntervalArithmetic to create intervals
export interval, ..,
IntervalBox

end # module
15 changes: 12 additions & 3 deletions test/multivariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ end
# Note: DynamicPolynomials automatically expands p, and evaluation using
# interval arithmetic gives a worse left bound than the factored expression.

x = enclose(p, dom, SumOfSquaresEnclosure(; backend=SDPA.Optimizer))
@test isapprox(inf(x), 0.0; atol=1e-3)
@test isapprox(sup(x), 670.612; atol=1e-3)
if Sys.iswindows()
# SDPA is broken on Windows
@test_broken begin
x = enclose(p, dom, SumOfSquaresEnclosure(; backend=SDPA.Optimizer))
isapprox(inf(x), 0.0; atol=1e-3)
isapprox(sup(x), 670.612; atol=1e-3)
end
else
x = enclose(p, dom, SumOfSquaresEnclosure(; backend=SDPA.Optimizer))
@test isapprox(inf(x), 0.0; atol=1e-3)
@test isapprox(sup(x), 670.612; atol=1e-3)
end
end

@testset "Taylor-model solver without normalization" begin
Expand Down
20 changes: 14 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
using IntervalOptimisation, TaylorModels, Test, RangeEnclosures, SumOfSquares, SDPA,
AffineArithmetic
using Test, RangeEnclosures
using AffineArithmetic, IntervalOptimisation, TaylorModels, SumOfSquares

@static if Sys.iswindows()
@test_broken using SDPA
else
using SDPA
end

using DynamicPolynomials: @polyvar

Expand All @@ -13,8 +19,10 @@ available_solvers = (NaturalEnclosure(),
include("univariate.jl")
include("multivariate.jl")

using Documenter
include("../docs/init.jl")
@time @testset "doctests" begin
doctest(RangeEnclosures)
@static if !Sys.iswindows() # broken due to SDPA
using Documenter
include("../docs/init.jl")
@time @testset "doctests" begin
doctest(RangeEnclosures)
end
end
18 changes: 14 additions & 4 deletions test/univariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,20 @@ end
rleft, rright = relative_precision(x, xref)
@test rleft 1e-5 && rright 1e-5

x = enclose(p, dom, SumOfSquaresEnclosure(; backend=SDPA.Optimizer))
xref = Interval(4.8333, 10.541)
rleft, rright = relative_precision(x, xref)
@test rleft 1e-5 && rright 1e-5
if Sys.iswindows()
# SDPA is broken on Windows
@test_broken begin
x = enclose(p, dom, SumOfSquaresEnclosure(; backend=SDPA.Optimizer))
xref = Interval(4.8333, 10.541)
rleft, rright = relative_precision(x, xref)
rleft 1e-5 && rright 1e-5
end
else
x = enclose(p, dom, SumOfSquaresEnclosure(; backend=SDPA.Optimizer))
xref = Interval(4.8333, 10.541)
rleft, rright = relative_precision(x, xref)
@test rleft 1e-5 && rright 1e-5
end
end

@testset "Taylor-model solver without normalization" begin
Expand Down

2 comments on commit 408249b

@schillic
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/90287

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 408249b030422ec1747100d05e31a8fe1fbee158
git push origin v0.2.0

Please sign in to comment.