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