From 6e83dcd7655b9d78d0905adc943621323a2296f3 Mon Sep 17 00:00:00 2001 From: Luca Ferranti <49938764+lucaferranti@users.noreply.github.com> Date: Mon, 13 Jun 2022 12:07:09 +0300 Subject: [PATCH 1/4] added mean value form --- src/RangeEnclosures.jl | 2 +- src/algorithms.jl | 9 +++++++++ src/intervals.jl | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/RangeEnclosures.jl b/src/RangeEnclosures.jl index 01ed6edb..2706ce21 100644 --- a/src/RangeEnclosures.jl +++ b/src/RangeEnclosures.jl @@ -25,7 +25,7 @@ API include("enclose.jl") export enclose, relative_precision, - NaturalEnclosure, MooreSkelboeEnclosure, SumOfSquaresEnclosure, + MeanValueEnclosure, NaturalEnclosure, MooreSkelboeEnclosure, SumOfSquaresEnclosure, TaylorModelsEnclosure, BranchAndBoundEnclosure, AbstractEnclosureAlgorithm, AbstractDirectRangeAlgorithm, AbstractIterativeRangeAlgorithm diff --git a/src/algorithms.jl b/src/algorithms.jl index 43f64774..ebabc422 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -36,6 +36,15 @@ julia> enclose(x -> 1 - x^4 + x^5, 0..1, NaturalEnclosure()) """ struct NaturalEnclosure <: AbstractDirectRangeAlgorithm end +""" + MeanValueEnclosure + +Data type to bound the range of `f` over `X` using the mean value form, that is the range +is bounded by the expression ``f(Xc) + f'(X) * (X - Xc)``. Where `Xc` is the midpoint of `X` +and `f'` is the derivative / gradient of `f`. +""" +struct MeanValueEnclosure <: AbstractDirectRangeAlgorithm end + """ MooreSkelboeEnclosure{T} <: AbstractIterativeRangeAlgorithm diff --git a/src/intervals.jl b/src/intervals.jl index 2564104c..3b849d14 100644 --- a/src/intervals.jl +++ b/src/intervals.jl @@ -5,3 +5,13 @@ Methods using Interval Arithmetic function _enclose(::NaturalEnclosure, f::Function, dom::Interval_or_IntervalBox; kwargs...) return f(dom...) end + +function _enclose(::MeanValueEnclosure, f::Function, dom::Interval; + df=Base.Fix1(ForwardDiff.derivative, f)) + return f(mid(dom)) + df(dom) * (dom - mid(dom)) +end + +function _enclose(::MeanValueEnclosure, f::Function, dom::IntervalBox; + df=t->ForwardDiff.gradient(w->f(w...), t.v)) + return f(mid.(dom)...) + dot(df(dom), dom - mid.(dom)) +end From 08187115b04a2dd3a5336b0a22d554ec089b000e Mon Sep 17 00:00:00 2001 From: Luca Ferranti <49938764+lucaferranti@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:28:52 +0300 Subject: [PATCH 2/4] 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 ebabc422..ba0f011a 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -40,7 +40,7 @@ struct NaturalEnclosure <: AbstractDirectRangeAlgorithm end MeanValueEnclosure Data type to bound the range of `f` over `X` using the mean value form, that is the range -is bounded by the expression ``f(Xc) + f'(X) * (X - Xc)``. Where `Xc` is the midpoint of `X` +is bounded by the expression ``f(Xc) + f'(X) * (X - Xc)``, where `Xc` is the midpoint of `X` and `f'` is the derivative / gradient of `f`. """ struct MeanValueEnclosure <: AbstractDirectRangeAlgorithm end From bbcb2d83bd53cc54fcf627ca2bb2b9812c318fd6 Mon Sep 17 00:00:00 2001 From: Luca Ferranti <49938764+lucaferranti@users.noreply.github.com> Date: Tue, 14 Jun 2022 12:31:11 +0300 Subject: [PATCH 3/4] add MeanValueEnclosure to docs --- docs/src/lib/types.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/lib/types.md b/docs/src/lib/types.md index 03169a05..cfd01daf 100644 --- a/docs/src/lib/types.md +++ b/docs/src/lib/types.md @@ -17,6 +17,7 @@ AbstractDirectRangeAlgorithm AbstractIterativeRangeAlgorithm BranchAndBoundEnclosure NaturalEnclosure +MeanValueEnclosure MooreSkelboeEnclosure SumOfSquaresEnclosure TaylorModelsEnclosure From a067f3be10f1ccbd8b72f4ba9d76c6d5e1d470c8 Mon Sep 17 00:00:00 2001 From: Luca Ferranti <49938764+lucaferranti@users.noreply.github.com> Date: Wed, 15 Jun 2022 16:38:44 +0300 Subject: [PATCH 4/4] Update src/algorithms.jl Co-authored-by: Marcelo Forets --- src/algorithms.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms.jl b/src/algorithms.jl index ba0f011a..aa6d36a5 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -41,7 +41,7 @@ struct NaturalEnclosure <: AbstractDirectRangeAlgorithm end Data type to bound the range of `f` over `X` using the mean value form, that is the range is bounded by the expression ``f(Xc) + f'(X) * (X - Xc)``, where `Xc` is the midpoint of `X` -and `f'` is the derivative / gradient of `f`. +and `f'` is the derivative of `f` (gradient in the multivariate case). """ struct MeanValueEnclosure <: AbstractDirectRangeAlgorithm end