I am currently implementing this for my project.
I need to add a rule for "at most four shift assignments per week per employee." I am new to java and drools. Is there an easy way to edit the rule below to match the constraint I am looking for?
rule "At most one shift assignment per day per employee"
when
$s : Shift(
employee != null,
$e : employee,
$leftDay : startDateTime.toLocalDate())
Shift(
employee == $e,
startDateTime.toLocalDate() == $leftDay,
this != $s)
then
scoreHolder.addHardConstraintMatch(kcontext, -10);
end
You could try to use accumulate
Your rule could look like this (I haven't tested it, but it should point you in the right direction):