Click here to Skip to main content
15,889,852 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Help to predict the output of this code Pin
Daniel Pfeffer9-Jan-19 21:48
professionalDaniel Pfeffer9-Jan-19 21:48 
AnswerRe: Help to predict the output of this code Pin
ChrisFromWales1-May-19 0:14
ChrisFromWales1-May-19 0:14 
PraiseDinic’s algorithm for Maximum Flow Pin
AshishKhuraishy6-Dec-18 3:56
AshishKhuraishy6-Dec-18 3:56 
GeneralRe: Dinic’s algorithm for Maximum Flow Pin
Patrice T25-Dec-18 16:15
mvePatrice T25-Dec-18 16:15 
SuggestionVector representation of the code. Pin
Member 1406583326-Nov-18 7:50
Member 1406583326-Nov-18 7:50 
GeneralRe: Vector representation of the code. Pin
Gerry Schmitz27-Nov-18 9:19
mveGerry Schmitz27-Nov-18 9:19 
GeneralRe: Vector representation of the code. Pin
shooky561-Dec-18 5:04
shooky561-Dec-18 5:04 
QuestionOptimal Task Scheduling with Complete Knowledge Pin
Member 140435574-Nov-18 12:11
Member 140435574-Nov-18 12:11 
Hi all,

I'm hoping someone can help me out with an algorithm question I got stuck on, while contemplating optimal scheduling algorithms (as one does lol).

Consider a basic task scheduling system, where there's a queue of "Tasks" that need to get done, a pool of "Workers" that can execute work (one at a time), and a scheduler that pulls work form the queue and assigns to the workers in some fashion.
( [Task1] [Task2] [Task3] ... [TaskT] ) ---> [Scheduler] ===> ( [Worker1] [Worker2] ... [WorkerN] )

I've been thinking about various optimal scheduling algorithms for such a system, with various parameters.

For this discussion, let's assume:
  1. The work is uniform (all Task units are exactly the same).
  2. "Optimal Scheduling" just means "If I add a bunch of work to the queue, all of it will be completed ASAP."

The Trivial Case


If, in addition to tasks being uniform, all workers are perfectly uniform, it's easy to see that assigning the work to the first available free worker is optimal, and that the scheduler can just be a dumb round-robin allocator of work.

The Heterogeneous Worker Case


Suppose we have an added constraint: Not all workers are the same; they take different amounts of time to perform a work unit. Maybe they run on a heterogeneous fleet, and some are on better hardware....

In that case, if we want optimal scheduling, we can do so greedily, by always assigning to the worker that will become available the soonest given one more unit of work (i.e. "store workers in a priority queue sorted by 'when it will be done with all its work, given one more unit of work'")

The Heterogeneous Worker with Scheduled Work Case


Ok, THIS is the one I am stuck on.

Suppose, in addition to the workers being different, we ALSO have a constraint where each unit of work becomes available at a specific time t into the execution.

The aforementioned greedy approach won't work anymore. Consider this example:

Workers:
  • W1 takes 8 minutes to finish a work item.
  • W2 takes 10 minutes to finish a work item.
Work:
  • Task1 is available immediately (t = 0)
  • Task2 is available one minute in (t = 1)
With the greedy algorithm: T1 will be assigned to W1, and T2 will be assiged to W2 one minute in, resulting in all work completing after 11 minutes.

However, the optimal solution is, T1 gets assigned to W2, and T2 gets assigned to W1, making T1 the long pole, and allowing the work to complete in only 10 minutes.

Intuitively, it kind of feels like this has to become a search/backtracking problem, perhaps with heavy pruning of nonsensical choices, but... is there a simpler solution I'm missing? I keep getting the sense that there's a viable DP approach, if we're generous with things like declaring all times are integers, and throwing everything at the slowest worker is guaranteed to take less than some reasonably small amount of time...

... or maybe there IS a greedy solution, and I'm just not seeing it...

Any thoughts/direction here?
AnswerRe: Optimal Task Scheduling with Complete Knowledge Pin
Mycroft Holmes4-Nov-18 19:31
professionalMycroft Holmes4-Nov-18 19:31 
GeneralRe: Optimal Task Scheduling with Complete Knowledge Pin
Member 140435575-Nov-18 1:37
Member 140435575-Nov-18 1:37 
AnswerRe: Optimal Task Scheduling with Complete Knowledge Pin
Gerry Schmitz12-Nov-18 8:20
mveGerry Schmitz12-Nov-18 8:20 
QuestionChess Futility pruning Pin
GM Fafkorn5-Oct-18 22:13
GM Fafkorn5-Oct-18 22:13 
QuestionAlgorithms help Pin
Member 139775798-Sep-18 7:36
Member 139775798-Sep-18 7:36 
QuestionStart with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Member 139396526-Aug-18 5:08
Member 139396526-Aug-18 5:08 
AnswerRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Stefan_Lang7-Aug-18 23:29
Stefan_Lang7-Aug-18 23:29 
AnswerRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Gerry Schmitz8-Aug-18 8:38
mveGerry Schmitz8-Aug-18 8:38 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Stefan_Lang8-Aug-18 21:12
Stefan_Lang8-Aug-18 21:12 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Gerry Schmitz9-Aug-18 9:52
mveGerry Schmitz9-Aug-18 9:52 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Stefan_Lang9-Aug-18 21:42
Stefan_Lang9-Aug-18 21:42 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Kenneth Haugland9-Aug-18 22:25
mvaKenneth Haugland9-Aug-18 22:25 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Gerry Schmitz11-Aug-18 9:19
mveGerry Schmitz11-Aug-18 9:19 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Gerry Schmitz10-Aug-18 7:38
mveGerry Schmitz10-Aug-18 7:38 
GeneralRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Stefan_Lang27-Aug-18 0:25
Stefan_Lang27-Aug-18 0:25 
AnswerRe: Start with a group of size X, divide it into Y groups, Z times, minimize overlap Pin
Patrice T1-Sep-18 16:42
mvePatrice T1-Sep-18 16:42 
QuestionSimplex Downhill... Pin
User 110609793-Aug-18 9:35
User 110609793-Aug-18 9:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.