Approximation Algorithm for the NP-Complete problem of balancing job loads on machines. Does not guarantee an optimal solution, but instead, a solution is within a factor of 1.5 of the optimal solution
Approximation Algorithm for the NP-Complete problem of balancing job loads on machines. (Could be applied to processes management on a CPU). Does not guarantee an optimal solution, but instead, a solution is within a factor of 1.5 of the optimal solution.
M
identical machinesN
jobsJ(i)
is the subset of jobs assigned to machine i
i
is Li = sum of the processing times for the jobs on that machineMakespan = the maximum of the loads on the machines (the machine with the largest load)
Goal: Minimize the Makespan
Assign each job to a machine to minimize makespan
There are mn different assignments of n jobs to m machines, which is exponential
The greedy solution runs in polynomial time and gives a solution no more than 1.5 times the optimal makespan
Proof involves complicated sigma notation and can be found in the references
Sort jobs by largest processing time 1st & keep assigning jobs to the machine with the smallest load
Machine ID’s are meaningless since machines are identical, they’re created for readability.
But the algorithm still creates the job assignments on the machines according to the greedy strategy
int machineCount
parameter is how many machines there areint[][] jobs
is a 2D array containing the jobsjobs[i]
is an array represents a jobjobs[i][0]
is the Job Id or namejobs[i][1]
is the Processing timeMachine
object in the Priority QueueM
machines with unique Id’sIncreaseKey()
method so the same effect is achieved by removing the machine from the Queue, updating the Machine’s currentLoad
and then adding the Machine back to the QueueMachine
class represents a machineid
is the ID or name of the machinecurrentLoad
is the sum of the processing times of the jobs currently assigned to the machinejobs
is a 2D ArrayList containing the jobs currently assigned to the machineMachine
class overrides compareTo()
from the Comparable
interface so that the `PriotityQueue is always has the smallest load machine at the top