Skip to content

Instantly share code, notes, and snippets.

@ge0ffrey
Last active January 24, 2017 11:06
Show Gist options
  • Save ge0ffrey/7fe165c5343076ae9d30da55c6e8b093 to your computer and use it in GitHub Desktop.
Save ge0ffrey/7fe165c5343076ae9d30da55c6e8b093 to your computer and use it in GitHub Desktop.
rule "fairAssignmentCountPerTeam"
when
accumulate(
$t : Team()
and accumulate(
$a : TeamAssignment(team == $t);
$teamTotal : count($a)
);
$total : sum($teamTotal.intValue() * $teamTotal.intValue())
)
then
scoreHolder.addMediumConstraintMatch(kcontext, - (int) (Math.sqrt($total) * 1000.0));
end
// Can we turn this into 1 accumulate?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment