Skip to main content

Messages being printed to standard output when library is loaded

Answered

Comments

3 comments

  • Eli Towle
    Gurobi Staff Gurobi Staff

    Hi Carlos,

    You could set the OutputFlag parameter before the Gurobi environment is even started. E.g.:

    import gurobipy as gp

    with gp.Env(empty=True) as env:
        env.setParam('OutputFlag', 0)
        env.start()
        with gp.Model(env=env) as m:
            # Build model m here

    Does this work for you?

    Eli

    0
  • Carlos Martin
    Gurobi-versary
    First Question
    Conversationalist

    Eli Towle Thanks, that seems to work. Is there a way to change the default for OutputFlag globally (e.g. through some system-wide environment variable or setting)?

    0
  • Eli Towle
    Gurobi Staff Gurobi Staff

    Hi Carlos,

    There's no way to change OutputFlag on a system level.

    An alternative approach (that may better fit your usage) is to create a \( \texttt{gurobi.env} \) file (see here) in the current working directory of your scripts, and add to that file the single line

    OutputFlag 0

    Gurobi will automatically look for a \( \texttt{gurobi.env} \) file to use in the current working directory. If it finds one, it applies the listed parameters to new Gurobi environments. So, if you have such a \( \texttt{gurobi.env} \) file in the same directory as your scripts, your scripts don't need to create a special environment:

    import gurobipy as gp

    with gp.Model() as m:
        # Build model m here

    Thanks,

    Eli

    0

Please sign in to leave a comment.