Using the following formulation for the objective, one can also minimize idle time:
In this formulation, one adds both maximum end time and idle times.
One may want a weighted combination.
Note also that solve time is also longer when using this objective.
Original Message:
Sent: Sun September 10, 2023 10:15 AM
From: Pedro Casal
Subject: Idle Time Calculation in sched_jobshop
Hello again,
I was now wondering if its possible to create a model that minimizes both makespan and idle time? Until now, for what i'm understanding, the idle time calculations have been after the minimization of the makespan so maybe it isnt possible to minimize it together with the makespan? (creating a pareto frontier and then seeing the possible candidates)
------------------------------
Pedro Casal
Original Message:
Sent: Mon September 04, 2023 05:05 AM
From: Olivier Lhomme
Subject: Idle Time Calculation in sched_jobshop
Sorry, I made a typo... I edited my first answer, replacing nbMachs by nbJobs in the 2nd loop:
for(var i = 0; i < nbJobs ; i++)
------------------------------
Olivier Lhomme
Original Message:
Sent: Fri September 01, 2023 10:03 PM
From: Pedro Casal
Subject: Idle Time Calculation in sched_jobshop
Thank you very much Olivier! I just have one more question. Does this script work well if the number of jobs is higher than machines? for example a problem instance with 20 jobs and 15 machines. I'm trying another problem instance and the idle time is giving incorrect values.
<1 0 59 59>
<1 59 129 70>
<1 129 225 96>
<1 225 227 2>
<1 227 322 95>
<1 322 372 50>
<1 372 431 59>
<1 431 487 56>
<1 487 556 69>
<1 556 632 76>
<1 632 637 5>
<1 637 667 30>
<1 667 737 70>
<1 737 764 27>
<1 764 798 34>
Idle time for machine 1 = 679
this is the scripting log for machine 1 and it only gives 15 values (it should give 20 since there are 20 jobs) and i have no idea from where that "679" came from. for that 15 values it should be actually 0.
Thank you again!
------------------------------
Pedro Casal
Original Message:
Sent: Fri September 01, 2023 11:34 AM
From: Olivier Lhomme
Subject: Idle Time Calculation in sched_jobshop
if each machine is started at the start of its first operation, you can use:
writeln("Idle time for machine " + m + " = " + (mchs[m].last().end - mchs[m].first().start - usage));
------------------------------
Olivier Lhomme
Original Message:
Sent: Fri September 01, 2023 11:06 AM
From: Pedro Casal
Subject: Idle Time Calculation in sched_jobshop
Hi Olivier thank you very much also for the contribution!! Just in case David doesn't see my reply, i would also like to ask you if you know what would i change in the script if i don't want to assume the initial time between 0 and the actual start of the first task of each machine as idle time?
------------------------------
Pedro Casal
Original Message:
Sent: Fri September 01, 2023 05:25 AM
From: Olivier Lhomme
Subject: Idle Time Calculation in sched_jobshop
To complete the answer from David, as you use a sequence variable you can directly access the last interval variable of the sequence, hence its ending time with "mchs[m].last().end".
Then, you need to substract the durations of the interval in the sequence: you can iterate over all the interval variables of the sequence with "s=mchs[m].first()" and "s=mchs[m].next(s)".
For example:
execute { for (var m = 0; m < nbMchs; m++) { var s=mchs[m].first(); var usage = 0; for(var i = 0; i < nbMchs; i++) { usage = usage + s.length; writeln(s); s=mchs[m].next(s) ; } writeln("Idle time for machine " + m + " = " + (mchs[m].last().end - usage)); }}
------------------------------
Olivier Lhomme
Original Message:
Sent: Tue August 29, 2023 12:55 PM
From: Pedro Casal
Subject: Idle Time Calculation in sched_jobshop
Hello! I'm starting to use cplex optimizer and i'm not being able to calculate the idle time in the model provided by cplex itself called sched_jobshop
How can i calculate the idle time per machine? (starting time of work i in machine m - ending time of work i-1 in machine m). I would like to assume that i turn on the machines all at time 0 and therefore if the first activity of a machine only starts at time 3 then this counts as idle time also.
using CP;
int nbJobs = ...;
int nbMchs = ...;
range Jobs = 0..nbJobs-1;
range Mchs = 0..nbMchs-1;
// Mchs is used both to index machines and operation position in job
tuple Operation {
int mch; // Machine
int pt; // Processing time
};
Operation Ops[j in Jobs][m in Mchs] = ...;
dvar interval itvs[j in Jobs][o in Mchs] size Ops[j][o].pt;
dvar sequence mchs[m in Mchs] in all(j in Jobs, o in Mchs : Ops[j][o].mch == m) itvs[j][o];
execute {
cp.param.FailLimit = 10000;
}
minimize max(j in Jobs) endOf(itvs[j][nbMchs-1]);
subject to {
forall (m in Mchs)
noOverlap(mchs[m]);
forall (j in Jobs, o in 0..nbMchs-2)
endBeforeStart(itvs[j][o], itvs[j][o+1]);
}
execute {
for (var j = 0; j <= nbJobs-1; j++) {
for (var o = 0; o <= nbMchs-1; o++) {
write(itvs[j][o].start + " ");
}
writeln("");
}
}
data:
nbJobs = 6;
nbMchs = 6;
Ops = [
[ <5,4>, <1,3>, <4,3>, <3,2>, <0,1>, <2,2> ],
[ <1,3>, <0,8>, <5,7>, <2,2>, <4,9>, <3,3> ],
[ <3,1>, <4,9>, <1,9>, <0,7>, <5,5>, <2,5> ],
[ <3,8>, <4,2>, <1,1>, <5,7>, <2,8>, <0,9> ],
[ <1,6>, <3,2>, <4,5>, <5,5>, <0,3>, <2,1> ],
[ <4,10>, <2,4>, <0,4>, <3,3>, <1,2>, <5,3> ]
];
Thank you so much!
------------------------------
Pedro Casal
------------------------------