Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

opl modeling

  • 1.  opl modeling

    Posted 11/27/16 09:03 AM

    Originally posted by: A.Omidi


    Dear Mr. fleischer

    Hi

    I have question about the modeling of a hybrid flow shop scheduling problem. My OPL code is:

    (My model have 3 stages with 2 machines in each stage & 5 parts)

         // Sets
        tuple fm {
                    int part;                  // number of parts
                    int stage;               // number of stages
                    {int} processors;  // number of processors at stage
                    };
        {fm} flow = {<1,1,{1,2}>,<1,2,{1,2}>,<1,3,{1,2}>,
                             <2,1,{1,2}>,<2,2,{1,2}>,<2,3,{1,2}>,
                             <3,1,{1,2}>,<3,2,{1,2}>,<3,3,{1,2}>,
                             <4,1,{1,2}>,<4,2,{1,2}>,<4,3,{1,2}>,
                             <5,1,{1,2}>,<5,2,{1,2}>,<5,3,{1,2}>
                            };
                          
        setof(int) stages = {s.stage | s in flow};
        setof(int) parts =   {p.part | p in flow}; 
        
        // Data
        int Q = 1000;
        float p[stages][parts] = [[10,12,14,16,18],[12,14,16,18,20],[16,18,20,22,24]]; 
        
        // Decision Variables
        dvar float      Cmax;
        dvar boolean x[flow];
        dvar boolean y[parts][parts];
        dvar float+    c[stages][parts];
        dexpr float    z=Cmax;
            
        // Optimization Model
        minimize z;
        subject to {
                            //
                            co1:
                            forall(k in parts)
                            c[1,k] >= p[1,k];
                            //
                            forall(i in stages, k in parts : i>1)
                            c[i,k]-c[i-1,k] >= p[i,k];
                            //
                            forall(k in parts)
                            c[3,k] <= Cmax;
                            //
                            forall(a in flow)
                            x[a] == 1;
                            //
                            forall(i in stages,k,l in parts, a in flow : k<l && a.part < a.part)
                            c[i,k]+Q*(2+y[k,l]-x[a]-x[a]) >= c[i,l]+p[i,k];
                            //
                            forall(i in stages,k,l in parts, a in flow : k<l && a.part < a.part)
                            c[i,l]+Q*(3-y[k,l]-x[a]-x[a]) >= c[i,k]+p[i,l];
        
                        };

     

     

    I try to solve this problem and objective value is 62, but i do not know, is it optimal? 

    I model this problem with other type and solve it, but objective value is 122. (I asked it from you, in the previous topic)

    Alternative model is:

        {int} stage = {1,2,3};
        {int} processors[i in stage] = {s | s in 1..2}; 
        {int} parts = {1,2};

        int Q = 1000;
        float p[stage][parts] = [[10,12,14,16,18],[12,14,16,18,20],[16,18,20,22,24]];
        
        dvar float      Cmax;
        dvar boolean x[i in stage][1..2][k in parts];
        dvar boolean y[parts][parts];
        dvar float+    c[stage][parts];
        dexpr float    z=Cmax;
        
        minimize z;
        constraints {
                            //
                            co1:
                            forall(k in parts)
                            c[1,k] >= p[1,k];
                            //
                            forall(i in stage, k in parts : i>1)
                            c[i,k]-c[i-1,k] >= p[i,k];
                            //
                            forall(k in parts)
                            c[3,k] <= Cmax;
                            //
                            forall(i in stage, j in processors[i],k in parts)
                            x[i,j,k] == 1;
                            //
                            forall(i in stage, j in processors[i],k,l in parts : k<l)
                            c[i,k]+Q*(2+y[k,l]-x[i,j,k]-x[i,j,l]) >= c[i,l]+p[i,k];
                            //
                            forall(i in stage, j in processors[i],k,l in parts : k<l)
                            c[i,l]+Q*(3-y[k,l]-x[i,j,k]-x[i,j,l]) >= c[i,k]+p[i,l];
        
                        }
                        
    execute display { 
    if(cplex.getCplexStatus() == 1) { 
        for(var i in stage)
            for(var j in processors[i])
                for(var k in parts)    {
                    if(x[i][j][k] == 1)
                        writeln(" parts",k," in stage",j," on machine ",i) 
                        continue} 
                             } else{ (" not optimal solution") } 
                                    cplex.epagap=0.0
                                    cplex.epgap=0.0
                            };

     

    Please if it possible for you, help me for modeling this problem.

    Thanks and best regards 

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: opl modeling

    Posted 11/28/16 07:00 AM

    Originally posted by: A.Omidi


    Hi

    About my question, i tried to solve my problem with 2 different modeling, one by use tuple and other by use array. After solved this two model, objective functions are not equal (first is 62 and second is 122). If it possible, check the first model and tell me, is it true and optimal?

    If it false, can please tell me what I keep on forgetting?

     

    Thanks so much

    Best regards

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer