Skip to content

Commit

Permalink
Cleaner logging
Browse files Browse the repository at this point in the history
  • Loading branch information
d-krupke committed Mar 29, 2024
1 parent f9ccc96 commit a0186df
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples/gurobi_tsp_with_slurminade/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = (
Expand All @@ -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))
Expand Down

0 comments on commit a0186df

Please sign in to comment.