-3

I have the following problem. Imagine a set of jobs, with start time (st) and end time (et). Each job has a priority value. I need to schedule these jobs using a number of machines greater than 1.

Basically is the same problem of the classroom interval scheduling with multiple classes, but instead of weights I have priorities.I dont need to maximize the weights, i just need to be sure that a job with higher priority will not be discarded while another job with lower priority is selected and overlaps it.

Also, the machines must be occupied the majority of the time.

Is this similar to other known problems? Help :S

Edit with an example and my thoughts (Input jobs are given ordered):

----(a)0
  ----(b)1
   --------------------------(c)2
    -----------(d)3
      ----(e)5
        ------------------------(f)3
                     --------(g)4

                     ---------(h)4

                     ---------(i)4

letter= id of the job, number=priority.
For istance, with 1 output queue, the algorithm should be simple:
-check for a local maximum, (i.e. compare subsequent jobs keeping the best one until a job with priority x does not overlap with a job with priority > x). In this case "e" is a local maximum. So we analzye until job f.
-Search for compatible jobs in previous analyzed job, removing jobs that collide. In our case, we analyzed until "f". We can remove jobs that collide with "e", therefore we have "a" and "b" left. and we can repeat the algorithm with "a" and "b", obtaining "b" and "e" as a result. Now we can continue with subsequent jobs that have not been discarded ("g", "h" and "i") and so on.

My problem is in case of multiple output queue.
My idea with 3 output queue for instance:
-pick the local maximum "e".
-pick the best 2 jobs in its collision domain or previous jobs: in our case "d" and "f".
-Check in the collision domain of "d" and "f" if there are 3 jobs with higher priority. In this case discard it and take the best one that collide.
-Must update previous selected job. Suppose that "b" is longer, has priority 2.5 and collide with f. We first pick "f", but then we need to discard it to pick "g", "h" and "i", and pick b.


Thank you in advance

Vap
  • 1
  • 1

1 Answers1

0

Sort the jobs first from highest priority to lowest, and then from shortest to longest. Each one can be added to the "jobs to do list" if there are no more than n overlapping jobs already scheduled. Once you have the full "jobs to do" list, you can order by start time and assign jobs to machines in a single pass.

This is a greedy algorithm and there is a possibility that you do not find the combination that does the most jobs of a given priority. But a lower priority job will never bump a higher priority one.

btilly
  • 43,296
  • 3
  • 59
  • 88
  • i forgot that it must be a real time algorithm – Vap Dec 17 '18 at 16:28
  • @Vap The same idea works. When looking at a job, you only have to figure out what the "jobs to do list" should include for higher priority jobs starting before it finishes. If you have enough jobs that algorithmic efficiency matters, storing jobs so that they are accessible quickly by combinations of time and priority can be done with a quad tree. But I'd bet that complication is not needed. – btilly Dec 17 '18 at 18:30
  • This may be the solution, however i realized that keeping the queue is use most of the time is not a requirement, so i can just skip the time ordering. – Vap Dec 18 '18 at 07:47