Browse Source

Doc + add an allSwpaps method in Nomicki neighborhood (to avoid casting in taboo)

Arthur Bit-Monnot 3 years ago
parent
commit
fd9fa99913
4 changed files with 50 additions and 14 deletions
  1. 2
    1
      .gitignore
  2. 25
    1
      doc/src/encodings.md
  3. 4
    5
      doc/src/prelude.md
  4. 19
    7
      src/main/java/jobshop/solvers/neighborhood/Nowicki.java

+ 2
- 1
.gitignore View File

@@ -1,3 +1,4 @@
1 1
 .gradle/
2 2
 .idea/
3
-build/
3
+build/
4
+doc/book/

+ 25
- 1
doc/src/encodings.md View File

@@ -19,6 +19,30 @@ Convenience methods:
19 19
 
20 20
  ## NumJobs
21 21
 
22
+ The `NumJobs` encoding consists of a sequence of job numbers. To produce a schedule, one should iterate on the job numbers and tries to schedule *as early as possible* the next task of the job.
22 23
 
24
+ For instance the encoding `[0 0 1 1 0 1]` will produce a schedule by trying to place as early as possible the following tasks (in this order):
23 25
 
24
- ## ResourceOrder
26
+ - `(0, 0)`: first task of the first job
27
+ - `(0, 1)`: second task of the first job
28
+ - `(1, 0)`: first task of the second job
29
+ - `(1, 1)`: second task of the second job
30
+ - `(0, 2)`: third task of the first job
31
+ - `(1, 2)`: third task of the second job
32
+
33
+
34
+ ## ResourceOrder
35
+
36
+The resource order encoding specifies the order in which each machine will process its tasks.
37
+
38
+Each machine is associated with an array of task that specifies the order on which the task must be scheduled on the machine.
39
+
40
+For instance, the encoding:
41
+
42
+ ```
43
+ machine 0: [(0, 1), (1, 0)]
44
+ machine 1: [(0, 0), (1, 1)]
45
+ machine 2: [(1, 2), (0, 2)]
46
+ ```
47
+
48
+ Specifies that the first machine (machine 0) will first process the second task of the first job `(0, 1)` and only when it is finished can start processing the first task of the second job `(1, 0)`.

+ 4
- 5
doc/src/prelude.md View File

@@ -12,12 +12,11 @@ Useful links:
12 12
 
13 13
 ## Setting up
14 14
 
15
+Start by accepting the GitHub classroom assignment : 
15 16
 
16
-You should start by cloning the repository containing the source code.
17
-
18
-```
19
-git clone https://github.com/insa-4ir-meta-heuristiques/template-jobshop
20
-```
17
+ - Go to the [invite link](https://classroom.github.com/a/18VUb3aB)
18
+ - Select your name in the list to associate it with you github account (there is a particular link that you can follow if you do not appear in the list). This should create a private repository to which only yourself and the teachers have access. 
19
+ - Clone the repository and get started.
21 20
 
22 21
 ### Working in IntelliJ
23 22
 

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

@@ -9,7 +9,7 @@ import java.util.List;
9 9
  *
10 10
  * It works on the ResourceOrder encoding by generating two neighbors for each block
11 11
  * of the critical path.
12
- * For each block, two neighbors should be generated that respectivly swap the first two and
12
+ * For each block, two neighbors should be generated that respectively swap the first two and
13 13
  * last two tasks of the block.
14 14
  */
15 15
 public class Nowicki extends Neighborhood<ResourceOrder> {
@@ -34,6 +34,7 @@ public class Nowicki extends Neighborhood<ResourceOrder> {
34 34
         /** index of the last task of the block */
35 35
         public final int lastTask;
36 36
 
37
+        /** Creates a new block. */
37 38
         Block(int machine, int firstTask, int lastTask) {
38 39
             this.machine = machine;
39 40
             this.firstTask = firstTask;
@@ -57,13 +58,16 @@ public class Nowicki extends Neighborhood<ResourceOrder> {
57 58
      * machine 2 : ...
58 59
      */
59 60
     public static class Swap extends Neighbor<ResourceOrder> {
60
-        // machine on which to perform the swap
61
+        /** machine on which to perform the swap */
61 62
         public final int machine;
62
-        // index of one task to be swapped
63
+
64
+        /** index of one task to be swapped (in the resource order encoding) */
63 65
         public final int t1;
64
-        // index of the other task to be swapped
66
+
67
+        /** index of the other task to be swapped (in the resource order encoding) */
65 68
         public final int t2;
66 69
 
70
+        /** Creates a new swap of two tasks. */
67 71
         Swap(int machine, int t1, int t2) {
68 72
             this.machine = machine;
69 73
             this.t1 = t1;
@@ -71,12 +75,13 @@ public class Nowicki extends Neighborhood<ResourceOrder> {
71 75
         }
72 76
 
73 77
 
74
-        /** Apply this swap on the given resource order, transforming it into a new solution. */
78
+        /** Apply this swap on the given ResourceOrder, transforming it into a new solution. */
75 79
         @Override
76 80
         public void applyOn(ResourceOrder current) {
77 81
             throw new UnsupportedOperationException();
78 82
         }
79 83
 
84
+        /** Unapply this swap on the neighbor, transforming it back into the original solution. */
80 85
         @Override
81 86
         public void undoApplyOn(ResourceOrder current) {
82 87
             throw new UnsupportedOperationException();
@@ -86,8 +91,15 @@ public class Nowicki extends Neighborhood<ResourceOrder> {
86 91
 
87 92
     @Override
88 93
     public List<Neighbor<ResourceOrder>> generateNeighbors(ResourceOrder current) {
89
-        List<Neighbor<ResourceOrder>> neighbors = new ArrayList<>();
90
-        // iterate over all blocks of the critical
94
+        // this simply converts the list of swaps into a list of neighbors
95
+        return new ArrayList<>(allSwaps(current));
96
+    }
97
+
98
+    /** Generates all swaps of the given ResourceOrder.
99
+     * This method can be used if one wants to access the inner fields of a neighbors. */
100
+    public List<Swap> allSwaps(ResourceOrder current) {
101
+        List<Swap> neighbors = new ArrayList<>();
102
+        // iterate over all blocks of the critical path
91 103
         for(var block : blocksOfCriticalPath(current)) {
92 104
             // for this block, compute all neighbors and add them to the list of neighbors
93 105
             neighbors.addAll(neighbors(block));

Loading…
Cancel
Save