Package org.pipecraft.infra.math
Class StaticJobScheduler<J>
- java.lang.Object
-
- org.pipecraft.infra.math.StaticJobScheduler<J>
-
- Type Parameters:
J- the job type
public class StaticJobScheduler<J> extends Object
Schedules n "jobs" among m "workers", trying to minimize the makespan. In this class we assume a simple version of the problem: - Jobs have weights known in advance - Workers are homogeneous - There are no job dependencies or assignment restrictions Since the problem is NP-complete, we use a simple approximation - LPT (See https://en.wikipedia.org/wiki/Multiprocessor_scheduling#Algorithms). This algorithm runs in O(m*log(m)) time and achieves (4/3 - 1/(3*m)) approximation factor, i.e. it is never more than 33% above the optimal result.- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description StaticJobScheduler(Collection<J> jobs, Function<J,Double> weightFunction)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Collection<J>>schedule(int workerCount)Performs the job scheduling, returning the full assignment of jobs to workers.
-
-
-
Constructor Detail
-
StaticJobScheduler
public StaticJobScheduler(Collection<J> jobs, Function<J,Double> weightFunction)
Constructor- Parameters:
jobs- The set of jobs to scheduleweightFunction- A function specifying how to extract the weight of a given job. Must be a valid, consistent function, returning non-negative values.
-
-
Method Detail
-
schedule
public List<Collection<J>> schedule(int workerCount)
Performs the job scheduling, returning the full assignment of jobs to workers.- Parameters:
workerCount- The number of workers- Returns:
- A partitioning of the jobs given in the constructor into the workerCount workers. Item at index i contains all jobs assigned to worker i. The numbering of the workers is arbitrary, but consistent. Each job collection is guaranteed to be ordered in descending job weight order (when iterating it).
-
-