diff --git a/.gitignore b/.gitignore index d5cf597..6418df1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .gradle/ .idea/ -build/ \ No newline at end of file +build/ +doc/book/ \ No newline at end of file diff --git a/doc/src/encodings.md b/doc/src/encodings.md index f676759..e261b63 100644 --- a/doc/src/encodings.md +++ b/doc/src/encodings.md @@ -19,6 +19,30 @@ Convenience methods: ## NumJobs + 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. + + 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): + + - `(0, 0)`: first task of the first job + - `(0, 1)`: second task of the first job + - `(1, 0)`: first task of the second job + - `(1, 1)`: second task of the second job + - `(0, 2)`: third task of the first job + - `(1, 2)`: third task of the second job - ## ResourceOrder \ No newline at end of file + ## ResourceOrder + +The resource order encoding specifies the order in which each machine will process its tasks. + +Each machine is associated with an array of task that specifies the order on which the task must be scheduled on the machine. + +For instance, the encoding: + + ``` + machine 0: [(0, 1), (1, 0)] + machine 1: [(0, 0), (1, 1)] + machine 2: [(1, 2), (0, 2)] + ``` + + 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)`. \ No newline at end of file diff --git a/doc/src/prelude.md b/doc/src/prelude.md index 31420d4..bbdce9e 100644 --- a/doc/src/prelude.md +++ b/doc/src/prelude.md @@ -12,12 +12,11 @@ Useful links: ## Setting up +Start by accepting the GitHub classroom assignment : -You should start by cloning the repository containing the source code. - -``` -git clone https://github.com/insa-4ir-meta-heuristiques/template-jobshop -``` + - Go to the [invite link](https://classroom.github.com/a/18VUb3aB) + - 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. + - Clone the repository and get started. ### Working in IntelliJ diff --git a/src/main/java/jobshop/solvers/neighborhood/Nowicki.java b/src/main/java/jobshop/solvers/neighborhood/Nowicki.java index 8ee97ec..0d11f7e 100644 --- a/src/main/java/jobshop/solvers/neighborhood/Nowicki.java +++ b/src/main/java/jobshop/solvers/neighborhood/Nowicki.java @@ -9,7 +9,7 @@ import java.util.List; * * It works on the ResourceOrder encoding by generating two neighbors for each block * of the critical path. - * For each block, two neighbors should be generated that respectivly swap the first two and + * For each block, two neighbors should be generated that respectively swap the first two and * last two tasks of the block. */ public class Nowicki extends Neighborhood { @@ -34,6 +34,7 @@ public class Nowicki extends Neighborhood { /** index of the last task of the block */ public final int lastTask; + /** Creates a new block. */ Block(int machine, int firstTask, int lastTask) { this.machine = machine; this.firstTask = firstTask; @@ -57,13 +58,16 @@ public class Nowicki extends Neighborhood { * machine 2 : ... */ public static class Swap extends Neighbor { - // machine on which to perform the swap + /** machine on which to perform the swap */ public final int machine; - // index of one task to be swapped + + /** index of one task to be swapped (in the resource order encoding) */ public final int t1; - // index of the other task to be swapped + + /** index of the other task to be swapped (in the resource order encoding) */ public final int t2; + /** Creates a new swap of two tasks. */ Swap(int machine, int t1, int t2) { this.machine = machine; this.t1 = t1; @@ -71,12 +75,13 @@ public class Nowicki extends Neighborhood { } - /** Apply this swap on the given resource order, transforming it into a new solution. */ + /** Apply this swap on the given ResourceOrder, transforming it into a new solution. */ @Override public void applyOn(ResourceOrder current) { throw new UnsupportedOperationException(); } + /** Unapply this swap on the neighbor, transforming it back into the original solution. */ @Override public void undoApplyOn(ResourceOrder current) { throw new UnsupportedOperationException(); @@ -86,8 +91,15 @@ public class Nowicki extends Neighborhood { @Override public List> generateNeighbors(ResourceOrder current) { - List> neighbors = new ArrayList<>(); - // iterate over all blocks of the critical + // this simply converts the list of swaps into a list of neighbors + return new ArrayList<>(allSwaps(current)); + } + + /** Generates all swaps of the given ResourceOrder. + * This method can be used if one wants to access the inner fields of a neighbors. */ + public List allSwaps(ResourceOrder current) { + List neighbors = new ArrayList<>(); + // iterate over all blocks of the critical path for(var block : blocksOfCriticalPath(current)) { // for this block, compute all neighbors and add them to the list of neighbors neighbors.addAll(neighbors(block));