我考虑了4个成本要素。我得到了处理成本,库存成本和公用事业成本的答案,但是我无法获得与序列有关的转换成本。谁能帮助我编写有关转换时间和成本的代码?
using CP;
// Number of Machines (Packing + Manufacturing)
int nbMachines = 3;
range Machines = 1..nbMachines;
// Number of Jobs
int nbJobs = 18;
range Jobs = 1..nbJobs;
//Processing time
int Ptime[Jobs,Machines] = [
//processing cost
int Pcost[Jobs,Machines] =[
int Start[Jobs] =[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
int due [Jobs] =
[8640,8640,8640,8640,8640,8640,8640,8640,8640,8640,8640,
8640,8640,8640,8640,8640,8640,8640];
int Ctime[Jobs, Jobs]=[
int ChangeCost[Jobs, Jobs]=200*Ctime;
int UtilityCost[Jobs,Machines] = 55*Ctime;
int InvCost[Jobs, Machines] = 55*Ctime;
int Utility[Jobs,Machines];
int Inv[Jobs, Machines];
//decision variables
dvar interval task[j in Jobs] in Start[j]..due[j];
dvar interval opttask[j in Jobs][m in Machines] optional size Ptime[j][m];
dvar sequence tool[m in Machines] in all(j in Jobs) opttask[j][m];
execute {
cp.param.FailLimit = 50000;
}
// Minimize the total processing cost (24)
minimize
sum(j in Jobs, m in Machines) (Pcost[j][m] * presenceOf(opttask[j][m])+
ChangeCost[j][j]*(Ctime[j][j]) +
UtilityCost[j][m] * Utility[j][m] + InvCost[j][m] * Inv[j][m]);
subject to {
// Each job needs one unary resource of the alternative set s (28)
forall(j in Jobs,m in Machines)
alternative(task[j], all(m in Machines) opttask[j][m]);
forall( j in Jobs , m in Machines )
Start[j] + Ptime[j][m] + Ctime[j][j]<= due[j];
// No overlap on machines
forall(j in Jobs ,m in Machines)
noOverlap(tool[m]);
};
execute {
writeln(task+Ctime[j][j]);
};