From e14f7d77eff298995bf6c4eeb4328cecf32a080d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20LACROIX?= Date: Thu, 27 Apr 2023 15:09:57 +0200 Subject: [PATCH] updated .sort to .max/min for SPT/LRPT --- src/main/java/jobshop/solvers/GreedySolver.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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()