Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Integrate CSV imported data into tuples

    Posted Mon July 16, 2018 09:15 AM

    Originally posted by: labrecheMustapha


    Hi,

    I have this lines of code 

    //Tuple 

    tuple Structures {
    int i;
    float consequence_economic
    }

    //Array of the tuple (each tuple corresponds to one periode p)

    Structures Array_Structure[1..p][1..n] = ...;

    //Define precedence 

    int consequence_economic[i in Cities][q in Periodes] = Array_Structure[q][i].consequence_economic;  

    int prec[q in Periodes][i in Cities][j in Cities]= consequence_economic[i][q] >= consequence_economic[j][q] ? 1 : 0;

     

    I imported know data from matlab (.csv file) like this as shown by  @AlexFleischer : 

    tuple Failures
        {
        int     h;
        float   beta_bil_1;
        float beta_quad_2;
        float beta_square_3;
        float beta_expo_4;
        float beta_bil_5;
        float beta_quad_6;
        float beta_square_7;
        float beta_expo_8;
        float beta_bil_9;
        float beta_quad_10;
        float beta_square_11;
        float beta_expo_12;
        }

     

    {Failures} failure={};

    execute
    {
    var f=new IloOplInputFile("dataSplit.csv");
    var str=f.readline(); // skip first line
    while (!f.eof)
    {
    var str=f.readline();
    writeln(str);
    var ar=str.split(",");
    if (ar.length==13) failure.add(ar[0],Opl.floatValue(ar[1]),ar[2],ar[3],ar[4],ar[5],ar[6],ar[7],ar[8],ar[9],ar[10],ar[11],ar[12]);
    }
    f.close();
    }

     

    were :

    - "int h" in tuple 2 corresponds to "p periode" in tuple 1  

    - "int i" in tuple 1 corresponds to " float   beta_bil_1;...;float  beta_expo_12;"

     

    How can i assign p to h and i to all float beta_....?

     

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Integrate CSV imported data into tuples