简体   繁体   中英

Import excel 2D array to tuple without convert to 1D CPLEX

I have a 2D array in excel need import to CPLEX.

在此处输入图片说明

Normally, I use:

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

However, can I import it as a tuple without convert to 1D

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

Or is there any way to convert runtime[part, operation] to runtime[run] ?

yes you can

" convert runtime[part, operation] to runtime[run] "

See

{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);
}

that gives

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM