BasicCollector: Make LP and MPS optional

This commit is contained in:
2024-02-01 12:02:23 -06:00
parent 60c7222fbe
commit 5b28595b0b

View File

@@ -16,6 +16,10 @@ from ..parallel import p_umap
class BasicCollector: class BasicCollector:
def __init__(self, skip_lp: bool = False, write_mps: bool = True) -> None:
self.skip_lp = skip_lp
self.write_mps = write_mps
def collect( def collect(
self, self,
filenames: List[str], filenames: List[str],
@@ -52,6 +56,7 @@ class BasicCollector:
model = build_model(data_filename) model = build_model(data_filename)
model.extract_after_load(h5) model.extract_after_load(h5)
if not self.skip_lp:
# Solve LP relaxation # Solve LP relaxation
relaxed = model.relax() relaxed = model.relax()
relaxed.optimize() relaxed.optimize()
@@ -61,6 +66,7 @@ class BasicCollector:
model.optimize() model.optimize()
model.extract_after_mip(h5) model.extract_after_mip(h5)
if self.write_mps:
# Add lazy constraints to model # Add lazy constraints to model
if model.lazy_enforce is not None: if model.lazy_enforce is not None:
model.lazy_enforce(model, model.lazy_) model.lazy_enforce(model, model.lazy_)