parent
44cb69583f
commit
05372eef68
1 changed files with 29 additions and 0 deletions
|
@ -2,6 +2,7 @@ import argparse
|
||||||
import typing as t
|
import typing as t
|
||||||
import random
|
import random
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from collections import defaultdict
|
||||||
import logging
|
import logging
|
||||||
import jinja2 as j2
|
import jinja2 as j2
|
||||||
|
|
||||||
|
@ -179,6 +180,32 @@ def export_latex(config: Config, groupes: list[list[str]]) -> str:
|
||||||
return template.render(**env)
|
return template.render(**env)
|
||||||
|
|
||||||
|
|
||||||
|
def log_assignment_toughness(config: Config):
|
||||||
|
"""Prints each group's assigned tasks toughness"""
|
||||||
|
|
||||||
|
grp_tough: dict[int, int] = defaultdict(int)
|
||||||
|
|
||||||
|
def explore_tasks(task: Task | Category):
|
||||||
|
if isinstance(task, Task):
|
||||||
|
assert task.assigned is not None
|
||||||
|
for grp in task.assigned:
|
||||||
|
grp_tough[grp] += task.tough
|
||||||
|
else:
|
||||||
|
for child in task.tasks:
|
||||||
|
explore_tasks(child)
|
||||||
|
|
||||||
|
explore_tasks(config.taches)
|
||||||
|
|
||||||
|
grp_ids = list(grp_tough.keys())
|
||||||
|
grp_ids.sort()
|
||||||
|
tough_lines = []
|
||||||
|
for grp_id in grp_ids:
|
||||||
|
tough_lines.append(f"{grp_id+1:2d} : {grp_tough[grp_id]:3d}")
|
||||||
|
out_str = "Répartition des pénibilités :\n" + "\n".join(tough_lines)
|
||||||
|
|
||||||
|
logger.info(out_str)
|
||||||
|
|
||||||
|
|
||||||
def repartition(config: Config) -> list[Group]:
|
def repartition(config: Config) -> list[Group]:
|
||||||
"""Crée des groupes et assigne des tâches"""
|
"""Crée des groupes et assigne des tâches"""
|
||||||
groupes: list[Group] = constituer_groupes(config.choristes)
|
groupes: list[Group] = constituer_groupes(config.choristes)
|
||||||
|
@ -255,6 +282,8 @@ def main() -> None:
|
||||||
logger.critical("Échec de répartition des tâches.")
|
logger.critical("Échec de répartition des tâches.")
|
||||||
raise exn from exn
|
raise exn from exn
|
||||||
|
|
||||||
|
log_assignment_toughness(config)
|
||||||
|
|
||||||
if args.to_intermed:
|
if args.to_intermed:
|
||||||
intermed = intermed_file.IntermedFile.from_assignment(config, groupes)
|
intermed = intermed_file.IntermedFile.from_assignment(config, groupes)
|
||||||
intermed.sanity_check()
|
intermed.sanity_check()
|
||||||
|
|
Loading…
Reference in a new issue