Skip to content
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

chore: port sports-league-scheduling quickstart example from Java to Python #685

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

PatrickDiallo23
Copy link

@PatrickDiallo23 PatrickDiallo23 commented Jan 15, 2025

Description of the change

Port the sports-league-scheduling quickstart example from Java to Python while keeping the same functionality.

Checklist

Development

  • The changes have been covered with tests, if necessary.
  • You have a green build, with the exception of the flaky tests.
  • UI and JS files are fully tested, the user interface works for all modules affected by your changes (e.g., solve and analyze buttons).
  • The network calls work for all modules affected by your changes (e.g., solving a problem).
  • The console messages are validated for all modules affected by your changes.

Code Review

  • This pull request includes an explanatory title and description.
  • The GitHub issue is linked.
  • At least one other engineer has approved the changes.
  • After PR is merged, inform the reporter.

@triceo
Copy link
Contributor

triceo commented Jan 15, 2025

Thanks for the contribution, @PatrickDiallo23!
We'll take a look when time permits.

Copy link
Contributor

@Christopher-Chianelli Christopher-Chianelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @PatrickDiallo23! I am impressed with the quality of the port. Some suggestions for improvement + consistency with the other quickstarts.

@PatrickDiallo23
Copy link
Author

Hello @Christopher-Chianelli! I did another commit where I applied your code suggestions. Please review. Thank you!

Copy link
Contributor

@Christopher-Chianelli Christopher-Chianelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mild formatting changes. It appears you missed the requested changes that were hidden by default (since GitHub automatically hides requested changes in the middle when there are many requests). Do the missed requested changes + the formatting ones, then it'll LGTM.

@@ -81,7 +81,7 @@ def start_to_away_hop(constraint_factory: ConstraintFactory) -> Constraint:
.for_each(Match)
.if_not_exists(Round, Joiners.equal(lambda match: match.round.index - 1,
lambda match_round: match_round.index))
.penalize(HardSoftScore.ONE_SOFT, away_home_match_distance_lambda)
.penalize(HardSoftScore.ONE_SOFT, lambda match: (match.away_team.get_distance(match.home_team)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parenthesis uneccessary

Suggested change
.penalize(HardSoftScore.ONE_SOFT, lambda match: (match.away_team.get_distance(match.home_team)))
.penalize(HardSoftScore.ONE_SOFT, lambda match: match.away_team.get_distance(match.home_team))

@@ -91,7 +91,7 @@ def home_to_away_hop(constraint_factory: ConstraintFactory) -> Constraint:
.join(Match,
Joiners.equal(lambda match: match.home_team, lambda match: match.away_team),
Joiners.equal(lambda match: match.round.index + 1, lambda match: match.round.index))
.penalize(HardSoftScore.ONE_SOFT, home_matches_distance_lambda)
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(other_match.home_team)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(other_match.home_team)))
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: match.home_team.get_distance(other_match.home_team))

@@ -101,7 +101,7 @@ def away_to_away_hop(constraint_factory: ConstraintFactory) -> Constraint:
.join(Match,
Joiners.equal(lambda match: match.away_team, lambda match: match.away_team),
Joiners.equal(lambda match: match.round.index + 1, lambda match: match.round.index))
.penalize(HardSoftScore.ONE_SOFT, home_matches_distance_lambda)
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(other_match.home_team)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(other_match.home_team)))
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: match.home_team.get_distance(other_match.home_team))

@@ -111,45 +111,22 @@ def away_to_home_hop(constraint_factory: ConstraintFactory) -> Constraint:
.join(Match,
Joiners.equal(lambda match: match.away_team, lambda match: match.home_team),
Joiners.equal(lambda match: match.round.index + 1, lambda match: match.round.index))
.penalize(HardSoftScore.ONE_SOFT, home_away_matches_distance_lambda)
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(match.away_team)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: (match.home_team.get_distance(match.away_team)))
.penalize(HardSoftScore.ONE_SOFT, lambda match, other_match: match.home_team.get_distance(match.away_team))


def away_to_end_hop(constraint_factory: ConstraintFactory) -> Constraint:
return (constraint_factory
.for_each(Match)
.if_not_exists(Round, Joiners.equal(lambda match: match.round.index + 1,
lambda match_round: match_round.index))
.penalize(HardSoftScore.ONE_SOFT, home_away_match_distance_lambda)
.penalize(HardSoftScore.ONE_SOFT, lambda match: (match.home_team.get_distance(match.away_team)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.penalize(HardSoftScore.ONE_SOFT, lambda match: (match.home_team.get_distance(match.away_team)))
.penalize(HardSoftScore.ONE_SOFT, lambda match: match.home_team.get_distance(match.away_team))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants