diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index 3e6ff90..8388ff5 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -23,7 +23,7 @@ jobs: - name: Run CompatHelper run: | julia -e 'import CompatHelper; - CompatHelper.main(; subdirs=["", "test", "docs"], + CompatHelper.main(; subdirs=["", "test", "docs", "test/IntervalArithmetic v0.22"], bump_compat_containing_equality_specifier=false)' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/IntervalArithmetic v0.22/Project.toml b/test/IntervalArithmetic v0.22/Project.toml new file mode 100644 index 0000000..c02da25 --- /dev/null +++ b/test/IntervalArithmetic v0.22/Project.toml @@ -0,0 +1,17 @@ +[deps] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +DynamicPolynomials = "7c1d4256-1411-5781-91ec-d7bc3513ac07" +IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253" +RangeEnclosures = "1b4d18b6-9e5d-11e9-236c-f792b01831f8" +SDPA = "b9a10b5b-afa4-512f-a053-bb3d8080febc" +SumOfSquares = "4b9e565b-77fc-50a5-a571-1244f986bda1" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +Aqua = "0.8.9" +Documenter = "0.27, 1" +DynamicPolynomials = "0.3 - 0.6" +IntervalArithmetic = "0.22" +SDPA = "0.2 - 0.6" +SumOfSquares = "0.3.6 - 0.7" diff --git a/test/IntervalArithmetic v0.22/runtests.jl b/test/IntervalArithmetic v0.22/runtests.jl new file mode 100644 index 0000000..2fb5282 --- /dev/null +++ b/test/IntervalArithmetic v0.22/runtests.jl @@ -0,0 +1,3 @@ +global oldIA = false + +include("../runtests.jl") diff --git a/test/paper.jl b/test/paper.jl index c0e5ac3..4aecbcc 100644 --- a/test/paper.jl +++ b/test/paper.jl @@ -10,34 +10,40 @@ struct MyEnclosure end end f(x) = x - @test enclose(f, 0 .. 1, MyEnclosure()) == 1 .. 2 + @test isequal_interval(enclose(f, 0 .. 1, MyEnclosure()), 1 .. 2) end @testset "How to use the package" begin f(x) = -sum(k * x * sin(k * (x - 3) / 3) for k in 1:5) D = -10 .. 10 - @test enclose(f, D, NaturalEnclosure()) == interval(-150, 150) + @test isequal_interval(enclose(f, D, NaturalEnclosure()), interval(-150, 150)) res = enclose(f, D, BranchAndBoundEnclosure()) - @test res isa Interval && inf(res) ≈ -56.42311 && sup(res) ≈ 34.99878 + @test res isa Interval + if oldIA + @test inf(res) ≈ -56.42311 && sup(res) ≈ 34.99878 + else + @test inf(res) ≈ -56.42400 && sup(res) ≈ 34.988386 + end end @testset "Combining different solvers" begin g(x) = x^2 - 2 * x + 1 Dg = 0 .. 4 - @test enclose(g, Dg, NaturalEnclosure()) == interval(-7, 17) - @test enclose(g, Dg, MeanValueEnclosure()) == interval(-11, 13) + @test isequal_interval(enclose(g, Dg, NaturalEnclosure()), interval(-7, 17)) + @test isequal_interval(enclose(g, Dg, MeanValueEnclosure()), interval(-11, 13)) - @test enclose(g, Dg, [NaturalEnclosure(), MeanValueEnclosure()]) == interval(-7, 13) + # TODO combining solvers is currently not supported for IntervalArithmetic v0.22 + @ts @test isequal_interval(enclose(g, Dg, [NaturalEnclosure(), MeanValueEnclosure()]), interval(-7, 13)) end -@testset "Using solvers based on external libraries" begin +@ts @testset "Using solvers based on external libraries" begin g(x) = x^2 - 2 * x + 1 Dg = 0 .. 4 res = enclose(g, Dg, MooreSkelboeEnclosure()) @test res isa Interval && inf(res) ≈ -0.0019195181 && sup(res) ≈ 9.0010805 end -@testset "Multivariate functions" begin +@ts @testset "Multivariate functions" begin h(x) = sin(x[1]) - cos(x[2]) - sin(x[1]) * cos(x[1]) Dh = IntervalBox(-5 .. 5, -5 .. 5) res = enclose(h, Dh, BranchAndBoundEnclosure()) diff --git a/test/runtests.jl b/test/runtests.jl index dab2a22..df1c9b7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,22 +1,51 @@ using Test, RangeEnclosures -using AffineArithmetic, IntervalOptimisation, TaylorModels, SDPA, SumOfSquares +using SDPA, SumOfSquares using DynamicPolynomials: @polyvar -available_solvers = (NaturalEnclosure(), - MeanValueEnclosure(), - AffineArithmeticEnclosure(), - MooreSkelboeEnclosure(), - TaylorModelsEnclosure(), - BranchAndBoundEnclosure()) +global oldIA +if !isdefined(Main, :oldIA) + @show oldIA = true +end + +@static if oldIA + using AffineArithmetic, IntervalOptimisation, TaylorModels + available_solvers = (NaturalEnclosure(), + MeanValueEnclosure(), + AffineArithmeticEnclosure(), + MooreSkelboeEnclosure(), + TaylorModelsEnclosure(), + BranchAndBoundEnclosure()) + + # execute the argument code + macro ts(arg) + quote + $(esc(arg)) + end + end + + isequal_interval = (==) +else + available_solvers = (NaturalEnclosure(), + MeanValueEnclosure(), + BranchAndBoundEnclosure()) + + # skip the argument code + macro ts(arg) end + + using RangeEnclosures: Interval # this is necessary for some reason + using RangeEnclosures.IntervalArithmetic: isequal_interval, inf, sup +end include("univariate.jl") -include("multivariate.jl") +@ts include("multivariate.jl") include("paper.jl") -using Documenter -include("../docs/init.jl") -@testset "doctests" begin - doctest(RangeEnclosures) +@ts begin + using Documenter + include("../docs/init.jl") + @testset "doctests" begin + doctest(RangeEnclosures) + end end include("Aqua.jl") diff --git a/test/univariate.jl b/test/univariate.jl index 9ab07ef..e964b65 100644 --- a/test/univariate.jl +++ b/test/univariate.jl @@ -29,15 +29,17 @@ end rleft, rright = relative_precision(x, xref) @test rleft ≤ 1e-5 && rright ≤ 1e-5 - x = enclose(f, dom, TaylorModelsEnclosure(; order=4)) - xref = interval(-4.2783, 12.7084) - rleft, rright = relative_precision(x, xref) - @test rleft ≤ 1e-5 && rright ≤ 1e-5 + @ts begin + x = enclose(f, dom, TaylorModelsEnclosure(; order=4)) + xref = interval(-4.2783, 12.7084) + rleft, rright = relative_precision(x, xref) + @test rleft ≤ 1e-5 && rright ≤ 1e-5 - x = enclose(f, dom, MooreSkelboeEnclosure()) - xref = interval(4.83299, 10.5448) - rleft, rright = relative_precision(x, xref) - @test rleft ≤ 1e-5 && rright ≤ 1e-5 + x = enclose(f, dom, MooreSkelboeEnclosure()) + xref = interval(4.83299, 10.5448) + rleft, rright = relative_precision(x, xref) + @test rleft ≤ 1e-5 && rright ≤ 1e-5 + end end @testset "Test univariate polynomial input" begin @@ -56,7 +58,7 @@ end @test rleft ≤ 1e-5 && rright ≤ 1e-5 end -@testset "Taylor-model solver without normalization" begin +@ts @testset "Taylor-model solver without normalization" begin f(x) = x^2 - 5x dom = interval(-1, 1) x = enclose(f, dom, TaylorModelsEnclosure(; normalize=false))