读取输入文件IloCplex C ++

问题描述

我正在尝试读取包含如下矩阵的数据文件:[[10,5,3],[3,5,6] [2,1,1]]

并尝试通过调用cplex求解器来解决开发的模型。编译代码时,出现错误:超出范围的操作:索引优于数组大小;断言失败”。如何解决此问题?谢谢您

#include<ilcplex/ilocplex.h>
#include <fstream>
ILOSTLBEGIN
typedef IloArray<IloNumArray> FloatMatrix;
int main(int argc,char **argv)
{
    IloEnv env;
    const char* filename ="C:/.../.../.../.../Project.dat";
    FloatMatrix p(env);
    if (argc > 1)
        filename = argv[1]; 
    ifstream file(filename);
    file.open("Project.dat");
    if (!file.is_open()) {
      `cerr << "ERROR: Could not open file '" << filename << "' for reading" << endl;`
      throw(-1);
}
    file >> p >>;
    cout << p<< endl;
    return 0;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)