4

I am using Gurobi on Python and my code requires a loop of Model.optimize() function. Is there a way to mute this function, so it won't make paragraphs of output?

Thanks.

Oğuz K
  • 164
  • 3
  • 7

1 Answers1

5

Set the Output Flag parameter to zero.

From the reference manual on output flag:

Enables or disables solver output. Use LogFile and LogToConsole for finer-grain control. Setting OutputFlag to 0 is equivalent to setting LogFile to "" and LogToConsole to 0.

a code chunk from a project I am working on:

from gurobipy import Model, GRB, LinExpr, quicksum

dual_subproblem = Model('dual_subproblem_(0,0)')
dual_subproblem.setParam('OutputFlag', 0)  # Also dual_subproblem.params.outputflag = 0
dual_subproblem.params.threads = 1 
dual_subproblem.modelSense = GRB.MAXIMIZE
dual_subproblem.update()

Then the call to optimize does not produce any output.

I hope this helps.

Ioannis
  • 5,238
  • 2
  • 19
  • 31