到第一个可行解的 CPLEX 时间

CPLEX time until first feasible solution

我是 CPLEX 和 C++ 编程的初学者,我正在尝试解决中等规模的 MIP 问题。

我的问题是我需要知道 CPLEX 花了多少时间来获得第一个可行解和获得最佳可行解(不一定是全局最优解)。

我已经知道如何配置时间限制,我一直在使用 CPLEX 的解决方案池来获取所有可行的解决方案,但不是它的时间。

CPLEX 中是否有直接代码获取每个可行解的时间值?

谢谢

EDIT1:问题代码如下:

IloEnv env;
IloModel model(env);
IloCplex cplex(model);
IloCplex::Param::TimeLimit;

IloExpr term2(env);
IloExpr term3(env);
IloExpr objetivo(env);

IloInt i,j;
double CP;

IloNumVarArray z(env, columnas-1, 0, INFTY,ILOBOOL);
IloNumVarArray a(env, columnas, -1*INFTY, INFTY, ILOFLOAT);

for (i = 0; i < filas; i++){
    IloExpr term1(env);
    for(j = 0; j < columnas-1; j++){

        term1 += a[j]*(A[i+1][j+2]);
    }
    term2 += ((b[i+1])-(term1+a[columnas-1]))*((b[i+1])-(term1+a[columnas-1]));
    term1.end();
}

for(j = 0; j < columnas-1; j++){
        term3 += z[j];
    }
objetivo=term2/(sigmasq)+2*(term3+1)-(filas);

model.add(IloMinimize(env, objetivo));


for (j = 0; j < columnas-1; j++) {
    IloExpr restr(env);
    restr = a[j] + (bigM)*z[j];
    model.add(0 <= restr <= IloInfinity);
    restr.end();
}
for (j = 0; j < columnas-1; j++) {
    IloExpr restr(env);
    restr = (bigM)*z[j] - a[j];
    model.add(0 <= restr <= IloInfinity);
    restr.end();
}

cplex.setParam(IloCplex::Param::ClockType, 2);
cplex.setParam(IloCplex::Param::TimeLimit, 3600);   

cplex.solve();

PD:抱歉有些参数是西班牙语,但那是我的母语。

您可以使用 incumbent callback to get the time (see the getCplexTime function) for every integer feasible solution found along the way (and including the final solution). To get started, check out the ilomipex4.cpp example that is shipped with CPLEX for an example of how to use callbacks in general. Also, see the documentation 通过 Concert 实现回调。