我要使用 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>}
关于cplex - 将 Excel 文件连接到 CPLEX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48231980/