CPLEX时间,直到第一个可行的解决方案
CPLEX time until first feasible solution
我是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实现回调的文档。
相关文章:
- 运行同一解决方案的另一个项目的项目
- 在一个解决方案中针对第三方静态库 (Creo) 的不同版本(版本)进行构建
- 如何巧妙地编写两个函数——一个用于检查是否存在解决方案,另一个用于获取所有解决方案
- 解决方案在第 25 行执行错误'out of bounds'
- 对于 ~95% 写入/5% 读取线程安全的无序列图,有没有一个简单的解决方案?
- 如何在不创建新配置的情况下对两个不同解决方案使用的一个项目使用不同的 #defines
- 单元测试类无法在我要测试的同一解决方案中的另一个项目中找到类
- 只有一个正确解决方案的无限循环
- 是否有一个很好的方法可以在C 11中打印出像JSON一样的Trie结构(仅迭代解决方案)的扁平命名空间
- VS为我提供了对构造函数的另一个解决方案,但我想知道为什么我的工作不起作用
- C++回文检查解决方案被一个测试用例跳闸
- 我提交了解决方案,并在第 4 个测试用例中出现时间限制错误
- 正在(在构造函数中)将其包含一个不良设计的指针传递,如果是的,则解决方案是什么
- 在同一解决方案但不同配置的另一个项目中使用一个类
- 为什么“从'x*'到'y'失去精度”是一个硬错误,什么是适合旧版代码的解决方案
- 一个解决方案,两个项目:如何从 Windows 应用程序调用控制台项目?C++
- C++/VS 2012-多项目解决方案:一个项目中存在链接器错误,但另一个项目没有
- 我需要一个非模板解决方案
- 每个解决方案有一个nuget包版本(但不是最新版本)
- 嵌套向量不遵循提升规则.解决方案有一个错误