You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Adding HeapedVector.jl and adding benchmarks
* trying to import Strategy.jl but cant do it
* Error:In Extending the function of StrategyBase.jl
* Tests and some bugs are fixed
* Benchmarks is shift to another branch
* .DS_store is removedand made few changes in Heaped and SortedVector
* All .DS_Store files are removed
Copy file name to clipboardExpand all lines: src/SortedVectors.jl
+10-12Lines changed: 10 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -3,31 +3,29 @@ __precompile__()
3
3
module SortedVectors
4
4
5
5
import Base: getindex, length, push!, isempty,
6
-
pop!, resize!, popfirst!
6
+
pop!, popfirst!
7
7
8
8
export SortedVector
9
9
10
-
"""
11
-
A `SortedVector` behaves like a standard Julia `Vector`, except that its elements are stored in sorted order, with an optional function `by` that determines the sorting order in the same way as `Base.searchsorted`.
12
-
"""
13
-
struct SortedVector{T, F<:Function}
10
+
import..StrategyBase:filter_elements!
11
+
using..StrategyBase
12
+
13
+
struct SortedVector{T, F<:Function} <:Strategy
14
+
14
15
data::Vector{T}
15
16
by::F
16
17
17
18
functionSortedVector(data::Vector{T}, by::F) where {T,F}
18
-
new{T,F}(sort(data,by=by), by)
19
+
new{T,F}(sort(data, by =by), by)
19
20
end
20
21
end
21
22
22
-
23
23
SortedVector(data::Vector{T}) where {T} =SortedVector(data, identity)
minimise(f, X, tol=1e-3) in this case the default value of "structure" is "HeapedVector"
1
7
2
-
"""
3
-
minimise(f, X, tol=1e-3)
4
-
5
-
Find the global minimum of the function `f` over the `Interval` or `IntervalBox` `X` using the Moore-Skelboe algorithm.
8
+
Find the global minimum of the function `f` over the `Interval` or `IntervalBox` `X` using the Moore-Skelboe algorithm. By specifing the way in which vector element are kept arranged which is in heaped array or in sorted array. If you not specify any particular strategy to keep vector elements arranged then by default heaped array is used.
6
9
7
10
For higher-dimensional functions ``f:\\mathbb{R}^n \\to \\mathbb{R}``, `f` must take a single vector argument.
8
11
9
12
Returns an interval containing the global minimum, and a list of boxes that contain the minimisers.
10
13
"""
11
-
functionminimise(f, X::T, tol=1e-3) where {T}
12
14
13
-
# list of boxes with corresponding lower bound, ordered by increasing lower bound:
14
-
working =SortedVector([(X, ∞)], x->x[2])
15
15
16
+
functionminimise(f, X::T ; structure = HeapedVector, tol=1e-3 ) where {T}
17
+
18
+
# list of boxes with corresponding lower bound, arranged according to selected structure :
19
+
working =structure([(X, ∞)], x->x[2])
16
20
minimizers = T[]
17
21
global_min = ∞ # upper bound
18
22
@@ -34,17 +38,14 @@ function minimise(f, X::T, tol=1e-3) where {T}
34
38
end
35
39
36
40
# Remove all boxes whose lower bound is greater than the current one:
37
-
# Since they are ordered, just find the first one that is too big
0 commit comments