Doc + add an allSwpaps method in Nomicki neighborhood (to avoid casting in taboo)
This commit is contained in:
parent
f6d78491ba
commit
fd9fa99913
4 changed files with 50 additions and 14 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
.gradle/
|
.gradle/
|
||||||
.idea/
|
.idea/
|
||||||
build/
|
build/
|
||||||
|
doc/book/
|
|
@ -19,6 +19,30 @@ Convenience methods:
|
||||||
|
|
||||||
## NumJobs
|
## 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
|
## 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)`.
|
|
@ -12,12 +12,11 @@ Useful links:
|
||||||
|
|
||||||
## Setting up
|
## Setting up
|
||||||
|
|
||||||
|
Start by accepting the GitHub classroom assignment :
|
||||||
|
|
||||||
You should start by cloning the repository containing the source code.
|
- 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.
|
||||||
git clone https://github.com/insa-4ir-meta-heuristiques/template-jobshop
|
|
||||||
```
|
|
||||||
|
|
||||||
### Working in IntelliJ
|
### Working in IntelliJ
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* It works on the ResourceOrder encoding by generating two neighbors for each block
|
* It works on the ResourceOrder encoding by generating two neighbors for each block
|
||||||
* of the critical path.
|
* 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.
|
* last two tasks of the block.
|
||||||
*/
|
*/
|
||||||
public class Nowicki extends Neighborhood<ResourceOrder> {
|
public class Nowicki extends Neighborhood<ResourceOrder> {
|
||||||
|
@ -34,6 +34,7 @@ public class Nowicki extends Neighborhood<ResourceOrder> {
|
||||||
/** index of the last task of the block */
|
/** index of the last task of the block */
|
||||||
public final int lastTask;
|
public final int lastTask;
|
||||||
|
|
||||||
|
/** Creates a new block. */
|
||||||
Block(int machine, int firstTask, int lastTask) {
|
Block(int machine, int firstTask, int lastTask) {
|
||||||
this.machine = machine;
|
this.machine = machine;
|
||||||
this.firstTask = firstTask;
|
this.firstTask = firstTask;
|
||||||
|
@ -57,13 +58,16 @@ public class Nowicki extends Neighborhood<ResourceOrder> {
|
||||||
* machine 2 : ...
|
* machine 2 : ...
|
||||||
*/
|
*/
|
||||||
public static class Swap extends Neighbor<ResourceOrder> {
|
public static class Swap extends Neighbor<ResourceOrder> {
|
||||||
// machine on which to perform the swap
|
/** machine on which to perform the swap */
|
||||||
public final int machine;
|
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;
|
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;
|
public final int t2;
|
||||||
|
|
||||||
|
/** Creates a new swap of two tasks. */
|
||||||
Swap(int machine, int t1, int t2) {
|
Swap(int machine, int t1, int t2) {
|
||||||
this.machine = machine;
|
this.machine = machine;
|
||||||
this.t1 = t1;
|
this.t1 = t1;
|
||||||
|
@ -71,12 +75,13 @@ public class Nowicki extends Neighborhood<ResourceOrder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 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
|
@Override
|
||||||
public void applyOn(ResourceOrder current) {
|
public void applyOn(ResourceOrder current) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Unapply this swap on the neighbor, transforming it back into the original solution. */
|
||||||
@Override
|
@Override
|
||||||
public void undoApplyOn(ResourceOrder current) {
|
public void undoApplyOn(ResourceOrder current) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
@ -86,8 +91,15 @@ public class Nowicki extends Neighborhood<ResourceOrder> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Neighbor<ResourceOrder>> generateNeighbors(ResourceOrder current) {
|
public List<Neighbor<ResourceOrder>> generateNeighbors(ResourceOrder current) {
|
||||||
List<Neighbor<ResourceOrder>> neighbors = new ArrayList<>();
|
// this simply converts the list of swaps into a list of neighbors
|
||||||
// iterate over all blocks of the critical
|
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<Swap> allSwaps(ResourceOrder current) {
|
||||||
|
List<Swap> neighbors = new ArrayList<>();
|
||||||
|
// iterate over all blocks of the critical path
|
||||||
for(var block : blocksOfCriticalPath(current)) {
|
for(var block : blocksOfCriticalPath(current)) {
|
||||||
// for this block, compute all neighbors and add them to the list of neighbors
|
// for this block, compute all neighbors and add them to the list of neighbors
|
||||||
neighbors.addAll(neighbors(block));
|
neighbors.addAll(neighbors(block));
|
||||||
|
|
Loading…
Reference in a new issue