-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python solver: support JSON of LoadBalance justification info #1264
Comments
Hello @ge0ffrey, I have reproduced this issue here where I tried to port the tournament example from Java to Python. It can be tested by pressing the "analyze" button after the Solver finishes its' job. For a larger context, check the StackOverflow question that I submitted. Also, I saw in the Java example that the expected JSON response should look like this:
I hope these details are useful to you. Thank you, |
@PatrickDiallo23 there is a workaround; use a custom justification function. @dataclass
class LoadBalanceJustification(ConstraintJustification):
unfairness: Decimal
def fair_assignment_count_per_team(constraint_factory: ConstraintFactory) -> Constraint:
return (constraint_factory
.for_each(TeamAssignment)
.group_by(ConstraintCollectors.load_balance(lambda team_assignment: team_assignment.team))
.penalize_decimal(HardMediumSoftDecimalScore.ONE_MEDIUM, lambda balance: balance.unfairness())
.justify_with(lambda balance, score: LoadBalanceJustification(balance.unfairness()))
.as_constraint("fairAssignmentCountPerTeam")) This causes (the Java LoadBalance class) to not be in the justification list; instead it is replaced by a double. You can try it out locally by checking out the branch and do |
Hello @Christopher-Chianelli, It works. Thank you very much! |
To reproduce:
Error:
The text was updated successfully, but these errors were encountered: