From a0186dfd00be813d99423533fae1d66f410119ef Mon Sep 17 00:00:00 2001 From: Dominik Krupke Date: Fri, 29 Mar 2024 13:47:48 +0100 Subject: [PATCH] Cleaner logging --- examples/gurobi_tsp_with_slurminade/solver.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/gurobi_tsp_with_slurminade/solver.py b/examples/gurobi_tsp_with_slurminade/solver.py index 0062130..1cf3500 100644 --- a/examples/gurobi_tsp_with_slurminade/solver.py +++ b/examples/gurobi_tsp_with_slurminade/solver.py @@ -11,6 +11,9 @@ import gurobipy as gp import networkx as nx +# default logging configuration +logging.basicConfig(level=logging.INFO, format="%(message)s") + class _EdgeVariables: def __init__(self, G: nx.Graph, model: gp.Model): @@ -79,7 +82,7 @@ def solve( """ Solve the model and return the objective value and the lower bound. """ - self._model.Params.LogToConsole = 1 + self._model.Params.LogToConsole = 0 self._model.Params.TimeLimit = time_limit self._model.Params.lazyConstraints = 1 self._model.Params.MIPGap = ( @@ -89,7 +92,7 @@ def solve( def gurobi_subtour_callback(model, where): if where == gp.GRB.Callback.MESSAGE: msg = model.cbGet(gp.GRB.Callback.MSG_STRING) - self.logger.info(msg) + self.logger.info(msg.strip()) if where == gp.GRB.Callback.MIPSOL: connected_components = list( nx.connected_components(self._vars.as_graph(in_callback=True))