【问题标题】:How to convert 4D generted data from excelsheet to OPL CPLEX Form?如何将 4D 生成的数据从 excel 表转换为 OPL CPLEX 表单?
【发布时间】:2021-09-13 16:27:20
【问题描述】:

我有一个 4d 数组说 Array4D[i in rangeA][j in rangeB][k in rangeC][l in rangeD]=...; 我想从 Excel 表中读取它的数据。我怎么能这样做?我已经检查了之前回答的问题——因为给定的链接不起作用,并且提供的方法给出了错误IBM ILOG Concert: excel: range size is not the size of tupleSet. 在我的问题范围A = 1; rangeB 为 20,rangeC 为 40,rangeD 为 100。

【问题讨论】:

    标签: cplex opl


    【解决方案1】:

    在这个article

    Read 3 dimension arrays

    .mod

    range A=1..2;
    range B=1..3;
    range C=1..4;
    
    
    tuple someTuple{
        key int a;
        key int b;
        key int c;
        int value;
        };
        
    
    {someTuple} someSet = ...;
    
    int v[a in A][b in B][c in C]=item(someSet,<a,b,c>).value;
    
    dvar int X[A][B][C];
    
    subject to
    {
        forall(a in A,b in B,c in C) X[a][b][c]==v[a][b][c];
    }
    
    
    assert forall(a in A,b in B,c in C) X[a][b][c]==a*b*c;
    

    .dat

    SheetConnection sheet("write3Darray.xlsx");
    
    someSet from SheetRead(sheet,"A1:D24"); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-18
      • 2022-10-02
      • 2019-07-08
      • 1970-01-01
      • 2014-06-09
      • 1970-01-01
      相关资源
      最近更新 更多