Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ the interval/interval box.
The algorithm also looks at the sign of the derivative / gradient to see if the range can be
computed directly. By default, the derivative / gradient is computed using `ForwardDiff.jl`,
but a custom value can be passed via the `df` keyword argument to [`enclose`](@ref).
Pass `df = nothing` to avoid computing any derivatives.

### Examples

Expand Down
8 changes: 5 additions & 3 deletions src/branchandbound.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ end
function _branch_bound(bab::BranchAndBoundEnclosure, f::Function, X::Interval_or_IntervalBox, df;
initial=emptyinterval(first(X)),
cnt=1)
dfX = df(X)
range_extrema, flag = _monotonicity_check(f, X, dfX)
flag && return hull(range_extrema, initial)
if !isnothing(df)
dfX = df(X)
range_extrema, flag = _monotonicity_check(f, X, dfX)
flag && return hull(range_extrema, initial)
end

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
Expand Down
4 changes: 4 additions & 0 deletions test/univariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ end
x = enclose(f, dom, BranchAndBoundEnclosure())
rleft, rright = relative_precision(x, xref)
@test rleft ≈ 0 && 2.04e-14 ≤ rright ≤ 2.05e-14

x = enclose(f, dom, BranchAndBoundEnclosure(), df=nothing)
rleft, rright = relative_precision(x, xref)
@test rleft ≈ 0 && 2.04e-14 ≤ rright ≤ 2.05e-14
end