diff --git a/src/main/java/jobshop/solvers/GreedySolver.java b/src/main/java/jobshop/solvers/GreedySolver.java index f5bb180..1a6e755 100644 --- a/src/main/java/jobshop/solvers/GreedySolver.java +++ b/src/main/java/jobshop/solvers/GreedySolver.java @@ -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()