Vy Le
Vy Le

Reputation: 41

How to spread tasks evenly for each machine?

enter image description here

I already used Fairness Constraint (3000 Blue tasks grouped by 11 machines). Machines are InverseRelationShadowVariable of tasks (@InverseRelationShadowVariable(sourceVariableName = "tasks")). It still did not fair. Also I have lots of deadline COntraints, but it rather break the constraints and start after deadline rather than put the tasks to a different machine

private Machine machine;

private Constraint fairAssignments(ConstraintFactory constraintFactory) {
    return constraintFactory.forEach(Task.class)
            .groupBy(ConstraintCollectors.loadBalance(Task::getMachine))
            .penalizeBigDecimal(HardMediumSoftBigDecimalScore.ONE_SOFT, LoadBalance::unfairness)
            .asConstraint("Fair Assignments");
}

My constraints are: start after earliest start date. Ends before deadline, and Fairness constraint Also a constraint for startAfterEarliestCutDateAsSoonAsPossible

 .penalize(HardMediumSoftBigDecimalScore.ofHard(BigDecimal.TEN), task -> {
                    long daysDifference = ChronoUnit.DAYS.between(task.getStartTime().toLocalDate(), task.getEarliestDate());
                    return Math.toIntExact(Math.abs(daysDifference)) *24;
                })
                .asConstraint("as close to earliest day as possible");

Upvotes: 0

Views: 50

Answers (0)

Related Questions