Artiste : heure de passage ; vœux d'artistes pris en compte par le solveur
Artist gagne start_time/end_time (end <= start ⇒ finit le lendemain, même convention que Shift/DayPart/Availability). Migration 0008. Le solveur (app/solver/) résout maintenant les fenêtres de passage des artistes que chaque bénévole veut voir (VolunteerArtist) et pénalise toute suggestion qui chevaucherait un passage souhaité — le bénévole raterait l'artiste. Comme le reste du scoring, c'est un terme de l'objectif, pas un blocage : pour un créneau urgent sans autre candidat, le solveur propose quand même, quitte à ce que ce soit un pis-aller. - SolverVolunteer.wished_artist_windows (fenêtres ShiftInfo précalculées par le loader depuis Artist + VolunteerArtist). - Nouveau malus _ARTIST_CONFLICT_PENALTY dans engine.py. - Tests : moteur (conflit détecté/ignoré hors chevauchement/toujours suggéré en dernier recours) + intégration API bout en bout. 176 tests, ruff et alembic check au vert. CLAUDE.md mis à jour (§2 et §4). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017uUsRg7XzopkCPWimwg9ZM
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
e47c29d35b
commit
fea9d37019
@@ -37,6 +37,7 @@ def _volunteer(
|
||||
*,
|
||||
availability=(),
|
||||
wished_position_ids=frozenset(),
|
||||
wished_artist_windows=(),
|
||||
existing_shifts=(),
|
||||
existing_minutes=0,
|
||||
) -> SolverVolunteer:
|
||||
@@ -44,6 +45,7 @@ def _volunteer(
|
||||
id=vid,
|
||||
availability=tuple(availability),
|
||||
wished_position_ids=frozenset(wished_position_ids),
|
||||
wished_artist_windows=tuple(wished_artist_windows),
|
||||
existing_shifts=tuple(existing_shifts),
|
||||
existing_minutes=existing_minutes,
|
||||
)
|
||||
@@ -146,3 +148,41 @@ def test_avoids_volunteer_who_would_exceed_eight_hours_that_day():
|
||||
fresh = _volunteer("fresh", availability=[_full_day(10)])
|
||||
solution = solve(SolverInput(shifts=(shift,), volunteers=(tired, fresh)))
|
||||
assert _by_shift(solution, "s1") == ("fresh",)
|
||||
|
||||
|
||||
def test_avoids_volunteer_whose_wished_artist_plays_during_the_shift():
|
||||
# Le créneau (14 h - 18 h) chevauche le passage de l'artiste (16 h - 17 h)
|
||||
# que « fan » veut voir : le solveur préfère « indiff », qui n'a pas ce
|
||||
# conflit.
|
||||
shift = _shift(start=_dt(10, 14), end=_dt(10, 18))
|
||||
passage = ShiftInfo(id="art1", starts_at=_dt(10, 16), ends_at=_dt(10, 17))
|
||||
fan = _volunteer(
|
||||
"fan", availability=[_full_day(10)], wished_artist_windows=[passage]
|
||||
)
|
||||
indiff = _volunteer("indiff", availability=[_full_day(10)])
|
||||
solution = solve(SolverInput(shifts=(shift,), volunteers=(fan, indiff)))
|
||||
assert _by_shift(solution, "s1") == ("indiff",)
|
||||
|
||||
|
||||
def test_still_suggests_the_only_candidate_despite_an_artist_conflict():
|
||||
# Le conflit d'artiste reste un avertissement, pas un blocage : s'il n'y a
|
||||
# personne d'autre pour un créneau urgent, le solveur propose quand même.
|
||||
shift = _shift(start=_dt(10, 14), end=_dt(10, 18))
|
||||
passage = ShiftInfo(id="art1", starts_at=_dt(10, 16), ends_at=_dt(10, 17))
|
||||
fan = _volunteer(
|
||||
"fan", availability=[_full_day(10)], wished_artist_windows=[passage]
|
||||
)
|
||||
solution = solve(SolverInput(shifts=(shift,), volunteers=(fan,)))
|
||||
assert _by_shift(solution, "s1") == ("fan",)
|
||||
|
||||
|
||||
def test_artist_conflict_outside_shift_hours_has_no_effect():
|
||||
# Le passage (20 h - 21 h) ne chevauche pas le créneau (14 h - 18 h) :
|
||||
# aucun malus, « fan » reste un candidat normal.
|
||||
shift = _shift(start=_dt(10, 14), end=_dt(10, 18))
|
||||
passage = ShiftInfo(id="art1", starts_at=_dt(10, 20), ends_at=_dt(10, 21))
|
||||
fan = _volunteer(
|
||||
"fan", availability=[_full_day(10)], wished_artist_windows=[passage]
|
||||
)
|
||||
solution = solve(SolverInput(shifts=(shift,), volunteers=(fan,)))
|
||||
assert _by_shift(solution, "s1") == ("fan",)
|
||||
|
||||
Reference in New Issue
Block a user