Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding benchmark folder #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
28 changes: 28 additions & 0 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
include("examples.jl")
using .OneDimExamples, .TwoDimExamples

using BenchmarkTools
using IntervalArithmetic
using IntervalOptimisation

const SUITE = BenchmarkGroup()


S = SUITE["One dimensional function"] = BenchmarkGroup()

for func in (OneDimExamples.func1, OneDimExamples.func2, OneDimExamples.func3)
s = S[func.title] = BenchmarkGroup()
for Structure in (HeapedVector, SortedVector)
s[string(Structure)] = @benchmarkable minimise($(func.func), $(func.region), structure = $Structure)
end
end


S = SUITE["Two dimensional function"] = BenchmarkGroup()

for func in (TwoDimExamples.Rosenbrock)
s = S[func.title] = BenchmarkGroup()
for Structure in (HeapedVector, SortedVector)
s[string(Structure)] = @benchmarkable minimise($(func.func), $(func.region), structure = $Structure )
end
end
33 changes: 33 additions & 0 deletions benchmark/examples.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Working_function
using IntervalArithmetic

struct Working_func{F<:Function, reg<:Union{Interval, IntervalBox}}
title::String
region::reg
func::F
end

end


module OneDimExamples

using IntervalArithmetic, IntervalOptimisation

import ..Working_function:Working_func
func1 = Working_func("Quadratic equation", (-1..2), x->x*(x-1) )
func2 = Working_func("Cubic equation", (-1..4), x->(x-2)^3-5x )
func3 = Working_func("Quartic equation", (-4..6), x->(x-6)*(x+4)*(7x^2+10x+24) )

end



module TwoDimExamples

using IntervalArithmetic, IntervalOptimisation

import ..Working_function:Working_func
rosenbrock(xx) = ( (x, y) = xx; 100*(y - x)^2 + (x - 1)^2 )
Rosenbrock = Working_func("Rosenbrock function", IntervalBox(-5..5, 2), rosenbrock)
end
3 changes: 1 addition & 2 deletions src/HeapedVectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ function filter_elements!(A::HeapedVector{T}, x::T) where{T}
if length(A.data) == 0
return A
end

heaping(A.data, A.by)
heaping(A.data, A.by)
return A

end
Expand Down