Silence debug statements

master
Alinson S. Xavier 5 years ago
parent 3f1aec7fad
commit bdfe343fea
No known key found for this signature in database
GPG Key ID: A796166E4E218E02

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

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

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

Loading…
Cancel
Save