Compare commits

..

No commits in common. "0b156ee40e28452eee0799e35e4d5824256107be" and "640e695533ef0c925cc7b18e497f38aebb446338" have entirely different histories.

2 changed files with 13 additions and 28 deletions

View file

@ -108,12 +108,8 @@ 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);
@ -122,16 +118,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("\u001b[36m" + "------------------------------------------------------------------------------------------------------------------" + "\u001b[0m"); output.println();
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 look up the `Main.solvers` hash map to get the solver object with the given name. // we lookup 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.
@ -157,22 +153,11 @@ 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", "-", "-");

View file

@ -51,8 +51,8 @@ public class GreedySolver implements Solver {
case SPT: case SPT:
return( return(
lTask.stream() lTask.stream()
.min(Comparator.comparing(e -> heuristiqueSPT(e, instance))) .sorted(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
.get() .toArray(Task[]::new)[0]
); );
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))
.min(Comparator.comparing(e -> e)) .sorted()
.get(); .toArray(Integer[]::new)[0];
// 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)
.min(Comparator.comparing(e -> heuristiqueSPT(e, instance))) .sorted(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
.get() .toArray(Task[]::new)[0]
); );
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))
.min(Comparator.comparing(e -> e)) .sorted()
.get(); .toArray(Integer[]::new)[0];
// 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()