updated .sort to .max/min for SPT/LRPT

This commit is contained in:
Raphaël LACROIX 2023-04-27 15:09:57 +02:00
parent 640e695533
commit e14f7d77ef

View file

@ -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()