Compare commits
2 commits
640e695533
...
0b156ee40e
작성자 | SHA1 | 날짜 | |
---|---|---|---|
|
0b156ee40e | ||
|
e14f7d77ef |
2개의 변경된 파일과 28개의 추가작업 그리고 13개의 파일을 삭제
|
@ -108,8 +108,12 @@ public class Main {
|
|||
}
|
||||
output.println();
|
||||
|
||||
ArrayList<Integer[]> makespans = new ArrayList<>();
|
||||
|
||||
// for all instances, load it from f
|
||||
for(String instanceName : instances) {
|
||||
|
||||
|
||||
// get the best known result for this instance
|
||||
int bestKnown = BestKnownResults.of(instanceName);
|
||||
|
||||
|
@ -118,16 +122,16 @@ public class Main {
|
|||
Instance instance = Instance.fromFile(path);
|
||||
|
||||
// print some general statistics on the instance
|
||||
output.println();
|
||||
output.println();
|
||||
output.println("\u001b[36m" + "------------------------------------------------------------------------" + "\u001b[0m");
|
||||
output.println("\u001b[36m" + "------------------------------------------------------------------------------------------------------------------" + "\u001b[0m");
|
||||
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
|
||||
for(int solverId = 0 ; solverId < solvers.size() ; solverId++) {
|
||||
// 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);
|
||||
|
||||
// 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();
|
||||
|
||||
output.printf("%7d %8s %5.1f ", runtime, makespan, dist);
|
||||
instanceMakespans.add(makespan);
|
||||
output.flush();
|
||||
}
|
||||
|
||||
makespans.add(instanceMakespans.toArray(Integer[]::new));
|
||||
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.
|
||||
output.printf("%-8s %-5s %4s ", "AVG", "-", "-");
|
||||
|
|
|
@ -51,8 +51,8 @@ public class GreedySolver implements Solver {
|
|||
case SPT:
|
||||
return(
|
||||
lTask.stream()
|
||||
.sorted(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
|
||||
.toArray(Task[]::new)[0]
|
||||
.min(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
|
||||
.get()
|
||||
);
|
||||
case LRPT:
|
||||
return(
|
||||
|
@ -65,8 +65,8 @@ public class GreedySolver implements Solver {
|
|||
// find the minimal next execution time value
|
||||
int EST_SPT_minValue = lTask.stream()
|
||||
.map(e -> heuristiqueEST(e, instance,machineStatus, jobStatus))
|
||||
.sorted()
|
||||
.toArray(Integer[]::new)[0];
|
||||
.min(Comparator.comparing(e -> e))
|
||||
.get();
|
||||
|
||||
// find all tasks with this next execution time value
|
||||
Task[] EST_SPT_closestTasks = lTask.stream()
|
||||
|
@ -76,16 +76,16 @@ public class GreedySolver implements Solver {
|
|||
// run SPT (see above) on this
|
||||
return(
|
||||
Arrays.stream(EST_SPT_closestTasks)
|
||||
.sorted(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
|
||||
.toArray(Task[]::new)[0]
|
||||
.min(Comparator.comparing(e -> heuristiqueSPT(e, instance)))
|
||||
.get()
|
||||
);
|
||||
case EST_LRPT:
|
||||
|
||||
// find the minimal next execution time value
|
||||
int EST_LRPT_minValue = lTask.stream()
|
||||
.map(e -> heuristiqueEST(e, instance,machineStatus, jobStatus))
|
||||
.sorted()
|
||||
.toArray(Integer[]::new)[0];
|
||||
.min(Comparator.comparing(e -> e))
|
||||
.get();
|
||||
|
||||
// find all tasks with this next execution time value
|
||||
Task[] EST_LRPT_closestTasks = lTask.stream()
|
||||
|
|
불러오는 중…
Reference in a new issue