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

Performance Correction #46

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
4 changes: 2 additions & 2 deletions src/CharibdeOptim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import Base: invokelatest, push!

struct Constraint{T}
bound::Interval{T}
C::Contractor
C::BasicContractor
end

function constraint(vars, constraint_expr::Operation, bound::Interval{T}; epsilon = 1e-4) where{T}
C = Contractor(vars, constraint_expr)
C = BasicContractor(vars, constraint_expr)
if diam(bound) == 0.0
bound = Interval(bound.lo - epsilon, bound.hi + epsilon)
end
Expand Down
26 changes: 3 additions & 23 deletions src/ConstrainedIBC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ end

function generate_random_feasible_point(X::IntervalBox{N, T}, constraints::Vector{Constraint{T}}) where{N, T}
for i in 1:30
point = [X[j].lo + (1-rand())*(X[j].hi - X[j].lo) for j in 1:length(X)] # discover a random point in interval box X

point = SVector{N,T}([X[j].lo + (1-rand())*(X[j].hi - X[j].lo) for j in 1:length(X)]) # discover a random point in interval box X
for j in 1:length(constraints)
if !(invokelatest(constraints[j].C, point) ⊆ constraints[j].bound)
break
Expand All @@ -55,27 +56,6 @@ function generate_random_feasible_point(X::IntervalBox{N, T}, constraints::Vecto

end

function convex_hull(vec::Vector{IntervalBox{N,T}}) where{N, T}

x_big = Interval{T}[]
num_variables = N
num_boxes = length(vec)

for i in 1:num_variables
lower_bound = Inf
upper_bound = -Inf
for j in 1:num_boxes
if vec[j][i].lo < lower_bound
lower_bound = vec[j][i].lo
end
if upper_bound < vec[j][i].hi
upper_bound = vec[j][i].hi
end
end
append!(x_big, Interval(lower_bound, upper_bound))
end
return IntervalBox(x_big...)
end

function ibc_minimise(f::Function , X::IntervalBox{N,T}, constraints::Vector{Constraint{T}}; ibc_chnl = RemoteChannel(()->Channel{Tuple{IntervalBox{N,T}, Float64}}(0)), diffevol_chnl = Nothing, structure = SortedVector, debug = false, tol=1e-6) where{N, T}

Expand Down Expand Up @@ -132,7 +112,7 @@ function ibc_minimise(f::Function , X::IntervalBox{N,T}, constraints::Vector{Con
println("Box send to DifferentialEvolution: ", x_best )
end
if info.iterations % 200 == 0
x_big = convex_hull(working.data)
x_big = union(working.data)
put!(diffevol_chnl, (x_best, global_min, x_big)) # sending best individual to diffevol
else
put!(diffevol_chnl, (x_best, global_min, nothing))
Expand Down
2 changes: 1 addition & 1 deletion src/IBC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function ibc_minimise(f::Function , X::IntervalBox{N,T}; debug = false, ibc_chn

lower_bound = minimum(inf.(f.(minimizers)))

return Interval(lower_bound,global_min), minimizers, info
return Interval(lower_bound, global_min), minimizers, info


end
Expand Down