0

I am using CPLEX in Cpp. After googling I found out what parameters need to be set to avoid cplex from printing to terminal and I use them like this:

IloCplex cplex(model);
std::ofstream logfile("cplex.log");
cplex.setOut(logfile);
cplex.setWarning(logfile);
cplex.setError(logfile);

cplex.setParam(IloCplex::MIPInterval, 1000);//Controls the frequency of node logging when MIPDISPLAY is set higher than 1.
cplex.setParam(IloCplex::MIPDisplay, 0);//MIP node log display information-No display until optimal solution has been found
cplex.setParam(IloCplex::SimDisplay, 0);//No iteration messages until solution
cplex.setParam(IloCplex::BarDisplay, 0);//No progress information
cplex.setParam(IloCplex::NetDisplay, 0);//Network logging display indicator

if ( !cplex.solve() ) {
....
}

but yet cplex prints such things:

Warning:  Bound infeasibility column 'x11'.
Presolve time = 0.00 sec. (0.00 ticks)

Root node processing (before b&c):
  Real time             =    0.00 sec. (0.01 ticks)
Parallel b&c, 4 threads:
  Real time             =    0.00 sec. (0.00 ticks)
  Sync time (average)   =    0.00 sec.
  Wait time (average)   =    0.00 sec.
                          ------------
Total (root+branch&cut) =    0.00 sec. (0.01 ticks)

Is there any way to avoid printing them?

4

2 回答 2

0

这是根据cplex 参数 doc在 C++ 中起作用的方法:

cplex.setOut(env.getNullStream());
cplex.setWarning(env.getNullStream());
cplex.setError(env.getNullStream());
于 2015-03-19T10:14:42.667 回答
0

使用类中的setOut方法IloAlgorithmIloCplex继承自IloAlgorithm)。您可以将空输出流设置为参数并防止在屏幕上记录消息。

于 2014-08-15T12:53:25.253 回答