cplex - 将 Excel 文件连接到 CPLEX

标签 cplex opl

我要使用 Cplex 解决优化问题。

在我的 file.dat 中,我使用 SheetConnection my_sheet("ExcelFile.xls") 将 Excel 文件链接到我的 cplex 程序,然后使用 SheetRead()从 Excel 文件中读取数据。

但是在运行配置后,出现以下错误:

"sheet data not supported on this platform"
"Processing failed"

我发现 Linux 不支持在 ILOG CPLEX optimization studio 上读取 Excel 电子表格

请问有什么想法吗?

最佳答案

我也遇到了同样的问题。 我的解决方案是将数据转换为 csv 并使用 IloOplInputFile 读取它。 示例:

假设您有以下 export.cvs 文件:

Nicolas;2; 
Alexander;3;

您可以使用以下代码将其转换为您的数据。

tuple t
{
   string firstname;
   int number;
}

{t} s={};

execute
{
   var f=new IloOplInputFile("export.csv");
   while (!f.eof){
      var str=f.readline();
      var ar=str.split(";");
      if (ar.length==3) s.add(ar[0],Opl.intValue(ar[1]));
   }
   f.close();
}

execute
{
    writeln(s);
}

它将读取 csv 文件并计算元组集 s:

{<“尼古拉斯”2> <“亚历山大”3>}

As you can see in the answer in IBM Forum.

关于cplex - 将 Excel 文件连接到 CPLEX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48231980/

相关文章:

java - 将数据从 Java 传递到 OPL 模型

c++ - 如何将条件约束转换为 cplex 的 Concert C++?

c++ - 让 Cplex 示例运行 : Undefined references

java - cplex 用于 if-else 语句

java - 在一定时间限制后终止并检索 ILOG 中的解决方案

cplex - 错误: cplex (default) cannot extract expression; OPL cannot extract expression AND change interface language

java - Java 中的元组类似于 OPL 中的元组

java - CPLEX 中的目标规划

cplex - 使用 MIP 接送车辆的车辆路线

java - 在 Java API 中使用 OPL 模型时出现 CPLEX 热启动错误