0

There is N jobs with execution times, deadlines and penalties if job misses deadline. Execution time, deadline and penalty may vary on every job. Only one job can be done at the time. And all jobs must be done. The task is to sort jobs (schedule) that penalty would be minimal.

Do you have any ideas for algorithm or even could share some code examples? I'm really stuck with this task.

JohnnyK
  • 1
  • 2

2 Answers2

0

The name of the problem is the "Job Sequencing problem", and though I don't have my own example to share you can take a look at this https://www.geeksforgeeks.org/job-sequencing-problem-set-1-greedy-algorithm/

Victor
  • 32
  • 6
  • Greedy algorithm all jobs execution time is 1 unit. However in my task every job execution time may vary. – JohnnyK May 13 '18 at 14:26
0

I suppose the penalty when a job misses its deadline is a constant w_j that depends on the job j but not on its lateness value. In the general case the problem is NP Hard (it is 1||sum_j w_j U_j in the classical alpha|beta|gamma notation). It is polynomial in the special case all weights w_j are equal (minimizing number of late jobs).

You can probably find many very efficient problem-specific algorithms to solve this particular problem. If you are interested in generic formulations to solve this problem you could try CP Optimizer [1], in OPL the formulation to solve it would read like:

int n = ...;
int  dd[j in 1..n] = ...; // Deadline for job j
int  pt[j in 1..n] = ...; // Processing time for job j
float w[j in 1..n] = ...; // Penalty for late job j

dvar interval job[j in 1..n] size pt[j]; // Decision variables

minimize sum(j in 1..n) ( w[j]*(endOf(job[j])>=dd[j]) );
subject to {
  noOverlap(all(j in 1..n) job[j]);
}

Here is an even better formulation in CP Optimizer exploiting the notion of optional interval variable: you maximize the waited sum of executed intervals/activities that are constrained to end before the deadline:

int n = ...;
int  dd[j in 1..n] = ...; // Deadline for job j
int  pt[j in 1..n] = ...; // Processing time for job j
float w[j in 1..n] = ...; // Penalty for late job j

dvar interval job[j in 1..n] optional in 0..dd[j] size pt[j]; // Decision variables

minimize n - sum(j in 1..n) ( w[j]*presenceOf(job[j]) );
subject to {
 noOverlap(all(j in 1..n) job[j]);
}

[1] P. Laborie, J. Rogerie, P. Shaw, P. Vilím. IBM ILOG CP optimizer for scheduling. Constraints Journal. April 2018, Volume 23, Issue 2, pp 210–250. http://ibm.biz/Constraints2018.