【发布时间】:2014-10-16 08:58:13
【问题描述】:
我在我的 c++ 代码中使用 OPL/Cplex 库,
在我的 file.mod 中,我标记了这个决策变量: dvar int+ x[nodes][nodes][1..nb_max][lambdas];
现在我那个Cplex解决了我成功恢复目标值的模型如下:
try {
IloCplex cplex(env);
cplex.setOut(env.getNullStream());
IloOplErrorHandler handler(env,cout);
IloOplModelSource modelSource(env, "file.mod");
IloOplSettings settings(env,handler);
IloOplModelDefinition def(modelSource,settings);
IloOplModel opl(def,cplex);
IloOplDataSource dataSource(env, "file2.dat");
opl.addDataSource(dataSource);
opl.generate();
if ( cplex.solve() ) {
cout<< opl.getCplex().getObjValue()<< endl;
}
}
我的问题是如何恢复多维数组“x”? 我试过了
IloIntVar x = opl.getElement("x").asIntVar; IloIntVar xvar =x.get(0);//第一项
但出现以下错误!
错误:请求从 '' 转换为非标量类型 'IloIntVar' 错误:“IloIntVar 类”没有名为“get”的成员
我真的是 OPL 的初学者, 提前致谢!
【问题讨论】: