Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Tuple element

    Posted Mon September 06, 2010 10:26 PM

    Originally posted by: harshniu


    Here is my code for the scheduling of n jobs on m machines. I am describing the problem just below the code.

    //data
    {int}total=...;
    int m=...;
    int n=...;

    range job=0..n;
    range mac=1..m;
    //int h=m*n*(n+1);

    int t;

    tuple timeType{
    int precedingjob;
    int succeedingjob ;
    int machine;
    int time;}

    timeType timestotal=...;

    //variables
    dvar int+ cjob;
    dvar int+ cmax;
    dvar boolean xjobjobmac;
    //objective
    minimize cmax;
    //constraints
    subject to {
    forall(j in job)
    onejobprecedesanother:
    sum(i in 0..n, k in mac :i!=j)x[i][j][k] == 1;

    forall(h in job, k in mac)
    balanceconstraint:
    sum(i in 0..n:i!=h)x[i][h][k] - sum(j in 0..n:j!=h )x[h][j][k] == 0;

    forall(i in 0..n,j in 1..n,k in 1..m :t ==((((n+1)*j)+i-n)*(k-1)))
    //p=((7*j)+i-6)*(k - 1);

    jobcompletiontime:
    + **c[j]>=c[i]+sum(k in 1..m) x[i][j][k]*(times[t].time) + 10000*(sum(k in 1..m)x[i][j][k]-1);+

    forall(k in mac)
    firstjob :
    sum(j in 0..n) x[0][j][k]==1;

    timeatstart:
    c[0]==0;
    forall(j in job)
    cmaxconstraint:
    cmax>= c[j];}

    As you can see I am using a tuple and I have linked my data file to and excel file to input the data. I have italicised the constraint which is giving the problem. The element(times[t].time)takes the first value from the excel sheet and does not follow the expression t ==((((n+1)*j)+i-n)*(k-1))). Thereby, multiplying the same vale say 116 * 5 for 5 job problem.
    Please help me out or suggest a way to handle 3 dimensional arrays.

    Thanks
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Tuple element

    Posted Tue September 07, 2010 12:06 AM

    Originally posted by: far123


    According to my experience with ODME3.3, it may not be possible to use excel file to handle 3 dimensional arrays. You can use .dat file instead.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Tuple element

    Posted Tue September 07, 2010 12:40 AM

    Originally posted by: harshniu


    The linking of tuple to excel file enables me to access the multi-dimensional data. There is no problem with that. The problem is 'how to read multiple lines from the excel spreadsheet. e.g. D1 :D36. I am using that counter 't' to do that. But it does not take values dynamically.

    And till now I haven't seen a .dat file containing data for 3-dimensional array. Can you explain how to do that?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Tuple element

    Posted Tue September 07, 2010 01:04 AM

    Originally posted by: far123


    The below 2*4*3 array is an example of 3 dimensional array in .dat file.
    [[[1,0,1] [1,1,0] [1,0,1] [0,0,1]]
     [[1,0,1] [1,1,0] [1,0,1] [0,0,1]]]
    

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Tuple element

    Posted Tue September 07, 2010 01:45 AM

    Originally posted by: harshniu


    Thanks , that does answer my question about 3-D in .dat file. But the reason i shifted to tuples is because I have like hundreds of data files in .txt format & it is impossible to convert each one of them into the desired .dat format. So, I converted them into a column in a spreadsheet writing a .cpp code. Now I have the files in the excel format. So, can you help me with my original problem?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Tuple element

    Posted Tue September 07, 2010 04:43 PM

    Originally posted by: SystemAdmin


    There is a FAQ to read a 3-D array from Excel: http://www-01.ibm.com/support/docview.wss?rs=0&context=SSCMS55&uid=swg21401340&loc=en_US&cs=utf-8&cc=us&lang=all but this FAQ assumes you already know the size of the array.
    If the issue you're facing is more related to the range that is only known at runtime, maybe you could use named range in your Excel spreadsheet ?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Tuple element

    Posted Tue September 07, 2010 05:15 PM

    Originally posted by: UDOPS


    Correct me if I am wrong, but the constraint definition appears wrong and this issue may have nothing to do with data files. In the "for" statement, you define ranges for i, j, k; but only list t as a limiting condition. If you want to read from the tuple set, shouldn't it be "for (<i,j,k,t> in timestotal: t ==((((n+1)*j)+i-n)*(k-1))) " ?

    By the way, I think this would be a lot more efficient if you separated the set in your excel file first, rather than parse it in OPL, since the test is a static condition.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer