从 Execl sheet 中读取二维索引和元组

Read 2D indexes and tuple from Execl sheet

我试图将 Useduration 定义为 3D 数组,但我不知道如何定义元组元素。我收到错误消息“sheet 不支持二维浮点数”。有没有办法从 excel 读取它?

`   {string} sources=...;

 range time=1..Time; 

tuple useduration {
 float frequency;
 float Averageduration;
 }
useduration Useduration[time][sources]=...;


dat.file


sources=7;
Time=2;
Useduration= [
          [<7.2,0.67>,<0.6,5>,<7.2,0.67>,<2,3>,<0.28,1>,<0.31,1>,<0.4,1>],
          [<7.2,0.67>,<0.6,5>,<7.2,0.67>,<2,3>,<0.28,1>,<0.31,1>,<0.4,1>]]`

你可以做的是读取 2 个二维数组,然后构建元组数组:

.mod

int Time=...;
int nbsources=...;

{int} sources=asSet(1..nbsources);

 range time=1..Time; 

tuple useduration {
 float frequency;
 float Averageduration;
 }
//useduration Useduration[time][sources]=...;

float fr[time][sources]=...;
float Av[time][sources]=...;

useduration Useduration[t in time][s in sources]=<fr[t][s],Av[t][s]>;

execute
{
  writeln(Useduration);
}

.dat

nbsources=7;
Time=2;
//Useduration= [
//          [<7.2,0.67>,<0.6,5>,<7.2,0.67>,<2,3>,<0.28,1>,<0.31,1>,<0.4,1>],
//          [<7.2,0.67>,<0.6,5>,<7.2,0.67>,<2,3>,<0.28,1>,<0.31,1>,<0.4,1>]];
//          
fr= [
          [7.2,0.6,7.2,2,0.28,0.31,0.4],
          [7.2,0.6,7.2,2,0.28,0.31,0.4]];
          
Av= [
          [0.67,5,0.67,3,1,1,1],
          [0.67,5,0.67,3,1,1,1]]; 

最好的方法是遍历元组集。您在此技术说明中有一个示例:

https://www.ibm.com/support/pages/node/125333