Compare commits
2 commits
640e695533
...
0b156ee40e
Author | SHA1 | Date | |
---|---|---|---|
|
0b156ee40e | ||
|
e14f7d77ef |
2 changed files with 28 additions and 13 deletions
|
@ -108,8 +108,12 @@ public class Main {
|
||||||
}
|
}
|
||||||
output.println();
|
output.println();
|
||||||
|
|
||||||
|
ArrayList<Integer[]> makespans = new ArrayList<>();
|
||||||
|
|
||||||
// for all instances, load it from f
|
// for all instances, load it from f
|
||||||
for(String instanceName : instances) {
|
for(String instanceName : instances) {
|
||||||
|
|
||||||
|
|
||||||
// get the best known result for this instance
|
// get the best known result for this instance
|
||||||
int bestKnown = BestKnownResults.of(instanceName);
|
int bestKnown = BestKnownResults.of(instanceName);
|
||||||
|
|
||||||
|
@ -118,16 +122,16 @@ public class Main {
|
||||||
Instance instance = Instance.fromFile(path);
|
Instance instance = Instance.fromFile(path);
|
||||||
|
|
||||||
// print some general statistics on the instance
|
// print some general statistics on the instance
|
||||||
output.println();
|
output.println("\u001b[36m" + "------------------------------------------------------------------------------------------------------------------" + "\u001b[0m");
|
||||||
output.println();
|
|
||||||
output.println("\u001b[36m" + "------------------------------------------------------------------------" + "\u001b[0m");
|
|
||||||
output.printf("%-8s %-5s %4d ",instanceName, instance.numJobs +"x"+instance.numTasks, bestKnown);
|
output.printf("%-8s %-5s %4d ",instanceName, instance.numJobs +"x"+instance.numTasks, bestKnown);
|
||||||
output.println();
|
|
||||||
|
|
||||||
|
|
||||||
|
// used to get a csv file of all compared makespans
|
||||||
|
ArrayList<Integer> instanceMakespans = new ArrayList<>();
|
||||||
// run all selected solvers on the instance and print the results
|
// run all selected solvers on the instance and print the results
|
||||||
for(int solverId = 0 ; solverId < solvers.size() ; solverId++) {
|
for(int solverId = 0 ; solverId < solvers.size() ; solverId++) {
|
||||||
// Select the next solver to run. Given the solver name passed on the command line,
|
// Select the next solver to run. Given the solver name passed on the command line,
|
||||||
// we lookup the `Main.solvers` hash map to get the solver object with the given name.
|
// we look up the `Main.solvers` hash map to get the solver object with the given name.
|
||||||
Solver solver = solvers.get(solverId);
|
Solver solver = solvers.get(solverId);
|
||||||
|
|
||||||
// start chronometer and compute deadline for the solver to provide a result.
|
// start chronometer and compute deadline for the solver to provide a result.
|
||||||
|
@ -153,11 +157,22 @@ public class Main {
|
||||||
avg_distances[solverId] += dist / (float) instances.size();
|
avg_distances[solverId] += dist / (float) instances.size();
|
||||||
|
|
||||||
output.printf("%7d %8s %5.1f ", runtime, makespan, dist);
|
output.printf("%7d %8s %5.1f ", runtime, makespan, dist);
|
||||||
|
instanceMakespans.add(makespan);
|
||||||
output.flush();
|
output.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
makespans.add(instanceMakespans.toArray(Integer[]::new));
|
||||||
output.println();
|
output.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used to get a csv file of all compared makespans
|
||||||
|
for(Integer[] i : makespans){
|
||||||
|
for (Integer j : i){
|
||||||
|
System.out.printf("%8s,", j);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// we have finished all benchmarks, compute the average solve time and distance of each solver.
|
// we have finished all benchmarks, compute the average solve time and distance of each solver.
|
||||||
output.printf("%-8s %-5s %4s ", "AVG", "-", "-");
|
output.printf("%-8s %-5s %4s ", "AVG", "-", "-");
|
||||||
|
|
|
@ -51,8 +51,8 @@ public class GreedySolver implements Solver {
|
||||||
case SPT:
|
case SPT:
|
||||||
return(
|
return(
|
||||||
lTask.stream()
|
lTask.stream()
|
||||||
.sorted(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
|
.min(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
|
||||||
.toArray(Task[]::new)[0]
|
.get()
|
||||||
);
|
);
|
||||||
case LRPT:
|
case LRPT:
|
||||||
return(
|
return(
|
||||||
|
@ -65,8 +65,8 @@ public class GreedySolver implements Solver {
|
||||||
// find the minimal next execution time value
|
// find the minimal next execution time value
|
||||||
int EST_SPT_minValue = lTask.stream()
|
int EST_SPT_minValue = lTask.stream()
|
||||||
.map(e -> heuristiqueEST(e, instance,machineStatus, jobStatus))
|
.map(e -> heuristiqueEST(e, instance,machineStatus, jobStatus))
|
||||||
.sorted()
|
.min(Comparator.comparing(e -> e))
|
||||||
.toArray(Integer[]::new)[0];
|
.get();
|
||||||
|
|
||||||
// find all tasks with this next execution time value
|
// find all tasks with this next execution time value
|
||||||
Task[] EST_SPT_closestTasks = lTask.stream()
|
Task[] EST_SPT_closestTasks = lTask.stream()
|
||||||
|
@ -76,16 +76,16 @@ public class GreedySolver implements Solver {
|
||||||
// run SPT (see above) on this
|
// run SPT (see above) on this
|
||||||
return(
|
return(
|
||||||
Arrays.stream(EST_SPT_closestTasks)
|
Arrays.stream(EST_SPT_closestTasks)
|
||||||
.sorted(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
|
.min(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
|
||||||
.toArray(Task[]::new)[0]
|
.get()
|
||||||
);
|
);
|
||||||
case EST_LRPT:
|
case EST_LRPT:
|
||||||
|
|
||||||
// find the minimal next execution time value
|
// find the minimal next execution time value
|
||||||
int EST_LRPT_minValue = lTask.stream()
|
int EST_LRPT_minValue = lTask.stream()
|
||||||
.map(e -> heuristiqueEST(e, instance,machineStatus, jobStatus))
|
.map(e -> heuristiqueEST(e, instance,machineStatus, jobStatus))
|
||||||
.sorted()
|
.min(Comparator.comparing(e -> e))
|
||||||
.toArray(Integer[]::new)[0];
|
.get();
|
||||||
|
|
||||||
// find all tasks with this next execution time value
|
// find all tasks with this next execution time value
|
||||||
Task[] EST_LRPT_closestTasks = lTask.stream()
|
Task[] EST_LRPT_closestTasks = lTask.stream()
|
||||||
|
|
Loading…
Reference in a new issue