mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Improve logging
This commit is contained in:
@@ -134,15 +134,17 @@ class PickleGzInstance(Instance):
|
|||||||
write_pickle_gz(self.instance, self.filename)
|
write_pickle_gz(self.instance, self.filename)
|
||||||
|
|
||||||
|
|
||||||
def write_pickle_gz(obj: Any, filename: str) -> None:
|
def write_pickle_gz(obj: Any, filename: str, quiet: bool = False) -> None:
|
||||||
logger.info(f"Writing: {filename}")
|
if not quiet:
|
||||||
|
logger.info(f"Writing: {filename}")
|
||||||
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
||||||
with gzip.GzipFile(filename, "wb") as file:
|
with gzip.GzipFile(filename, "wb") as file:
|
||||||
pickle.dump(obj, cast(IO[bytes], file))
|
pickle.dump(obj, cast(IO[bytes], file))
|
||||||
|
|
||||||
|
|
||||||
def read_pickle_gz(filename: str) -> Any:
|
def read_pickle_gz(filename: str, quiet: bool = False) -> Any:
|
||||||
logger.info(f"Reading: {filename}")
|
if not quiet:
|
||||||
|
logger.info(f"Reading: {filename}")
|
||||||
with gzip.GzipFile(filename, "rb") as file:
|
with gzip.GzipFile(filename, "rb") as file:
|
||||||
return pickle.load(cast(IO[bytes], file))
|
return pickle.load(cast(IO[bytes], file))
|
||||||
|
|
||||||
|
|||||||
@@ -184,6 +184,9 @@ class LearningSolver:
|
|||||||
logger.info("Solving root LP relaxation...")
|
logger.info("Solving root LP relaxation...")
|
||||||
lp_stats = self.internal_solver.solve_lp(tee=tee)
|
lp_stats = self.internal_solver.solve_lp(tee=tee)
|
||||||
stats.update(cast(LearningSolveStats, lp_stats.__dict__))
|
stats.update(cast(LearningSolveStats, lp_stats.__dict__))
|
||||||
|
logger.info(
|
||||||
|
"LP relaxation solved in %.2f seconds" % lp_stats.lp_wallclock_time
|
||||||
|
)
|
||||||
|
|
||||||
logger.debug("Running after_solve_lp callbacks...")
|
logger.debug("Running after_solve_lp callbacks...")
|
||||||
for component in self.components.values():
|
for component in self.components.values():
|
||||||
@@ -247,6 +250,7 @@ class LearningSolver:
|
|||||||
user_cut_cb=user_cut_cb,
|
user_cut_cb=user_cut_cb,
|
||||||
lazy_cb=lazy_cb,
|
lazy_cb=lazy_cb,
|
||||||
)
|
)
|
||||||
|
logger.info("MIP solved in %.2f seconds" % mip_stats.mip_wallclock_time)
|
||||||
stats.update(cast(LearningSolveStats, mip_stats.__dict__))
|
stats.update(cast(LearningSolveStats, mip_stats.__dict__))
|
||||||
stats["Solver"] = "default"
|
stats["Solver"] = "default"
|
||||||
stats["Gap"] = self._compute_gap(
|
stats["Gap"] = self._compute_gap(
|
||||||
|
|||||||
Reference in New Issue
Block a user