我有一个问题,我不明白这是怎么可能的。
这是代码的快照:
IloNumVarArray variables;
IloEnv environment;
if(!cplex.solve()) {
IloCplex::CplexStatus cplexStatus = cplex.getCplexStatus();
IloAlgorithm::Status status = cplex.getStatus();
printf("status: %d %d\n", cplexStatus, status);
}
IloNumArray values(environment);
cplex.getValues(values, variables);
奇怪的是程序偶尔会打印
“状态:1 2”
分别是:
CplexStatus::CPX_STAT_OPTIMAL
和Status::Optimal
为什么 cplex.solve() 返回 false,而 cplex.getCplexStatus() 和 cplex.getStatus() 返回找到最优解?
如果我强制程序调用 cplex.getValues(),在这些情况下忽略 cplex.solve() 的返回值,则对 cplex.getValues() 的调用会生成运行异常。
这是 cplex 的输出:
Tried aggregator 1 time.
MIP Presolve eliminated 274 rows and 296 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec. (0.16 ticks)
Root node processing (before b&c):
Real time = 0.00 sec. (0.20 ticks)
Parallel b&c, 12 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.20 ticks)
更新:
似乎一种可能的解释可能来自以下几行:
MIP Presolve eliminated 274 rows and 296 columns.
All rows and columns eliminated.