将Excel 2D数组导入到元组而不转换为1D CPLEX

时间:2018-06-20 02:48:57

标签: cplex

我在excel中有一个2D数组,需要导入到CPLEX。

enter image description here

通常,我使用:

{string} part = ...;
{string} operation = ...;
float runtime[part, operation] = ...;

但是,我可以将其作为元组导入而不转换为一维吗?

tuple Trun
{
    string part;
    string operation;
}
{Trun} run = {<i, o> | i in part, o in operation};
float runtime[run] = ...;

或者有什么方法可以将runtime[part, operation]转换为runtime[run]

1 个答案:

答案 0 :(得分:1)

是的

将运行时[部件,操作]转换为运行时[run]

请参见

{string} part = {"A","B","C"};
{string} operation = {"1","2"};
float runtime[part, operation] = [[1,2],[3,4],[5,6]];

tuple Trun
{
string p;
string o;
}
{Trun} run = {<i, o> | i in part, o in operation};


float runtime2[r in run] = runtime[r.p,r.o];

execute
{
writeln(runtime);
writeln(runtime2);
}

给出

[[1 2]
         [3 4]
         [5 6]]
 [1 2 3 4 5 6]