0

I have this constraint

Constraint noOverlappingShifts(ConstraintFactory constraintFactory) {
        return constraintFactory.forEachUniquePair(Shift.class,
                equal(Shift::getEmployee),
                overlapping(Shift::getStartDateTime, Shift::getEndDateTime),
                equal(Shift::getstatus))
                .penalizeConfigurableLong(CONSTRAINT_NO_OVERLAPPING_SHIFTS,
                        (shift, otherShift) -> otherShift.getLengthInMinutes());
    }

Now i want to change the second equal to not equal but Joiner class in optaplanner does not contain this. There is a filtering method but not sure how to use it.I am using employee rostering pre complied optaplanner, if possible suggest code changes in the above code rather than core.

Also this is how the filtering method is defined

public static <A, B> BiJoiner<A, B> filtering(BiPredicate<A, B> filter) {
        return JoinerSupport.getJoinerService()
                .newBiJoiner(filter);
    }

Thanks in advance. Also can you let me know where can i ask optaplanner related queries.

I tried filter like this

Constraint noOverlappingShifts(ConstraintFactory constraintFactory) {
        return constraintFactory.forEachUniquePair(Shift.class,
                equal(Shift::getEmployee),
                overlapping(Shift::getStartDateTime, Shift::getEndDateTime),
                filtering((shift, otherShift) -> !Objects.equals(shift.getstatus(), 
                .penalizeConfigurableLong(CONSTRAINT_NO_OVERLAPPING_SHIFTS,
                        (shift, otherShift) -> otherShift.getLengthInMinutes());
    } 

Instead of using java can i directly use a drool file to write constraints. If so how do link it in my code.

0 Answers0