Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  matrix size

    Posted 09/24/17 03:48 PM

    Originally posted by: user1234567


    Hello, i have a variable size of a matrix. Each Job have 5 or 6 operations which is declared as follows in the .DAT:

    nbJobs = 10;
    nbMchs = 36;
    nbOper=36;

    Ops = [
     [ <1,1,1,5>,<1,1,2,0>,<1,1,3,4>,<1,1,4,0>,<1,1,5,0>, <1,1,6,0> ,<2,1,1,0>,<2,1,2,1>, <2,1,3,5>, <2,1,4,0>, <2,1,5,3>, <2,1,6,0> ,<3,1,1,0>,<3,1,2,0>, <3,1,3,4>, <3,1,4,0>, <3,1,5,0>, <3,1,6,2> ,<4,1,1,1>,<4,1,2,6>, <4,1,3,0>, <4,1,4,0>, <4,1,5,0>, <4,1,6,5> ,<5,1,1,0>,<5,1,2,0>, <5,1,3,1>, <5,1,4,0>, <5,1,5,0>, <5,1,6,0> ,<6,1,1,3>,<6,1,2,0>, <6,1,3,6>, <6,1,4,3>, <6,1,5,0>, <6,1,6,6> ],
     
      
     [ <1,2,1,0>,<1,2,2,6>, <1,2,3,0>, <1,2,4,0>, <1,2,5,0>,<1,2,6,0> ,<2,2,1,0>,<2,2,2,0>, <2,2,3,1>, <2,2,4,0>, <2,2,5,0>,<2,2,6,0> ,<3,2,1,2>,<3,2,2,0>, <3,2,3,0>, <3,2,4,0>, <3,2,5,0>,<3,2,6,0> ,<4,2,1,0>,<4,2,2,6>, <4,2,3,0>, <4,2,4,6>, <4,2,5,0>,<4,2,6,0> ,<5,2,1,1>,<5,2,2,6>, <5,2,3,0>, <5,2,4,0>, <5,2,5,0>,<5,2,6,5> ],
     
     [ <1,3,1,0>,<1,3,2,6>, <1,3,3,0>, <1,3,4,0>, <1,3,5,0>,<1,3,6,0> ,<2,3,1,0>,<2,3,2,0>, <2,3,3,4>, <2,3,4,0>, <2,3,5,0>,<2,3,6,2> ,<3,3,1,1>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,2>,<4,9,2,0>, <4,9,3,0>, <4,9,4,0>, <4,9,5,0>,<4,9,6,0> ,<5,9,1,0>,<5,9,2,6>, <5,9,3,4>, <5,9,4,0>, <5,9,5,0>,<5,9,6,6> , <6,9,1,0>,<6,9,2,6>, <6,9,3,0>, <6,9,4,6>, <6,9,5,0>,<6,9,6,0> ], 

     [ <1,10,1,0>,<1,10,2,0>, <1,10,3,4>, <1,10,4,0>, <1,10,5,0>,<1,10,6,2> ,<2,10,1,0>,<2,10,2,6>, <2,10,3,4>, <2,10,4,0>, <2,10,5,0>,<2,10,6,6> ,<3,10,1,0>,<3,10,2,1>, <3,10,3,5>, <3,10,4,0>, <3,10,5,3>,<3,10,6,0> ,<4,10,1,0>,<4,10,2,0>, <4,10,3,0>, <4,10,4,0>, <4,10,5,0>,<4,10,6,1> ,<5,10,1,0>,<5,10,2,6>, <5,10,3,0>, <5,10,4,6>, <5,10,5,0>,<5,10,6,0> , <6,10,1,3>,<6,10,2,0>, <6,10,3,0>, <6,10,4,2>, <6,10,5,0>,<6,10,6,0> ]
     
    ];

    In the .MOD, it is declared as follows:

    tuple Operation {
     int id;
     int jobId;
     int mch; // Machine
     int pt;  // Processing time

    };


    Operation Ops[i in Jobs][j in Oper] = ...;

    But the problem is that the program takes more than hour and does not dispaly anything ! So, i think that the problem comes from the declaration of the data and because that the column size is different from one job to another (sometimes 6 operations, sometimes 5 operations).

    How can i write this data correctly ? Thank you.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: matrix size

    Posted 09/25/17 02:46 AM

    Hi

    .mod

    int nbJobs = ...;
    int nbMchs = ...;
    int nbOper=...;

    range Oper=1..nbOper;
    range Jobs=1..nbJobs;
     
     tuple Operation {
     int id;
     int jobId;
     int mch; // Machine
     int pt;  // Processing time

    };


    Operation Ops[i in Jobs][j in Oper] = ...;

    execute
    {
    writeln(Ops);
    }

    .dat

    nbJobs = 10;
    nbMchs = 36;
    nbOper=36;

    Ops = [
     [ <1,1,1,5>,<1,1,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>,<1,10,6,2> ,<2,10,1,0>,<2,10,2,6>, <2,10,3,4>, <2,10,4,0>, <2,10,5,0>,<2,10,6,6> ,<3,10,1,0>,<3,10,2,1>, <3,10,3,5>, <3,10,4,0>, <3,10,5,3>,<3,10,6,0> ,<4,10,1,0>,<4,10,2,0>, <4,10,3,0>, <4,10,4,0>, <4,10,5,0>,<4,10,6,1> ,<5,10,1,0>,<5,10,2,6>, <5,10,3,0>, <5,10,4,6>, <5,10,5,0>,<5,10,6,0> , <6,10,1,3>,<6,10,2,0>, <6,10,3,0>, <6,10,4,2>, <6,10,5,0>,<6,10,6,0> ]
     
    ];

    works fine

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: matrix size

    Posted 09/25/17 06:19 AM

    Originally posted by: user1234567


    Alex, can you try this please, with the same .DAT:

    int L=1000;

    int nbJobs = ...;
    int nbMchs = ...;
    int nbOper = ...;

     

    range Jobs = 1..nbJobs;
    range Mchs = 1..nbMchs;
    range Oper = 1..nbOper;

    // Mchs is used both to index machines and operation position in job (cijk)
    tuple Operation {
     int id;
     int jobId;
     int mch; // Machine
     int pt;  // Processing time

    };


    Operation Ops[i in Jobs][j in Oper] = ...;
     
    dvar int+ s[j in Jobs][o in Mchs];
    dvar int+ c[j in Jobs][o in Mchs];

      dvar boolean X[i in Jobs][j in Oper][k in Mchs];
      dvar int+ e[i in Jobs][j in Oper][k in Mchs];
      dvar boolean y[i1 in Jobs][j1 in Oper][i2 in Jobs][j2 in Oper][k in Mchs];
     
     
    minimize max(j in Jobs, k in Mchs) c[j][k];
    subject to {

     

    forall (j in Jobs, o in 1..nbMchs) c[j][o]-s[j][o]==Ops[j][o].pt;

     

       forall (o1,o2 in Mchs) 
       forall(i,j in Jobs:(Ops[i][o1].mch==Ops[j][o2].mch) && ((i!=j) || (o1!=o2)))
       (s[i][o1]>=c[j][o2]) || (s[j][o2]>=c[i][o1]);
       
        
        
     forall (j in Jobs, g in Jobs: j==g, o in 1..nbMchs-1, w in 1..nbMchs)
            if (Ops[j][o].id==Ops[g][w].id   &&   Ops[j][o+1].mch==Ops[j][w].mch + 1 )
         
        
        s[j][o+1]==c[j][o];
        
        
        //Operations of the same job with successive id on successive machines 
        //(example O11 on machine 0 And O21 on machine 1)
        //The start time of the second operation is the completion time of the first operation.
         forall (j in Jobs, g in Jobs: j==g, o in 1..nbMchs-1, w in 1..nbMchs)
            if (Ops[j][o].id==Ops[g][w].id + 1   &&   Ops[j][o+1].mch==Ops[j][w].mch + 1 )
         
        
        s[j][o+1]==c[j][o];
        
        
        forall (i in Jobs, j in Oper, k in Mchs: Ops[i][j].mch==k)
        
        X[i][j][k]==1;
        
        forall(i in Jobs,j in Oper, k in Mchs: (Ops[i][j].mch==k))
      
    e[i][j][k]==1;  
        
        //C1
            forall (i in Jobs, j in Oper)
        
        sum (k in Mchs) X[i][j][k]==1;
        
       
    //C2
    forall(i in Jobs,j in Oper, k in Mchs)
      
    sum (i in Jobs, j in Oper) X[i][j][k]==1 <= e[i][j][k];            

     

      //Precedence
      forall( k in Mchs,o1 in Mchs, o2 in Mchs, i1,i2 in Jobs: i1!=i2, j1 in Oper, j2 in Oper : j1!=j2 &&
    Ops[i1][o1].mch==Ops[i2][o2].mch==k && Ops[i1][o1].id==j1 && Ops[i2][o2].id==j2 &&
     Ops[i1][o1].jobId==i1 && Ops[i2][o2].jobId==i2 )
     
     
     
      y[i1][j1][i2][j2][k] == (c[j1][k]>=s[j2][k])|| (c[j2][k]>=s[j1][k]) ;
      
      
      //C3
      forall (i1,i2 in Jobs,j2 in Oper, k in Mchs)
    sum (j1 in Oper) y[i1][j1][i2][j2][k] <= 1;

      
        

    //C10
    forall (i in Jobs, k in Mchs, j in Oper)
    sum (k in Mchs) c[i][k] >=  c[i][k];

    //C11
    forall (i in Jobs, k in Mchs)
    max(i in Jobs, k in Mchs) c[i][k] >= c[i][k];

    //C12
    forall (i in Jobs, k in Mchs )
    c[i][k]>=0;
           
                              
    }

    execute {
      for (var j = 1; j <= nbJobs; j++) {
        for (var o = 1; o <= nbMchs; o++) {
     
            
        
          write("Start time of operation" +o+ "job" +j+ "on machine" +o+ "equal to" +s[j][o]+ "and end at" +c[j][o]+ " ");
        } 
        writeln("");
      }
    }  

     

    Thank you


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: matrix size

    Posted 09/25/17 07:02 AM

    Hi,

    your model consumes all available memory on my machine.

    if you write

    nbMchs2 = 36;

    in your .dat and

    int nbMchs=2;

    in your .mod then you ll get a solution quickly.

    So my advice would be either to improve your model or to rely on CPO

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: matrix size

    Posted 09/26/17 06:59 AM

    I ran your model here and CPLEX claims it is infeasible.


    #CPLEXOptimizers
    #DecisionOptimization