OptaPlanner 8.36.0.Final
When using ConstraintStreamImplType.DROOLS the following constraint behaves as expected:
return constraintFactory
.forEach(Ewe.class)
.groupBy(ConstraintCollectors.count())
.penalize(level,
(count) -> {
return activeRange.check(count));
}
)
.asConstraint(name);
Ewe is a PlanningEntity that has a nullable PlanningVariable Ram. There are 100 Ewes of which between 50 and 75 should be assigned rams. This constraint penalizes under or over allocation. The constraint produces the expected result.
When I change to ConstraintStreamImplType.BAVET the solver ends with no ewes assigned and the score is zero, so the solution picked is one with none of the Ewes assigned and the constraint is not evaluated, therefore the zero score.
It seems like BAVET does not evaluate this constraint because there are zero entities that match. On the other hand DROOLS evaluates the constraint when there are zero matches.
Is this difference between DROOLS and BAVET expected?
I validated this behavior change by only switching between ConstraintStreamImplType.BAVET and ConstraintStreamImplType.DROOLS with no other change
Edit: Ultimately I want to count entries even including a zero count as a possible answer.