mirror of
https://github.com/ANL-CEEESA/MIPLearn.jl.git
synced 2025-12-06 00:18:51 -06:00
DualGMI: Add time limit
This commit is contained in:
@@ -26,8 +26,10 @@ function collect_gmi_dual(
|
|||||||
optimizer,
|
optimizer,
|
||||||
max_rounds = 10,
|
max_rounds = 10,
|
||||||
max_cuts_per_round = 500,
|
max_cuts_per_round = 500,
|
||||||
|
time_limit = 3_600,
|
||||||
)
|
)
|
||||||
reset_timer!()
|
reset_timer!()
|
||||||
|
initial_time = time()
|
||||||
|
|
||||||
@timeit "Read H5" begin
|
@timeit "Read H5" begin
|
||||||
h5_filename = replace(mps_filename, ".mps.gz" => ".h5")
|
h5_filename = replace(mps_filename, ".mps.gz" => ".h5")
|
||||||
@@ -130,9 +132,14 @@ function collect_gmi_dual(
|
|||||||
@timeit "Compute GMI cuts" begin
|
@timeit "Compute GMI cuts" begin
|
||||||
cuts_s = compute_gmi(data_s, tableau)
|
cuts_s = compute_gmi(data_s, tableau)
|
||||||
|
|
||||||
# Assert cuts have been generated correctly
|
try
|
||||||
assert_cuts_off(cuts_s, sol_frac)
|
# Assert cuts have been generated correctly
|
||||||
assert_does_not_cut_off(cuts_s, sol_opt_s)
|
assert_cuts_off(cuts_s, sol_frac)
|
||||||
|
assert_does_not_cut_off(cuts_s, sol_opt_s)
|
||||||
|
catch
|
||||||
|
@warn "Numerical error. Aborting."
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
# Abort if no cuts are left
|
# Abort if no cuts are left
|
||||||
if length(cuts_s.lb) == 0
|
if length(cuts_s.lb) == 0
|
||||||
@@ -207,6 +214,12 @@ function collect_gmi_dual(
|
|||||||
sum(sp[i] * gmi_exps[i] for (i, c) in enumerate(constrs) if useful[i]),
|
sum(sp[i] * gmi_exps[i] for (i, c) in enumerate(constrs) if useful[i]),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elapsed_time = time() - initial_time
|
||||||
|
if elapsed_time > time_limit
|
||||||
|
@info "Time limit exceeded. Stopping."
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@timeit "Store cuts in H5 file" begin
|
@timeit "Store cuts in H5 file" begin
|
||||||
@@ -322,12 +335,15 @@ function _dualgmi_compress_h5(h5_filename)
|
|||||||
orig_cut_basis_vars = h5.get_array("cuts_basis_vars")
|
orig_cut_basis_vars = h5.get_array("cuts_basis_vars")
|
||||||
orig_cut_basis_sizes = h5.get_array("cuts_basis_sizes")
|
orig_cut_basis_sizes = h5.get_array("cuts_basis_sizes")
|
||||||
orig_cut_rows = h5.get_array("cuts_rows")
|
orig_cut_rows = h5.get_array("cuts_rows")
|
||||||
|
h5.close()
|
||||||
if orig_cut_basis_vars === nothing
|
if orig_cut_basis_vars === nothing
|
||||||
@warn "orig_cut_basis_vars is null; skipping file"
|
@warn "orig_cut_basis_vars is null; skipping file"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
ncuts, _ = size(orig_cut_basis_vars)
|
ncuts, _ = size(orig_cut_basis_vars)
|
||||||
h5.close()
|
if ncuts == 0
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
for i in 1:ncuts
|
for i in 1:ncuts
|
||||||
vars = orig_cut_basis_vars[i, :]
|
vars = orig_cut_basis_vars[i, :]
|
||||||
|
|||||||
Reference in New Issue
Block a user