diff --git a/src/algorithms.jl b/src/algorithms.jl index 405b0a6f..663dcd00 100644 --- a/src/algorithms.jl +++ b/src/algorithms.jl @@ -195,5 +195,6 @@ julia> enclose(x -> -x^3/6 + 5x, 1..4, BranchAndBoundEnclosure(tol=1e-2); df=x-> """ Base.@kwdef struct BranchAndBoundEnclosure <: AbstractIterativeRangeAlgorithm maxdepth = 10 - tol = 1e-3 + atol = 1e-6 + rtol = 1e-3 end diff --git a/src/branchandbound.jl b/src/branchandbound.jl index 5baf54fd..a46a6de1 100644 --- a/src/branchandbound.jl +++ b/src/branchandbound.jl @@ -19,7 +19,8 @@ function _branch_bound(bab::BranchAndBoundEnclosure, f::Function, X::Interval_or fX = f(X) # TODO: allow user to choose how to evaluate this (mean value, natural enclosure) # if tolerance or maximum number of iteration is met, return current enclosure - if diam(fX) <= bab.tol || cnt == bab.maxdepth + min_abs = in_interval(0, fX) ? zero(fX.lo) : min(abs(fX.lo), abs(fX.hi)) + if diam(fX) <= max(bab.atol, bab.rtol * min_abs) || cnt == bab.maxdepth return hull(fX, initial) end