Skip to main content

Do not print "Set parameter Username" in console

Answered

Comments

5 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    In order to suppress the "Set parameter XXX" output, you have to set the parameter OutputFlag as the first parameter in your environment, i.e., 

    // Create an environment
    GRBEnv env = GRBEnv(true);
    env.set(GRB_IntParam_OutputFlag,0);
    // Rest of your code

    Best regards,
    Jaromił

    1
  • Allyson Silva
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks for the quick answer, Jaromił!

    In fact, my problem is that I am creating the GRBEnv and GRBModel as attributes of a class as:

    class MyProblem {
    public:
    GRBEnv env;
    GRBModel model = GRBModel(env);
    // ...
    void setModel();
    }

    and adding model.set(GRB_IntParam_OutputFlag, 0) as the first command in void setModel(). After your suggestion, I could contour the problem by adding a constructor to initialize env before model as:

    class MyProblem {
    public:
    GRBEnv env;
    GRBModel model;

    // Constructor to set OutputFlag before creating my model
    MyProblem() : env(true), model(createModel(env)) {};

    GRBModel createModel(GRBEnv& env);
    void setModel();
    }

    // Set OutputFlag to 0 in env
    GRBModel MyProblem::createModel(GRBEnv& env) {
    env.set(GRB_IntParam_OutputFlag, 0);
    env.start();
    return GRBModel(env);
    }

    I will leave this here in case it may be helpful to someone else.

    1
  • Florian Götz
    • Gurobi-versary
    • Conversationalist
    • First Question

    Hello,

    could someone please post a solution for python users?

    Thanks a lot.

    0
  • Jaromił Najman
    • Gurobi Staff Gurobi Staff

    could someone please post a solution for python users?

    The Python solution can be found in the Knowledge Base article How do I suppress all console output from Gurobi?

    -1

Post is closed for comments.