Do not print "Set parameter Username" in console
AnsweredI am using the C++ API and recently updated my Gurobi version from 9.1 to 9.5. It seems there is a new feature that prints "Set parameter XXX" when a parameter is manually set in the new version. I have been using Gurobi to solve an optimization problem that requires calling new environments multiple times sequentially. As so, I don't want to print anything from Gurobi in my console to keep it clean. I followed the second suggestion in this nice post to suppress all console output. However, even when setting OutputFlag 0 in an external file, the console still prints "Set parameter Username" after every new environment creation. How can I suppress that?
-
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 codeBest regards,
Jaromił1 -
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 -
Hello,
could someone please post a solution for python users?
Thanks a lot.
0 -
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
Please sign in to leave a comment.
Comments
4 comments