如何在灵活的作业车间编写一个操作的后继者在同一台机器上完成?

问题描述 投票:1回答:1

在模型中,我们有3个必须为每个Job执行的操作。我想如果在OR类型的机器中处理操作1,则操作2和操作3也必须在OR类型的同一台机器上执行,如果它们是在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]);  

}
constraint-programming opl cp-optimizer
1个回答
1
投票

我认为您需要做的就是在区间变量的存在之间发布一些二元约束。类似于:presenceOf(mode1) => !presenceOf(mode2),其中mode1OR类型的机器上的操作1的分配,而mode2是在类型OR的机器上分配操作2,不同于mode1。这就是你想要的:禁止在OR类型的机器上分配操作2(与操作3相同),但操作1除外。

© www.soinside.com 2019 - 2024. All rights reserved.