【问题标题】:How can I read a 1 dimensional data in excel to a two dimensional data in cplex?如何将 excel 中的一维数据读取为 cplex 中的二维数据?
【发布时间】:2021-05-16 08:14:07
【问题描述】:

我做了 数据。我有一个按 1 列组织的数据文件。它是这样生成的,因为我试图在 s 场景中为诊所的 n 名患者生成不定时的时间。我的问题是,现在当我将列作为二维数据读入 cplex mod 时,比如说 Tunpunctual[s][n]? enter image description here

【问题讨论】:

    标签: cplex


    【解决方案1】:

    Excel, Rocket science and optimization

    有一个很简单的2D array read example

    .mod

    int n=2;
    int m=3;
    
    int ar[1..n][1..m]=...;
    {int} se=...;
    
    int subar[1..2]=...;
    int subar2[1..2]=...;
    
    subject to
    {
      
    }
    
    {int} se2= {i+1 | i in se};
    int ar2[i in 1..n][j in 1..m]=ar[i][j]+1;
    
    execute
    {
      writeln("subar=",subar);
      writeln("subar2=",subar2);
    }
    

    .dat

    SheetConnection s("read2Darray.xlsx");
    
    ar from SheetRead(s,"B1:D2");
    subar from SheetRead(s,"B1:C1");
    subar2 from SheetRead(s,"B1:B2");
    se from SheetRead(s,"B1:D2");
    
    se2 to SheetWrite(s,"B5:D6");
    ar2 to SheetWrite(s,"F5:H6");
    
    subar to SheetWrite(s,"B8:B9");
    subar2 to SheetWrite(s,"B11:C11");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-26
      • 1970-01-01
      相关资源
      最近更新 更多