Skip to content

Commit a831cdd

Browse files
authored
Fix issue on GeneralDichotomy initial weights (#208)
1 parent b71397a commit a831cdd

2 files changed

Lines changed: 12 additions & 17 deletions

File tree

ext/Polyhedra/GeneralDichotomy.jl

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ function MOA.minimize_multiobjective!(
8181
for (i, weight) in enumerate(weights)
8282
sol_z = weight.w' * new_sol.y
8383
if sol_z < weight.z - atol
84-
# The new solution is strictly better than the previous.
8584
if length(weight.adj_bnd) < n_obj
8685
weight.removed = true
8786
n_removed += 1
88-
else
87+
end
88+
union!(polytope_sol, weight.adj_sol)
89+
if !weight.removed
8990
weight.adj_sol = Int[new_sol_ind]
9091
weight.z = sol_z
9192
end
92-
union!(polytope_sol, weight.adj_sol)
9393
elseif sol_z <= weight.z + atol
9494
# The new solution is equal in value to the previous.
9595
push!(weight.adj_sol, new_sol_ind)
@@ -115,20 +115,7 @@ function MOA.minimize_multiobjective!(
115115
for idx in eachindex(Polyhedra.points(poly))
116116
w = get(poly, idx)
117117
z = w' * new_sol.y
118-
if (i = get(equal_weights, _round(w; atol), nothing)) !== nothing
119-
# Update an existing extreme weight.
120-
weights[i].z = z
121-
weights[i].tested = true
122-
weights[i].adj_sol = Int[new_sol_ind]
123-
if length(weights[i].adj_bnd) < n_obj - 1
124-
if !weights[i].removed
125-
weights[i].removed = true
126-
n_removed += 1
127-
end
128-
else
129-
weights[i].removed = false
130-
end
131-
else
118+
if (i = get(equal_weights, _round(w; atol), nothing)) === nothing
132119
# Insert a new extreme weight.
133120
adj_bnd, adj_sol = Int[], Int[]
134121
for elt in Polyhedra.incidenthalfspaceindices(poly, idx)

test/algorithms/test_GeneralDichotomy.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ function test_vlp()
127127
MOI.set(model, MOI.Silent(), true)
128128
MOI.set(model, MOA.Algorithm(), MOA.GeneralDichotomy())
129129
MOI.optimize!(model)
130+
N = MOI.get(model, MOI.ResultCount())
131+
y_sol = map(1:N) do i
132+
return round.(Int, 10 .* MOI.get(model, MOI.ObjectiveValue(i)))
133+
end
134+
Y_N = [[15, 15, 0], [5, 10, 5], [5, 5, 10], [10, 5, 5]]
135+
for i in length(Y_N)
136+
@test Y_N[i] y_sol
137+
end
130138
return
131139
end
132140

0 commit comments

Comments
 (0)