@@ -4,28 +4,28 @@ public class LoadBalancing {
4
4
public void balanceMachines (int machineCount , int [][] jobs ){
5
5
Arrays .sort (jobs , (a , b ) -> -Integer .compare (a [1 ], b [1 ])); //Sort by longest processing time 1st
6
6
7
- ArrayList <ArrayList <ArrayList <Integer >>> jobsForMachine = new ArrayList <ArrayList <ArrayList <Integer >>>();
7
+ // ArrayList<ArrayList<ArrayList<Integer>>> jobsForMachine = new ArrayList<ArrayList<ArrayList<Integer>>>();
8
8
PriorityQueue <Machine > loads = new PriorityQueue <Machine >();
9
9
for (int i =0 ; i <machineCount ; i ++){
10
10
loads .add (new Machine (i ));
11
- jobsForMachine .add (new ArrayList <ArrayList <Integer >>());
11
+ // jobsForMachine.add(new ArrayList<ArrayList<Integer>>());
12
12
}
13
13
14
14
for (int j =0 ; j <jobs .length ; j ++){
15
15
Machine smallestLoadMachine = loads .remove ();
16
- int i = smallestLoadMachine . getId () ;
16
+ int jobId = jobs [ j ][ 0 ] ;
17
17
int jobProcessingTime = jobs [j ][1 ];
18
- jobsForMachine .get (i ).add (new ArrayList <Integer >(Arrays .asList (jobs [j ][0 ], jobProcessingTime )) );
18
+ // int i=smallestLoadMachine.getId();
19
+ // jobsForMachine.get(i).add(new ArrayList<Integer>(Arrays.asList(jobs[j][0], jobProcessingTime)) );
20
+
21
+ System .out .println (smallestLoadMachine );
19
22
20
- int jobId =jobs [j ][0 ];
21
23
smallestLoadMachine .addJob (jobId , jobProcessingTime );
22
-
23
- System .out .println (smallestLoadMachine );
24
24
25
25
smallestLoadMachine .setCurrentLoad (smallestLoadMachine .getCurrentLoad () + jobProcessingTime );
26
26
loads .add (smallestLoadMachine ); //Adding machine back does increaseKey
27
27
28
- System .out .println (smallestLoadMachine +"\n " );
28
+ System .out .println (smallestLoadMachine +"\n " );
29
29
}
30
30
31
31
int makespan = 0 ;
0 commit comments