CPLEX时间,直到第一个可行的解决方案

CPLEX time until first feasible solution

本文关键字:解决方案 第一个 时间 CPLEX      更新时间:2023-10-16

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

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

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

CPLEX中是否有直接代码来获得每个可行解决方案的时间值?

感谢

编辑1:问题的代码如下:

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:很抱歉有些参数是西班牙语,但那是我的母语。

您可以使用现任回调来获取沿途找到的每个整数可行解(包括最终解)的时间(请参阅getCplexTime函数)。要开始,请查看CPLEX附带的ilomipex4.cpp示例,了解如何使用一般回调的示例。另外,请参阅有关使用Concert实现回调的文档。

相关文章: