Browse Source

Add method to access tasks in resource order

Arthur Bit-Monnot 5 months ago
parent
commit
f6d78491ba

+ 2
- 2
src/main/java/jobshop/MainTest.java View File

@@ -16,13 +16,13 @@ public class MainTest {
16 16
             // load the aaa1 instance
17 17
             Instance instance = Instance.fromFile(Paths.get("instances/aaa1"));
18 18
 
19
-            // builds a solution in the job-numbers encoding [0 1 1 0 0 1]
19
+            // builds a solution in the job-numbers encoding [0 0 1 1 0 1]
20 20
             JobNumbers enc = new JobNumbers(instance);
21 21
             enc.addTask(0);
22
+            enc.addTask(0);
22 23
             enc.addTask(1);
23 24
             enc.addTask(1);
24 25
             enc.addTask(0);
25
-            enc.addTask(0);
26 26
             enc.addTask(1);
27 27
 
28 28
             System.out.println("\nENCODING: " + enc);

+ 10
- 0
src/main/java/jobshop/encodings/ResourceOrder.java View File

@@ -62,6 +62,16 @@ public class ResourceOrder extends Encoding {
62 62
         nextFreeSlot[machine] += 1;
63 63
     }
64 64
 
65
+    /** Returns the i-th task scheduled on a particular machine.
66
+     *
67
+     * @param machine Machine on which the task to retrieve is scheduled.
68
+     * @param taskIndex Index of the task in the queue for this machine.
69
+     * @return The i-th task scheduled on a machine.
70
+     */
71
+    public Task getTaskOfMachine(int machine, int taskIndex) {
72
+        return tasksByMachine[machine][taskIndex];
73
+    }
74
+
65 75
     /** Exchange the order of two tasks that are scheduled on a given machine.
66 76
      *
67 77
      * @param machine Machine on which the two tasks appear (line on which to perform the exchange)

Loading…
Cancel
Save