Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 6 additions & 2 deletions src/MultiObjectiveAlgorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,17 @@ function MOI.delete(model::Optimizer, ci::MOI.ConstraintIndex)
return
end

function _compute_ideal_point(model::Optimizer)
function _compute_ideal_point(model::Optimizer, start_time)
objectives = MOI.Utilities.eachscalar(model.f)
model.ideal_point = fill(NaN, length(objectives))
if !MOI.get(model, ComputeIdealPoint())
return
end
for (i, f) in enumerate(objectives)
if _time_limit_exceeded(model, start_time)
status = MOI.TIME_LIMIT
break
end
MOI.set(model.inner, MOI.ObjectiveFunction{typeof(f)}(), f)
MOI.optimize!(model.inner)
status = MOI.get(model.inner, MOI.TerminationStatus())
Expand All @@ -584,7 +588,7 @@ function MOI.optimize!(model::Optimizer)
model.termination_status = MOI.INVALID_MODEL
return
end
_compute_ideal_point(model)
_compute_ideal_point(model, start_time)
algorithm = something(model.algorithm, default(Algorithm()))
status, solutions = optimize_multiobjective!(algorithm, model)
model.termination_status = status
Expand Down
6 changes: 6 additions & 0 deletions src/algorithms/Dichotomy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@
error("Only scalar or bi-objective problems supported.")
end
if MOI.output_dimension(model.f) == 1
if _time_limit_exceeded(model, start_time)
return MOI.TIME_LIMIT, nothing

Check warning on line 85 in src/algorithms/Dichotomy.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/Dichotomy.jl#L85

Added line #L85 was not covered by tests
end
status, solution = _solve_weighted_sum(model, algorithm, [1.0])
return status, [solution]
end
solutions = Dict{Float64,SolutionPoint}()
for w in (0.0, 1.0)
if _time_limit_exceeded(model, start_time)
return MOI.TIME_LIMIT, nothing
end
status, solution = _solve_weighted_sum(model, algorithm, w)
if !_is_scalar_status_optimal(status)
return status, nothing
Expand Down
2 changes: 1 addition & 1 deletion test/algorithms/Dichotomy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function test_time_limit()
)
MOI.optimize!(model)
@test MOI.get(model, MOI.TerminationStatus()) == MOI.TIME_LIMIT
@test MOI.get(model, MOI.ResultCount()) > 0
@test MOI.get(model, MOI.ResultCount()) == 0
return
end

Expand Down
Loading