From 15db596a4bae2b235b34badfc9dd2de182e6f919 Mon Sep 17 00:00:00 2001 From: Luca Ferranti <49938764+lucaferranti@users.noreply.github.com> Date: Tue, 7 Jun 2022 18:50:18 +0300 Subject: [PATCH 1/3] updated types --- src/RangeEnclosures.jl | 2 +- src/algorithms.jl | 36 ++++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/RangeEnclosures.jl b/src/RangeEnclosures.jl index 06b80eb7..01ed6edb 100644 --- a/src/RangeEnclosures.jl +++ b/src/RangeEnclosures.jl @@ -27,6 +27,6 @@ include("enclose.jl") export enclose, relative_precision, NaturalEnclosure, MooreSkelboeEnclosure, SumOfSquaresEnclosure, TaylorModelsEnclosure, BranchAndBoundEnclosure, - AbstractEnclosureAlgorithm + AbstractEnclosureAlgorithm, AbstractDirectRangeAlgorithm, AbstractIterativeRangeAlgorithm end # module diff --git a/src/algorithms.jl b/src/algorithms.jl index 1081dc04..56a43979 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -6,7 +6,23 @@ Abstract type for range enclosure algorithms. abstract type AbstractEnclosureAlgorithm end """ - NaturalEnclosure <: AbstractEnclosureAlgorithm + AbstractDirectRangeAlgorithm <: AbstractEnclosureAlgorithm + +Abstract type for range enclosures algorithms that directly evaluate the functions over a +given domain. +""" +abstract type AbstractDirectRangeAlgorithm <: AbstractEnclosureAlgorithm end + +""" + AbstractIterativeRangeAlgorithm <: AbstractEnclosureAlgorithm + +Abstract type for algorithms that iteratively bound the range of a function over a given +domain. +""" +abstract type AbstractIterativeRangeAlgorithm <: AbstractEnclosureAlgorithm end + +""" + NaturalEnclosure <: AbstractDirectRangeAlgorithm Data type to bound the range of `f` over `X` using natural enclosure, i.e., to evaluate `f(X)` with interval arithmetic. @@ -18,10 +34,10 @@ julia> enclose(x -> 1 - x^4 + x^5, 0..1, NaturalEnclosure()) [0, 2] ``` """ -struct NaturalEnclosure <: AbstractEnclosureAlgorithm end +struct NaturalEnclosure <: AbstractDirectRangeAlgorithm end """ - MooreSkelboeEnclosure{T} <: AbstractEnclosureAlgorithm + MooreSkelboeEnclosure{T} <: AbstractIterativeRangeAlgorithm Data type to bound the range of `f` over `X` using the Moore-Skelboe algorithm, which rigorously computes the global minimum and maximum of the function. @@ -48,13 +64,13 @@ julia> enclose(x -> 1 - x^4 + x^5, 0..1, MooreSkelboeEnclosure()) # default para julia> enclose(x -> 1 - x^4 + x^5, 0..1, MooreSkelboeEnclosure(; tol=1e-2)) [0.900812, 1.0326] """ -Base.@kwdef struct MooreSkelboeEnclosure{T} <: AbstractEnclosureAlgorithm +Base.@kwdef struct MooreSkelboeEnclosure{T} <: AbstractIterativeRangeAlgorithm structure::T = HeapedVector tol::Float64 = 1e-3 end """ - TaylorModelsEnclosure <: AbstractEnclosureAlgorithm + TaylorModelsEnclosure <: AbstractDirectRangeAlgorithm Data type to bound the range of `f` over `X` using Taylor models. See [`TaylorModels.jl`](https://github.com/JuliaIntervals/TaylorModels.jl) for more details. @@ -77,14 +93,14 @@ julia> enclose(x -> 1 - x^4 + x^5, 0..1, TaylorModelsEnclosure(; order=4)) ``` """ -Base.@kwdef struct TaylorModelsEnclosure <: AbstractEnclosureAlgorithm +Base.@kwdef struct TaylorModelsEnclosure <: AbstractDirectRangeAlgorithm order::Int = 10 normalize::Bool = true end """ - SumOfSquaresEnclosure{T} <: AbstractEnclosureAlgorithm + SumOfSquaresEnclosure{T} <: AbstractIterativeRangeAlgorithm Data type to bound the range of `f` over `X` using sum-of-squares optimization. See [`SumOfSquares.jl`](https://github.com/jump-dev/SumOfSquares.jl) for more details @@ -110,13 +126,13 @@ julia> enclose(x -> -x^3/6 + 5x, 1..4, SumOfSquaresEnclosure(; backend=backend)) [4.8333, 10.541] ``` """ -Base.@kwdef struct SumOfSquaresEnclosure{T} <: AbstractEnclosureAlgorithm +Base.@kwdef struct SumOfSquaresEnclosure{T} <: AbstractIterativeRangeAlgorithm backend::T order::Int = 5 end """ - BranchAndBoundEnclosure + BranchAndBoundEnclosure <: AbstractIterativeRangeAlgorithm Data type to bound the range of `f` over `X` using the branch and bound algorithm. @@ -144,7 +160,7 @@ julia> enclose(x -> -x^3/6 + 5x, 1..4, BranchAndBoundEnclosure()) julia> enclose(x -> -x^3/6 + 5x, 1..4, BranchAndBoundEnclosure(tol=1e-2); df=x->-x^2/2+5) [4.83333, 10.5709] """ -Base.@kwdef struct BranchAndBoundEnclosure <: AbstractEnclosureAlgorithm +Base.@kwdef struct BranchAndBoundEnclosure <: AbstractIterativeRangeAlgorithm maxdepth = 10 tol = 1e-3 end From 5ec4e04f7e96c19b46cc723d8e4d7db62ae97160 Mon Sep 17 00:00:00 2001 From: Luca Ferranti <49938764+lucaferranti@users.noreply.github.com> Date: Tue, 7 Jun 2022 19:51:05 +0300 Subject: [PATCH 2/3] added abstract types to docs --- docs/src/lib/types.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/src/lib/types.md b/docs/src/lib/types.md index e1073e58..03169a05 100644 --- a/docs/src/lib/types.md +++ b/docs/src/lib/types.md @@ -13,6 +13,8 @@ CurrentModule = RangeEnclosures ```@docs AbstractEnclosureAlgorithm +AbstractDirectRangeAlgorithm +AbstractIterativeRangeAlgorithm BranchAndBoundEnclosure NaturalEnclosure MooreSkelboeEnclosure From 69bccad1814e550df4f0b166f5044d54b3329816 Mon Sep 17 00:00:00 2001 From: lucaferranti <49938764+lucaferranti@users.noreply.github.com> Date: Tue, 7 Jun 2022 22:48:55 +0300 Subject: [PATCH 3/3] Update src/algorithms.jl Co-authored-by: Christian Schilling --- src/algorithms.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms.jl b/src/algorithms.jl index 56a43979..43f64774 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -8,7 +8,7 @@ abstract type AbstractEnclosureAlgorithm end """ AbstractDirectRangeAlgorithm <: AbstractEnclosureAlgorithm -Abstract type for range enclosures algorithms that directly evaluate the functions over a +Abstract type for range enclosure algorithms that directly evaluate the functions over a given domain. """ abstract type AbstractDirectRangeAlgorithm <: AbstractEnclosureAlgorithm end