Silence debug statements

This commit is contained in:
2021-01-12 07:54:32 -06:00
parent 3f1aec7fad
commit bdfe343fea
3 changed files with 9 additions and 7 deletions

View File

@@ -28,7 +28,7 @@ class InstanceIterator:
result = self.instances[self.current]
self.current += 1
if isinstance(result, str):
logger.info("Read: %s" % result)
logger.debug("Read: %s" % result)
if result.endswith(".gz"):
with gzip.GzipFile(result, "rb") as file:
result = pickle.load(file)

View File

@@ -84,16 +84,17 @@ class GurobiSolver(InternalSolver):
self._bin_vars[name] = {}
self._bin_vars[name][idx] = var
def _apply_params(self):
def _apply_params(self, streams):
with RedirectOutput(streams):
for (name, value) in self.params.items():
self.model.setParam(name, value)
def solve_lp(self, tee=False):
self._raise_if_callback()
self._apply_params()
streams = [StringIO()]
if tee:
streams += [sys.stdout]
self._apply_params(streams)
for (varname, vardict) in self._bin_vars.items():
for (idx, var) in vardict.items():
var.vtype = self.GRB.CONTINUOUS
@@ -122,12 +123,12 @@ class GurobiSolver(InternalSolver):
if lazy_cb:
self.params["LazyConstraints"] = 1
self._apply_params()
total_wallclock_time = 0
total_nodes = 0
streams = [StringIO()]
if tee:
streams += [sys.stdout]
self._apply_params(streams)
if iteration_cb is None:
iteration_cb = lambda: False
while True:

View File

@@ -12,6 +12,7 @@ from copy import deepcopy
from typing import Optional, List
from p_tqdm import p_map
from . import RedirectOutput
from .. import (
ObjectiveValueComponent,
PrimalSolutionComponent,
@@ -38,7 +39,6 @@ def _parallel_solve(idx):
else:
output = OUTPUTS[0][idx]
instance = INSTANCES[0][idx]
print(instance)
stats = solver.solve(instance, output=output)
return (stats, instance)
@@ -219,6 +219,7 @@ class LearningSolver:
instance = pickle.load(file)
if model is None:
with RedirectOutput([]):
model = instance.to_model()
self.tee = tee