Skip to content

Commit

Permalink
improve retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Feb 9, 2024
1 parent fff6433 commit c296555
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/core/optimization_container.jl
Original file line number Diff line number Diff line change
Expand Up @@ -684,20 +684,22 @@ function solve_impl!(container::OptimizationContainer, system::PSY.System)
optimizer_stats.sec_in_gc = @timed JuMP.optimize!(jump_model)
model_status = JuMP.primal_status(jump_model)

if get_calculate_conflict(get_settings(container))
@error "Optimizer returned $model_status computing conflict"
conflict_status = compute_conflict!(container)
if conflict_status == MOI.CONFLICT_FOUND
return RunStatus.FAILED
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
end
else
@warn "Optimizer returned $model_status trying optimize! again"
end
else
@error "Optimizer returned $model_status trying again"
end

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

Expand Down

0 comments on commit c296555

Please sign in to comment.