constraint-programmingoplcp-optimizer

How to code in a flexible job shop that the successor of an operation is done on the same machine?


In the model we have 3 operations that have to be performed for each Job. I would like that if operation 1 is processed in a machine of type OR, operation 2 and operation 3 also have to be performed on the same machine of type OR if they are performed in a machine of type OR.

using CP;   
int nbJobs = ...;  
int nbMchs = ...;  
int nbOR=...;     //special machine type OR  
int nbIR=...;     //special machine type IR  
int nbSR=...;     //special machine type SR   

range Jobs = 1..nbJobs;  
range Mchs = 1..nbMchs;   
range OR  =1..nbOR;  
range IR = nbOR+1..(nbOR+nbIR);  
range SR=(nbOR+nbIR+1)..(nbOR+nbIR+nbSR);  

tuple Operation {  
int id;    // Operation id  
int jobId; // Job id  
int pos;   // Position in the Job  
};  

tuple Mode {  
int opId; // Operation id  
int mch;  // Machine  
int pt;   // Processing time  
};  
{Operation} Ops=...;  
{Mode}  Modes=...;  

execute {  
    cp.param.FailLimit = 10000;  
}  
// Position of last operation of job j  
int jlast[j in Jobs] = max(o in Ops: o.jobId==j) o.pos;  

dvar interval ops[Ops];   
dvar interval modes[md in Modes] optional size md.pt;  
dvar sequence mchs[m in Mchs] in 
     all(md in Modes: md.mch == m) modes[md];  


minimize 
   max(j in Jobs, o in Ops: o.pos==jlast[j]) endOf(ops[o]);  

subject to {  

    forall (j in Jobs, o1 in Ops, o2 in Ops: 
            o1.jobId==j && o2.jobId==j && o1.pos==2 && o2.pos==3)  
        endAtStart(ops[o1],ops[o2]);  

    forall (j in Jobs, o3 in Ops, o4 in Ops, o5 in Ops: 
            o3.jobId==j && o4.jobId==j && o5.jobId==j && 
            o3.pos==1 && o4.pos==2 && o5.pos==3) {  
        (endOf(ops[o3]) != startOf(ops[o4])) =>
            (endOf(ops[o3]) == startOf(ops[o5]));  
        (endOf(ops[o3]) != startOf(ops[o5])) =>
            (endOf(ops[o3]) == startOf(ops[o4]));    
    }     

    // How to code the following in a correct way?
    // From here...

    forall (j in Jobs, k in OR, l in OR,  m1 in Modes, m2 in Modes:    
            m1.opId == 1+(j-1)*3 && m2.opId == j*3) {  
        if (m1.mch == k && m2.mch == l){  
            m1.mch == m2.mch;  
        }  
    }    

    forall (j in Jobs, k in OR, l in OR, m1 in Modes, m2 in Modes:               
            m1.opId == 2+(j-1)*3 && m2.opId == j*3 && 
            m1.mch == k && m2.mch == l) {  
        if (m1.mch == k && m2.mch == l) {  
            m1.mch == m2.mch;  
        }    
    }   

    forall (j in Jobs, k in OR, l in OR, m in OR, m1 in Modes, 
            m2 in Modes, m3 in Modes: 
            m1.opId == 1+(j-1)*3 && m2.opId == 2+(j-1)*3 &&
            m3.opId == j*3 && m1.mch == k && m2.mch == l && m3.mch == m) {  
        if (m1.mch == k && m2.mch == l && m3.mch == m) {        
            m1.mch == m2.mch == m3.mch;
        }  
    }  

    // ... to here    

    forall (o in Ops)  
        alternative(ops[o], all(md in Modes: md.opId==o.id) modes[md]);  
    forall (m in Mchs)  
        noOverlap(mchs[m]);  

}

Solution

  • I think that all you need to do is to post some binary constraints between the presence of interval variables. Something like: presenceOf(mode1) => !presenceOf(mode2) where mode1 is the allocation of operation 1 on a machine of type OR and mode2 is the allocation of operation 2 on a machine of type OR different from the one of mode1. This is what you want: forbid the allocation of operation 2 (same with operation 3) on a machine of type OR except the one of operation 1.