Very long running constraint in OptaPanner for RHDM

Solution Unverified - Updated -

Issue

There are shifts that will overlap one another: shift 1 can be from 8am-12pm and shift 2 can be from 11am-3pm, both on the same day. These two shifts overlap between 11am and 12pm and therefore and cannot be scheduled to the same person. The rule that penalizes overlapping shifts uses a Joiner to get two shifts that are scheduled for the same person as follows:

protected Constraint noOverlappingShift (ConstraintFactory constraintFactory) {
    return constraintFactory.fromUniquePair(TimeSlotPlanningEntity.class,Joiners.equal(TimeSlotPlanningEntity::getEmployee))
            .filter((shift1,shift2) ->shift1.getEmployee() != null && !shift1.equals(shift2) && shift1.getStartDateTime().isBefore(shift2.getEndDateTime()))
            .penalize("noOverlappingShift",HardMediumSoftLongScore.ONE_HARD);
}

But this rule causes OptaPlanner to run for around 20 minutes when there are 2,000 shifts. So it prevents OptaPlanner from terminating accordingly even though the solver configuration file contains the following configuration:

<termination>
<secondsSpentLimit>5</secondsSpentLimit>
</termination>

How to stop this behaviour?

Environment

  • Red Hat Decision Manager (Decision Manager)
    • 7.10.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content