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

add xpress patch #1051

Merged
merged 11 commits into from
Feb 9, 2024
2 changes: 2 additions & 0 deletions src/core/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ const NO_SERVICE_NAME_PROVIDED = ""
const CONTAINER_KEY_EMPTY_META = ""
const UPPER_BOUND = "ub"
const LOWER_BOUND = "lb"
const MAX_OPTIMIZE_TRIES = 2


jd-lara marked this conversation as resolved.
Show resolved Hide resolved
# File Names definitions
const PROBLEM_SERIALIZATION_FILENAME = "operation_problem.bin"
Expand Down
43 changes: 32 additions & 11 deletions src/core/optimization_container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -671,17 +671,35 @@
optimizer_stats = get_optimizer_stats(container)

jump_model = get_jump_model(container)
_,
optimizer_stats.timed_solve_time,
optimizer_stats.solve_bytes_alloc,
optimizer_stats.sec_in_gc = @timed JuMP.optimize!(jump_model)
model_status = JuMP.primal_status(jump_model)
if model_status != MOI.FEASIBLE_POINT::MOI.ResultStatusCode
@error "Optimizer returned $model_status"
if get_calculate_conflict(get_settings(container))
compute_conflict!(container)

model_status = MOI.NO_SOLUTION::MOI.ResultStatusCode
conflict_status = MOI.COMPUTE_CONFLICT_NOT_CALLED

try_count = 0
while model_status != MOI.FEASIBLE_POINT::MOI.ResultStatusCode
_,
optimizer_stats.timed_solve_time,
optimizer_stats.solve_bytes_alloc,
optimizer_stats.sec_in_gc = @timed JuMP.optimize!(jump_model)
model_status = JuMP.primal_status(jump_model)

if model_status != MOI.FEASIBLE_POINT::MOI.ResultStatusCode
if get_calculate_conflict(get_settings(container))
@warn "Optimizer returned $model_status computing conflict"
conflict_status = compute_conflict!(container)
if conflict_status == MOI.CONFLICT_FOUND
return RunStatus.FAILED

Check warning on line 691 in src/core/optimization_container.jl

View check run for this annotation

Codecov / codecov/patch

src/core/optimization_container.jl#L687-L691

Added lines #L687 - L691 were not covered by tests
end
else
@warn "Optimizer returned $model_status trying optimize! again"

Check warning on line 694 in src/core/optimization_container.jl

View check run for this annotation

Codecov / codecov/patch

src/core/optimization_container.jl#L694

Added line #L694 was not covered by tests
end

try_count += 1
if try_count > MAX_OPTIMIZE_TRIES
@error "Optimizer returned $model_status after $MAX_OPTIMIZE_TRIES optimize! attempts"
return RunStatus.FAILED

Check warning on line 700 in src/core/optimization_container.jl

View check run for this annotation

Codecov / codecov/patch

src/core/optimization_container.jl#L697-L700

Added lines #L697 - L700 were not covered by tests
end
end
return RunStatus.FAILED
end

status = RunStatus.SUCCESSFUL
Expand All @@ -706,6 +724,7 @@
JuMP.compute_conflict!(jump_model)
if MOI.get(jump_model, MOI.ConflictStatus()) != MOI.CONFLICT_FOUND
@error "No conflict could be found for the model. $(MOI.get(jump_model, MOI.ConflictStatus()))"
return MOI.get(jump_model, MOI.ConflictStatus())

Check warning on line 727 in src/core/optimization_container.jl

View check run for this annotation

Codecov / codecov/patch

src/core/optimization_container.jl#L727

Added line #L727 was not covered by tests
end

for (key, field_container) in get_constraints(container)
Expand All @@ -718,6 +737,8 @@
end
end
@error "$(conflict)"

return MOI.get(jump_model, MOI.ConflictStatus())

Check warning on line 741 in src/core/optimization_container.jl

View check run for this annotation

Codecov / codecov/patch

src/core/optimization_container.jl#L741

Added line #L741 was not covered by tests
catch e
jump_model.is_model_dirty = true
if isa(e, MethodError)
Expand All @@ -727,7 +748,7 @@
end
end

return
return MOI.NO_CONFLICT_EXISTS

Check warning on line 751 in src/core/optimization_container.jl

View check run for this annotation

Codecov / codecov/patch

src/core/optimization_container.jl#L751

Added line #L751 was not covered by tests
end

function write_optimizer_stats!(container::OptimizationContainer)
Expand Down
2 changes: 2 additions & 0 deletions src/core/optimizer_stats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mutable struct OptimizerStats
has_duals::Bool
# Candidate solution
objective_bound::Union{Missing, Float64}
relative_gap::Union{Missing, Float64}
# Use missing instead of nothing so that CSV writting doesn't fail
dual_objective_value::Union{Missing, Float64}
# Work counters
Expand Down Expand Up @@ -37,6 +38,7 @@ function OptimizerStats()
false,
missing,
missing,
missing,
NaN,
missing,
missing,
Expand Down
1 change: 1 addition & 0 deletions src/utils/jump_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ function _summary_to_dict!(optimizer_stats::OptimizerStats, jump_model::JuMP.Mod
:objective_bound, # Union{Missing,Float64}
:dual_objective_value, # Union{Missing,Float64}
# Work counters
:relative_gap, # Union{Missing,Int}
:barrier_iterations, # Union{Missing,Int}
:simplex_iterations, # Union{Missing,Int}
:node_count, # Union{Missing,Int}
Expand Down
Loading