Skip to content

Commit

Permalink
Update DividedRectangles.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
tawheeler authored Sep 22, 2024
1 parent 391739c commit cb0bfdb
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/DividedRectangles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,6 @@ function get_split_intervals(□s::Vector{DirectRectangle}, r_min::Float64)
return hull
end

"""
An implementation of DIRECT that runs for the given number of iterations and
then returns all hyperrectangular intervals.
"""
function direct(f, a::Vector{Float64}, b::Vector{Float64};
max_iterations::Int = 100, min_radius::Float64 = 1e-5)

g = x -> f(x.*(b-a) + a) # evaluate within unit hypercube

n = length(a)
c = fill(0.5, n)
□s = [DirectRectangle(c, g(c), fill(0, n), sqrt(0.5^n))]

for k in 1 : max_iterations
□s_split = get_split_intervals(□s, r_min)
setdiff!(□s, □s_split)
for □_split in □s_split
append!(□s, split_interval(□_split, g))
end
end

return □s
end

"""
Split the given interval, where g is the objective function in the unit hypercube.
This method returns a list of the resulting smaller intervals.
Expand All @@ -97,6 +73,30 @@ function split_interval(□, g)
return □s
end

"""
An implementation of DIRECT that runs for the given number of iterations and
then returns all hyperrectangular intervals.
"""
function direct(f, a::Vector{Float64}, b::Vector{Float64};
max_iterations::Int = 100, min_radius::Float64 = 1e-5)

g = x -> f(x.*(b-a) + a) # evaluate within unit hypercube

n = length(a)
c = fill(0.5, n)
□s = [DirectRectangle(c, g(c), fill(0, n), sqrt(0.5^n))]

for k in 1 : max_iterations
□s_split = get_split_intervals(□s, min_radius)
setdiff!(□s, □s_split)
for □_split in □s_split
append!(□s, split_interval(□_split, g))
end
end

return □s
end

"""
The primary method provided by DividedRectangles.jl, which is used to
optimize an objective function and return the best design found.
Expand Down

0 comments on commit cb0bfdb

Please sign in to comment.