Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm to calculate next set in sequence

Tags:

algorithm

I am looking for an algorithm to calculate the next set of operations in a sequence. Here is the simple definition of the sequence.

  1. Task 1A will be done every 500 hours
  2. Task 2A will be done every 1000 hours
  3. Task 3A will be done every 1500 hours

So at t=500, do 1A. At t=1000, do both 1A and 2A, at t=1500 do 1A and 3A, but not 2A as 1500 is not a multiple of 1000. You get the idea.

It would be quite easy if I had the actual time, but I don't. What I have is the history of tasks (eg last time a [1A+2A] was done).

Knowing last time (eg [1A+2A]) is not enough to decide:

  • [1A+2A] could be at t=1000: next is [1A+3A] at t=1500
  • [1A+2A] could be at t=5000: next is [1A] at t=5500

Is there an algorithm for this? It looks like a familiar problem (some sort of sieve?) but I can't seem to find a solution.

Also it must "scale" as I actually have more than 3 tasks.

like image 866
Christian Lescuyer Avatar asked Mar 02 '23 06:03

Christian Lescuyer


1 Answers

If you have enough history to get the last two times each task was done you could reconstruct the original task sequence definitions. When they coincide is incidental.

like image 51
Bill the Lizard Avatar answered Mar 11 '23 09:03

Bill the Lizard