Remove a misleading method of ResourceOrder

This commit is contained in:
Arthur Bit-Monnot 2021-04-12 15:48:42 +02:00
parent c98accd114
commit 8e5545fc80
7 changed files with 16 additions and 23 deletions

View file

@ -18,9 +18,9 @@ Convenience methods:
- `asciiGantt()`: generates a Gantt chart view of the solution in ASCII art. - `asciiGantt()`: generates a Gantt chart view of the solution in ASCII art.
## NumJobs ## JobNumbers
The `NumJobs` encoding consists of a sequence of job numbers. To produce a schedule, one should iterate on the job numbers and try to schedule *as early as possible* the next task of the job. The `JobNumbers` encoding consists of a sequence of job numbers. To produce a schedule, one should iterate on the job numbers and try 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): 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):

View file

@ -26,14 +26,16 @@ classrooms as well as on `montp.insa-toulouse.fr`.
To import the project in IntelliJ (once IntelliJ is running): To import the project in IntelliJ (once IntelliJ is running):
- Open a new project : `Open project` or `File > Open` - Open a new project : `Open project` or `File > Open`
- Select the `gradle.build` file in the cloned repository. - Select the `build.gradle` file in the cloned repository.
- Select `Open as project`. - Select `Open as project`.
To run the program in IntelliJ, you can To run the program in IntelliJ, you can
- Right click on the `src/main/java/jobshop/Main` class in the project view. - Right click on the `src/main/java/jobshop/Main` class in the project view.
- Select `Run Main.main()`. The program should execute but complain that some arguments are missing. - Select `Run Main.main()`. The program should execute but complain that some arguments are missing.
- Give it the expected command line arguments : `Run > Edit Configuration`, then fill in the `Program arguments` text box. - Specify the expected command line arguments :
- open the run configuration dialog: `Run > Edit Configuration`
- fill in the `Program arguments` text box with `--solver basic random --instance aaa1 aaa2` (see the next page for more details on the meaning of the arguments)
### Working on the command line (Gradle) ### Working on the command line (Gradle)

View file

@ -3,8 +3,6 @@ package jobshop;
import jobshop.encodings.JobNumbers; import jobshop.encodings.JobNumbers;
import jobshop.encodings.ResourceOrder; import jobshop.encodings.ResourceOrder;
import jobshop.encodings.Schedule; import jobshop.encodings.Schedule;
import jobshop.encodings.Task;
import jobshop.solvers.GreedySolver;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -19,12 +17,12 @@ public class MainTest {
// builds a solution in the job-numbers encoding [0 0 1 1 0 1] // builds a solution in the job-numbers encoding [0 0 1 1 0 1]
JobNumbers enc = new JobNumbers(instance); JobNumbers enc = new JobNumbers(instance);
enc.addTask(0); enc.addTaskOfJob(0);
enc.addTask(0); enc.addTaskOfJob(0);
enc.addTask(1); enc.addTaskOfJob(1);
enc.addTask(1); enc.addTaskOfJob(1);
enc.addTask(0); enc.addTaskOfJob(0);
enc.addTask(1); enc.addTaskOfJob(1);
System.out.println("\nENCODING: " + enc); System.out.println("\nENCODING: " + enc);

View file

@ -47,13 +47,13 @@ public final class JobNumbers extends Encoding {
.min(Comparator.comparing(t -> schedule.startTime(t.job, t.task))) .min(Comparator.comparing(t -> schedule.startTime(t.job, t.task)))
.get(); .get();
this.addTask(next.job); this.addTaskOfJob(next.job);
nextOnJob[next.job] += 1; nextOnJob[next.job] += 1;
} }
} }
/** Schedule the next task of the given job. */ /** Schedule the next task of the given job. */
public void addTask(int jobNumber) { public void addTaskOfJob(int jobNumber) {
this.jobs[nextToSet++] = jobNumber; this.jobs[nextToSet++] = jobNumber;
} }

View file

@ -53,13 +53,6 @@ public final class ResourceOrder extends Encoding {
} }
} }
/** Enqueues a task for the given job on the machine. We automatically, find the task
* that must be executed on this particular machine. */
public void addToMachine(int machine, int jobNumber) {
Task taskToEnqueue = new Task(jobNumber, instance.task_with_machine(jobNumber, machine));
addTaskToMachine(machine, taskToEnqueue);
}
/** Adds the given task to the queue of the given machine. */ /** Adds the given task to the queue of the given machine. */
public void addTaskToMachine(int machine, Task task) { public void addTaskToMachine(int machine, Task task) {
tasksByMachine[machine][nextFreeSlot[machine]] = task; tasksByMachine[machine][nextFreeSlot[machine]] = task;

View file

@ -14,7 +14,7 @@ public class BasicSolver implements Solver {
JobNumbers sol = new JobNumbers(instance); JobNumbers sol = new JobNumbers(instance);
for(int t = 0 ; t<instance.numTasks ; t++) { for(int t = 0 ; t<instance.numTasks ; t++) {
for(int j = 0 ; j<instance.numJobs ; j++) { for(int j = 0 ; j<instance.numJobs ; j++) {
sol.addTask(j); sol.addTaskOfJob(j);
} }
} }

View file

@ -21,7 +21,7 @@ public class RandomSolver implements Solver {
// initialize a first solution to the problem. // initialize a first solution to the problem.
for(int j = 0 ; j<instance.numJobs ; j++) { for(int j = 0 ; j<instance.numJobs ; j++) {
for(int t = 0 ; t<instance.numTasks ; t++) { for(int t = 0 ; t<instance.numTasks ; t++) {
sol.addTask(j); sol.addTaskOfJob(j);
} }
} }
// best solution is currently the initial one // best solution is currently the initial one