diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..ae70915c --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,29 @@ +name: Format +on: + schedule: + - cron: '0 0 * * 6' # every Saturday at 0:00 +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install JuliaFormatter and format + run: | + julia -e 'import Pkg; Pkg.add("JuliaFormatter")' + julia -e 'using JuliaFormatter; format(".")' + + # https://github.com/marketplace/actions/create-pull-request + # https://github.com/peter-evans/create-pull-request#reference-example + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Format .jl files + title: 'Automatic JuliaFormatter.jl run' + branch: auto-juliaformatter-pr + delete-branch: true + - name: Check outputs + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" diff --git a/benchmark/Daisy/daisy.jl b/benchmark/Daisy/daisy.jl index bfc8d8cf..1a64919a 100644 --- a/benchmark/Daisy/daisy.jl +++ b/benchmark/Daisy/daisy.jl @@ -18,10 +18,10 @@ e = Interval(-10.0, 8.0) f = Interval(1.0, 2.0) # Dictionary to hold the vector of relative precision intervals for each benchmark -RELPREC = Dict{String, Any}() +RELPREC = Dict{String,Any}() # Dictionaries to store data and reference values -DAISY = Dict{String, Any}() +DAISY = Dict{String,Any}() # load functions include("univariate.jl") @@ -40,13 +40,34 @@ for name in keys(DAISY) RESULTS[name]["order $ord"] = BenchmarkGroup() RELPREC[name]["order $ord"] = Dict() - RESULTS[name]["order $ord"]["Taylor Model subs."] = @benchmarkable enclose($func, $dom, :TaylorModels, order=$ord, normalize=false) - RELPREC[name]["order $ord"]["Taylor Model subs."] = relative_precision(enclose(func, dom, :TaylorModels, order=ord, normalize=false), ref) + RESULTS[name]["order $ord"]["Taylor Model subs."] = @benchmarkable enclose($func, $dom, + :TaylorModels, + order=$ord, + normalize=false) + RELPREC[name]["order $ord"]["Taylor Model subs."] = relative_precision(enclose(func, dom, + :TaylorModels; + order=ord, + normalize=false), + ref) - RESULTS[name]["order $ord"]["Normalized Taylor Model subs."] = @benchmarkable enclose($func, $dom, :TaylorModels, order=$ord, normalize=true) - RELPREC[name]["order $ord"]["Normalized Taylor Model subs."] = relative_precision(enclose(func, dom, :TaylorModels, order=ord, normalize=true), ref) + RESULTS[name]["order $ord"]["Normalized Taylor Model subs."] = @benchmarkable enclose($func, + $dom, + :TaylorModels, + order=$ord, + normalize=true) + RELPREC[name]["order $ord"]["Normalized Taylor Model subs."] = relative_precision(enclose(func, + dom, + :TaylorModels; + order=ord, + normalize=true), + ref) - RESULTS[name]["order $ord"]["Interval Arithmetic subs."] = @benchmarkable enclose($func, $dom, :IntervalArithmetic) - RELPREC[name]["order $ord"]["Interval Arithmetic subs."] = relative_precision(enclose(func, dom, :IntervalArithmetic), ref) + RESULTS[name]["order $ord"]["Interval Arithmetic subs."] = @benchmarkable enclose($func, + $dom, + :IntervalArithmetic) + RELPREC[name]["order $ord"]["Interval Arithmetic subs."] = relative_precision(enclose(func, + dom, + :IntervalArithmetic), + ref) end end diff --git a/benchmark/Daisy/multivariate.jl b/benchmark/Daisy/multivariate.jl index 4c97808e..16e703b4 100644 --- a/benchmark/Daisy/multivariate.jl +++ b/benchmark/Daisy/multivariate.jl @@ -1,47 +1,50 @@ # ====================== # Multivariate functions # ====================== -DAISY["himmilbeau"] = Dict("dom" => a×b, - "numvars" => 2, - "vars" => "x1 x2", - "f" => ((x1, x2) -> (x1*x1 + x2 - 11)*(x1 * x1 + x2 - 11) + (x1 + x2*x2 - 7)*(x1 + x2*x2 - 7)), - "ref" => Interval(85.46830677734748, 221.7338939301446) # MOSEK deg 6 - ) +DAISY["himmilbeau"] = Dict("dom" => a × b, + "numvars" => 2, + "vars" => "x1 x2", + "f" => ((x1, x2) -> (x1 * x1 + x2 - 11) * (x1 * x1 + x2 - 11) + + (x1 + x2 * x2 - 7) * (x1 + x2 * x2 - 7)), + "ref" => Interval(85.46830677734748, 221.7338939301446)) -DAISY["kepler1"] = Dict("dom" => a×b×c×d×e×f, - "numvars" => 6, - "vars" => "x1 x2 x3 x4 x5 x6", - "f" => ((x1, x2, x3, x4, x5, x6) -> x2 * x5 + x3 * x6 - x2 * x3 - x5 * x6 + x1 * (-x1 + x2 + x3 - x4 + x5 + x6)), - "ref" => Interval(-5.255935494810441, 7.321362422825775) # MOSEK deg 6 - ) +DAISY["kepler1"] = Dict("dom" => a × b × c × d × e × f, + "numvars" => 6, + "vars" => "x1 x2 x3 x4 x5 x6", + "f" => ((x1, x2, x3, x4, x5, x6) -> x2 * x5 + x3 * x6 - x2 * x3 - x5 * x6 + + x1 * (-x1 + x2 + x3 - x4 + x5 + x6)), + "ref" => Interval(-5.255935494810441, 7.321362422825775)) -DAISY["kepler2"] = Dict("dom" => a×b×c×d, - "numvars" => 4, - "vars" => "x1 x2 x3 x4", - "f" => ((x1, x2, x3, x4) -> x1 * x4 * (-x1 + x2 + x3 - x4) + - x2 * (x1 - x2 + x3 + x4) + x3 * (x1 + x2 - x3 + x4) -x2 * x3 * x4 - x1 * x3 - x1 * x2 - x4), - "ref" => Interval(-195.36974909125482, 78.3669520644375) # MOSEK deg 6 - ) +DAISY["kepler2"] = Dict("dom" => a × b × c × d, + "numvars" => 4, + "vars" => "x1 x2 x3 x4", + "f" => ((x1, x2, x3, x4) -> x1 * x4 * (-x1 + x2 + x3 - x4) + + x2 * (x1 - x2 + x3 + x4) + + x3 * (x1 + x2 - x3 + x4) - x2 * x3 * x4 - + x1 * x3 - x1 * x2 - x4), + "ref" => Interval(-195.36974909125482, 78.3669520644375)) -DAISY["kepler3"] = Dict("dom" => a×b×c×d×e×f, - "numvars" => 6, - "vars" => "x1 x2 x3 x4 x5 x6", - "f" => ((x1, x2, x3, x4, x5, x6) -> x1 * x4 * (-x1 + x2 + x3 - x4 + x5 + x6) + - x2 * x5 * (x1 - x2 + x3 + x4 - x5 + x6) +x3* x6 * (x1 + x2 - x3 + x4 + x5 - x6) - - x2 * x3 * x4 -x1* x3* x5 - x1 * x2 * x6 - x4 * x5 * x6), - "ref" => Interval(-309.8484155131222, 17.982082401462407) # MOSEK deg 6 - ) +DAISY["kepler3"] = Dict("dom" => a × b × c × d × e × f, + "numvars" => 6, + "vars" => "x1 x2 x3 x4 x5 x6", + "f" => ((x1, x2, x3, x4, x5, x6) -> x1 * x4 * + (-x1 + x2 + x3 - x4 + x5 + x6) + + x2 * x5 * + (x1 - x2 + x3 + x4 - x5 + x6) + + x3 * x6 * (x1 + x2 - x3 + x4 + x5 - x6) - + x2 * x3 * x4 - x1 * x3 * x5 - + x1 * x2 * x6 - x4 * x5 * x6), + "ref" => Interval(-309.8484155131222, 17.982082401462407)) -DAISY["Rigidbody1"] = Dict("dom" => a×b×c, - "numvars" => 3, - "vars" => "x1 x2 x3", - "f" => ((x1, x2, x3) -> -x1*x2 - 2*x2*x3 - x1 - x3), - "ref" => Interval(-20.786552979420335, -0.540012836551535) # MOSEK deg 6 - ) +DAISY["Rigidbody1"] = Dict("dom" => a × b × c, + "numvars" => 3, + "vars" => "x1 x2 x3", + "f" => ((x1, x2, x3) -> -x1 * x2 - 2 * x2 * x3 - x1 - x3), + "ref" => Interval(-20.786552979420335, -0.540012836551535)) -DAISY["Rigidbody2"] = Dict("dom" => a×b×c, - "numvars" => 3, - "vars" => "x1 x2 x3", - "f" => ((x1, x2, x3) -> 2*(x1*x2*x3) + (3*x3*x3) - x2*(x1*x2*x3) + (3*x3*x3) - x2), - "ref" => Interval(68.81138021006673, 359.98566570476504) # MOSEK deg 6 - ) +DAISY["Rigidbody2"] = Dict("dom" => a × b × c, + "numvars" => 3, + "vars" => "x1 x2 x3", + "f" => ((x1, x2, x3) -> 2 * (x1 * x2 * x3) + (3 * x3 * x3) - + x2 * (x1 * x2 * x3) + (3 * x3 * x3) - x2), + "ref" => Interval(68.81138021006673, 359.98566570476504)) diff --git a/benchmark/Daisy/univariate.jl b/benchmark/Daisy/univariate.jl index 36af274f..024531db 100644 --- a/benchmark/Daisy/univariate.jl +++ b/benchmark/Daisy/univariate.jl @@ -4,31 +4,26 @@ # (*) can be checked by hand DAISY["sine"] = Dict("dom" => a, - "numvars" => 1, - "f" => (x -> sin(x)), - "ref" => Interval(-1.0, 0.977530117665097) # (*) - ) + "numvars" => 1, + "f" => (x -> sin(x)), + "ref" => Interval(-1.0, 0.977530117665097)) DAISY["bspline0"] = Dict("dom" => a, - "numvars" => 1, - "f" => (x -> (1 - x) * (1 - x) * (1 - x) / 6.0), - "ref" => Interval(0.36616666666666675, 27.729166666666668) # (*) - ) + "numvars" => 1, + "f" => (x -> (1 - x) * (1 - x) * (1 - x) / 6.0), + "ref" => Interval(0.36616666666666675, 27.729166666666668)) DAISY["bspline1"] = Dict("dom" => a, - "numvars" => 1, - "f" => (x -> (3*x*x*x - 6*x*x + 4) / 6.0), - "ref" => Interval(-65.14583333333333, 0.5631666666666667) # (*) - ) + "numvars" => 1, + "f" => (x -> (3 * x * x * x - 6 * x * x + 4) / 6.0), + "ref" => Interval(-65.14583333333333, 0.5631666666666667)) DAISY["bspline2"] = Dict("dom" => a, - "numvars" => 1, - "f" => (x -> (-3*x*x*x + 3*x*x + 3*x + 1) / 6.0), - "ref" => Interval(0.07516666666666667, 53.604166666666664) # (*) - ) + "numvars" => 1, + "f" => (x -> (-3 * x * x * x + 3 * x * x + 3 * x + 1) / 6.0), + "ref" => Interval(0.07516666666666667, 53.604166666666664)) DAISY["bspline3"] = Dict("dom" => a, - "numvars" => 1, - "f" => (x -> -x*x*x / 6.0), - "ref" => Interval(0.0045, 15.1875) # (*) - ) + "numvars" => 1, + "f" => (x -> -x * x * x / 6.0), + "ref" => Interval(0.0045, 15.1875)) diff --git a/docs/make.jl b/docs/make.jl index 82cd3387..995fa414 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,25 +2,17 @@ using Documenter, RangeEnclosures include("init.jl") -makedocs( - sitename = "RangeEnclosures.jl", - modules = [RangeEnclosures], - format = Documenter.HTML( - prettyurls = get(ENV, "CI", nothing) == "true", - assets = ["assets/aligned.css"]), - doctest = false, - strict = true, - pages = [ - "Home" => "index.md", - "Tutorial" => "tutorial.md", - "Library" => Any[ - "Types" => "lib/types.md", - "Methods" => "lib/methods.md"], - "About" => "about.md" - ] -) +makedocs(; sitename="RangeEnclosures.jl", + modules=[RangeEnclosures], + format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true", + assets=["assets/aligned.css"]), + doctest=false, + strict=true, + pages=["Home" => "index.md", + "Tutorial" => "tutorial.md", + "Library" => Any["Types" => "lib/types.md", + "Methods" => "lib/methods.md"], + "About" => "about.md"]) -deploydocs( - repo = "github.com/JuliaReach/RangeEnclosures.jl.git", - push_preview=true -) +deploydocs(; repo="github.com/JuliaReach/RangeEnclosures.jl.git", + push_preview=true)