Skip to content

Fixed KS and TV #107

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

Closed
wants to merge 2 commits into from
Closed
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/algorithms/KirlikSayin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function optimize_multiobjective!(algorithm::KirlikSayin, model::Optimizer)
return status, nothing
end
_, Y = _compute_point(model, variables, f_i)
yI[i] = Y + 1
yI[i] = Y
model.ideal_point[i] = Y
MOI.set(
model.inner,
Expand All @@ -125,7 +125,7 @@ function optimize_multiobjective!(algorithm::KirlikSayin, model::Optimizer)
return status, nothing
end
_, Y = _compute_point(model, variables, f_i)
yN[i] = Y
yN[i] = Y + 1
end
# Reset the sense after modifying it.
MOI.set(model.inner, MOI.ObjectiveSense(), sense)
Expand Down
38 changes: 21 additions & 17 deletions src/algorithms/TambyVanderpooten.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ function _update_search_region(
y::Vector{Float64},
yN::Vector{Float64},
)
bounds_to_remove = Vector{Float64}[]
p = length(y)
bounds_to_remove = Vector{Float64}[]
bounds_to_add = Dict{Vector{Float64},Vector{Vector{Vector{Float64}}}}()
for u in keys(U_N)
if all(y .< u)
push!(bounds_to_remove, u)
for l in 1:p
u_l = _get_child(u, y, l)
N = [
k != l ? [yi for yi in U_N[u][k] if yi[l] < y[l]] : [y]
k == l ? [y] : [yi for yi in U_N[u][k] if yi[l] < y[l]]
for k in 1:p
]
if all(!isempty(N[k]) for k in 1:p if u_l[k] yN[k])
U_N[u_l] = N
if all(!isempty(N[k]) for k in 1:p if k != l && u_l[k] != yN[k])
bounds_to_add[u_l] = N
end
end
else
Expand All @@ -53,27 +54,31 @@ function _update_search_region(
end
end
end
for bound_to_remove in bounds_to_remove
delete!(U_N, bound_to_remove)
for u in bounds_to_remove
delete!(U_N, u)
end
merge!(U_N, bounds_to_add)
return
end

function _get_child(u::Vector{Float64}, y::Vector{Float64}, k::Int)
@assert length(u) == length(y)
return vcat(u[1:k-1], y[k], u[k+1:length(y)])
return vcat(u[1:(k-1)], y[k], u[(k+1):length(y)])
end

function _select_search_zone(
U_N::Dict{Vector{Float64},Vector{Vector{Vector{Float64}}}},
yI::Vector{Float64},
yN::Vector{Float64},
)
i, j =
argmax([
prod(_project(u, k) - _project(yI, k)) for k in 1:length(yI),
u in keys(U_N)
]).I
return i, collect(keys(U_N))[j]
upper_bounds = collect(keys(U_N))
p = length(yI)
hvs = [
u[k] == yN[k] ? 0.0 : prod(_project(u, k) .- _project(yI, k)) for
k in 1:p, u in upper_bounds
]
k_star, j_star = argmax(hvs).I
return k_star, upper_bounds[j_star]
end

function optimize_multiobjective!(
Expand All @@ -100,7 +105,6 @@ function optimize_multiobjective!(
warm_start_supported = true
end
solutions = Dict{Vector{Float64},Dict{MOI.VariableIndex,Float64}}()
YN = Vector{Float64}[]
variables = MOI.get(model.inner, MOI.ListOfVariableIndices())
n = MOI.output_dimension(model.f)
yI, yN = zeros(n), zeros(n)
Expand All @@ -114,7 +118,7 @@ function optimize_multiobjective!(
return status, nothing
end
_, Y = _compute_point(model, variables, f_i)
yI[i] = Y + 1
yI[i] = Y
model.ideal_point[i] = Y
MOI.set(model.inner, MOI.ObjectiveSense(), MOI.MAX_SENSE)
MOI.optimize!(model.inner)
Expand All @@ -124,7 +128,7 @@ function optimize_multiobjective!(
return status, nothing
end
_, Y = _compute_point(model, variables, f_i)
yN[i] = Y
yN[i] = Y + 1
end
MOI.set(model.inner, MOI.ObjectiveSense(), MOI.MIN_SENSE)
U_N = Dict{Vector{Float64},Vector{Vector{Vector{Float64}}}}()
Expand All @@ -136,7 +140,7 @@ function optimize_multiobjective!(
status = MOI.TIME_LIMIT
break
end
k, u = _select_search_zone(U_N, yI)
k, u = _select_search_zone(U_N, yI, yN)
MOI.set(
model.inner,
MOI.ObjectiveFunction{typeof(scalars[k])}(),
Expand Down
Loading