Browse Source

Doc improvments

Arthur Bit-Monnot 5 months ago
parent
commit
b46ed2a951

+ 1
- 1
src/main/java/jobshop/BestKnownResults.java View File

@@ -15,7 +15,7 @@ public class BestKnownResults {
15 15
     /**
16 16
      * Checks whether we have data available for the provided instance.
17 17
      * @param instanceName Name of the instance.
18
-     * @return True if the isntance is known, false otherwise.
18
+     * @return True if the instance is known, false otherwise.
19 19
      */
20 20
     public static boolean isKnown(String instanceName) {
21 21
         return bests.containsKey(instanceName);

+ 0
- 2
src/main/java/jobshop/Main.java View File

@@ -5,12 +5,10 @@ import java.nio.file.Path;
5 5
 import java.nio.file.Paths;
6 6
 import java.util.ArrayList;
7 7
 import java.util.Arrays;
8
-import java.util.HashMap;
9 8
 import java.util.List;
10 9
 import java.util.stream.Collectors;
11 10
 
12 11
 import jobshop.solvers.*;
13
-import jobshop.solvers.neighborhood.Nowicki;
14 12
 import net.sourceforge.argparse4j.ArgumentParsers;
15 13
 import net.sourceforge.argparse4j.inf.ArgumentParser;
16 14
 import net.sourceforge.argparse4j.inf.ArgumentParserException;

+ 3
- 0
src/main/java/jobshop/encodings/JobNumbers.java View File

@@ -16,6 +16,7 @@ public class JobNumbers extends Encoding {
16 16
      * element of `jobs` that has not been set yet. */
17 17
     public int nextToSet = 0;
18 18
 
19
+    /** Creates a new empty encoding. */
19 20
     public JobNumbers(Instance instance) {
20 21
         super(instance);
21 22
 
@@ -23,6 +24,7 @@ public class JobNumbers extends Encoding {
23 24
         Arrays.fill(jobs, -1);
24 25
     }
25 26
 
27
+    /** Cerates a new encoding based on the given schedule. */
26 28
     public JobNumbers(Schedule schedule) {
27 29
         super(schedule.instance);
28 30
 
@@ -48,6 +50,7 @@ public class JobNumbers extends Encoding {
48 50
         }
49 51
     }
50 52
 
53
+    /** Schedule the next task of the given job. */
51 54
     public void addTask(int jobNumber) {
52 55
         this.jobs[nextToSet++] = jobNumber;
53 56
     }

+ 14
- 6
src/main/java/jobshop/encodings/ResourceOrder.java View File

@@ -10,10 +10,10 @@ public class ResourceOrder extends Encoding {
10 10
 
11 11
     // for each machine m, taskByMachine[m] is an array of tasks to be
12 12
     // executed on this machine in the same order
13
-    public final Task[][] tasksByMachine;
13
+    final Task[][] tasksByMachine;
14 14
 
15 15
     // for each machine, indicate how many tasks have been initialized
16
-    public final int[] nextFreeSlot;
16
+    final int[] nextFreeSlot;
17 17
 
18 18
     /** Creates a new empty resource order. */
19 19
     public ResourceOrder(Instance instance)
@@ -51,6 +51,8 @@ public class ResourceOrder extends Encoding {
51 51
         }
52 52
     }
53 53
 
54
+    /** Enqueues a task for the given job on the machine. We automatically, find the task
55
+     * that must be executed on this particular machine. */
54 56
     public void addToMachine(int machine, int jobNumber) {
55 57
         addTaskToMachine(machine, new Task(jobNumber, instance.task_with_machine(jobNumber, machine)));
56 58
     }
@@ -60,10 +62,16 @@ public class ResourceOrder extends Encoding {
60 62
         nextFreeSlot[machine] += 1;
61 63
     }
62 64
 
63
-    public void swapTasks(int machine, int indexFirstTask, int indexSecondTask) {
64
-        Task tmp = tasksByMachine[machine][indexFirstTask];
65
-        tasksByMachine[machine][indexFirstTask] = tasksByMachine[machine][indexSecondTask];
66
-        tasksByMachine[machine][indexSecondTask] = tmp;
65
+    /** Exchange the order of two tasks that are scheduled on a given machine.
66
+     *
67
+     * @param machine Machine on which the two tasks appear (line on which to perform the exchange)
68
+     * @param indexTask1 Position of the first task on the machine (column of the first element)
69
+     * @param indexTask2 Position of the second task on the machine (column of the second element)
70
+     */
71
+    public void swapTasks(int machine, int indexTask1, int indexTask2) {
72
+        Task tmp = tasksByMachine[machine][indexTask1];
73
+        tasksByMachine[machine][indexTask1] = tasksByMachine[machine][indexTask2];
74
+        tasksByMachine[machine][indexTask2] = tmp;
67 75
     }
68 76
 
69 77
     @Override

+ 2
- 2
src/main/java/jobshop/encodings/Schedule.java View File

@@ -69,8 +69,8 @@ public class Schedule extends Encoding {
69 69
                 for(int j2 = j1+1; j2< instance.numJobs ; j2++) {
70 70
                     int t2 = instance.task_with_machine(j2, machine);
71 71
 
72
-                    boolean t1_first = startTime(j1, t1) + instance.duration(j1, t1) <= startTime(j2, t2);
73
-                    boolean t2_first = startTime(j2, t2) + instance.duration(j2, t2) <= startTime(j1, t1);
72
+                    boolean t1_first = endTime(j1, t1) <= startTime(j2, t2);
73
+                    boolean t2_first = endTime(j2, t2) <= startTime(j1, t1);
74 74
 
75 75
                     if(!t1_first && !t2_first)
76 76
                         return false;

+ 1
- 2
src/main/java/jobshop/solvers/BasicSolver.java View File

@@ -5,8 +5,7 @@ import jobshop.Result;
5 5
 import jobshop.encodings.JobNumbers;
6 6
 
7 7
 /**
8
- * A very naïve solver that first schedules
9
- *
8
+ * A very naïve solver that first schedules all first tasks, then all second tasks, ...
10 9
  **/
11 10
 public class BasicSolver implements Solver {
12 11
     @Override

+ 3
- 0
src/main/java/jobshop/solvers/RandomSolver.java View File

@@ -6,6 +6,9 @@ import jobshop.encodings.Schedule;
6 6
 
7 7
 import java.util.Random;
8 8
 
9
+/** A solver that generates random solutions until a deadline is met.
10
+ *  Then returns the best solution that was generated.
11
+ */
9 12
 public class RandomSolver implements Solver {
10 13
 
11 14
     @Override

+ 10
- 3
src/main/java/jobshop/solvers/neighborhood/Neighbor.java View File

@@ -1,8 +1,15 @@
1 1
 package jobshop.solvers.neighborhood;
2 2
 
3
-public abstract class Neighbor<Encoding> {
3
+import jobshop.encodings.Encoding;
4 4
 
5
-    public abstract void applyOn(Encoding current);
6
-    public abstract void undoApplyOn(Encoding current);
5
+/** This class provides a representation of neighbor by allowing to transform
6
+ * a solution in a particular encoding Enc into the neighbor and back.*/
7
+public abstract class Neighbor<Enc extends Encoding> {
8
+
9
+    /** Transform the given solution into the neighbor. */
10
+    public abstract void applyOn(Enc current);
11
+
12
+    /** Transform the neighbor back into the original solution. */
13
+    public abstract void undoApplyOn(Enc current);
7 14
 
8 15
 }

+ 10
- 2
src/main/java/jobshop/solvers/neighborhood/Neighborhood.java View File

@@ -1,9 +1,17 @@
1 1
 package jobshop.solvers.neighborhood;
2 2
 
3
+import jobshop.encodings.Encoding;
4
+
3 5
 import java.util.List;
4 6
 
5
-public abstract class Neighborhood<Encoding> {
7
+/** For a particular encoding Enc, a neighborhood allow the generation of the neighbors of
8
+ * a particular solution.
9
+ *
10
+ * @param <Enc> A subcless of Encoding for which this encoding can generate neighbors.
11
+ */
12
+public abstract class Neighborhood<Enc extends Encoding> {
6 13
 
7
-    public abstract List<Neighbor<Encoding>> generateNeighbors(Encoding current);
14
+    /** Generates all neighbors for the current solution.  */
15
+    public abstract List<Neighbor<Enc>> generateNeighbors(Enc current);
8 16
 
9 17
 }

+ 7
- 0
src/main/java/jobshop/solvers/neighborhood/Nowicki.java View File

@@ -5,6 +5,13 @@ import jobshop.encodings.ResourceOrder;
5 5
 import java.util.ArrayList;
6 6
 import java.util.List;
7 7
 
8
+/** Implementation of the Nowicki and Smutnicki neighborhood.
9
+ *
10
+ * It works on the ResourceOrder encoding by generating two neighbors for each block
11
+ * of the critical path.
12
+ * For each block, two neighbors should be generated that respectivly swap the first two and
13
+ * last two tasks of the block.
14
+ */
8 15
 public class Nowicki extends Neighborhood<ResourceOrder> {
9 16
 
10 17
     /** A block represents a subsequence of the critical path such that all tasks in it execute on the same machine.

Loading…
Cancel
Save