Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ge0ffrey/76847c8f940fc51382dfeb58a4289e81 to your computer and use it in GitHub Desktop.
Save ge0ffrey/76847c8f940fc51382dfeb58a4289e81 to your computer and use it in GitHub Desktop.
import accumulate org.optaplanner.examples.tennis.solver.drools.functions.LoadBalanceAccumulateFunction loadBalance;
rule "fairAssignmentCountPerTeam"
when
accumulate(
$t : Team()
and accumulate(
TeamAssignment(team == $t);
$assignmentCount : count()
);
$result : loadBalance($assignmentCount)
)
then
scoreHolder.addMediumConstraintMatch(kcontext, - (int) $result.getMeanDeviationSquaredSumRootMillis());
end
rule "evenlyConfrontationCount"
when
accumulate(
$t1 : Team()
and $t2 : Team($t1.getId() < id)
and accumulate(
TeamAssignment(team == $t1, $d : day)
and TeamAssignment(team == $t2, day == $d);
$confrontationCount : count()
);
$result : loadBalance($confrontationCount)
)
then
scoreHolder.addSoftConstraintMatch(kcontext, - (int) $result.getMeanDeviationSquaredSumRootMillis());
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment