Skip to content

WIP: Evolutionary network design branch#1600

Draft
tahini wants to merge 115 commits into
mainfrom
evolutionaryTransitNetworkDesign
Draft

WIP: Evolutionary network design branch#1600
tahini wants to merge 115 commits into
mainfrom
evolutionaryTransitNetworkDesign

Conversation

@tahini

@tahini tahini commented Nov 25, 2025

Copy link
Copy Markdown
Collaborator

Feature branch for the evolutionary transit network design algorithm implementation.

Current status: It compiles!!!... 👯

TODO:

frontend:

  • Nettoyage... beaucoup de nettoyage...
  • Utiliser les option descriptor pour les paramètres de conception de réseau aussi (1re section)
  • Fournir et afficher des messages d'aide dans les formulaires des option descriptors (encore connus sous le nom de SimulationAlgorithmOptionDescriptor)
  • Ajouter un type secondsToMinutes ou qqc du genre aux option descriptors pour permettre d'avoir des valeurs en secondes, mais indiquer de les faire entrer en minutes dans les UI.
  • Validation de chaque étape. S'assurer que le bouton Suivant soit actif seulement si tout est valide. Tous les champs n'ont pas encore été validés
  • Valeurs par défaut des objets. Bien que les valeurs par défaut s'affichent dans l'interface, elles ne sont pas automatiquement assignées aux objets correspondant, donc elles peuvent rester non-définies si non-modifiées
  • Traductions des champs non-traduits (ou mise à jour des traductions, car elles sont déjà en qq part) (@kaligrafy)
  • Affichage du résumé et confirmation sur la dernière page.
  • Permettre de visualiser les résultats (@kaligrafy)

backend:

  • Faire fonctionner qqc, la job ne roule de toute évidence pas, ni ne complète avec une exception. Donc au moins faire qq générations avec des console.log
  • Revoir le flot au complet, les types ont été changés pour passer la Job et pour que ça compile, mais ça a probablement brisé beaucoup de choses.
  • Ajouter les méthodes de simulation (pour l'instant, c'est des valeurs par défaut)
  • Sauvegarder les résultats en qq part somehow
  • Gérer la cache correctement (ou s'assurer que c'est géré correctement?)
  • S'arranger pour que la cache n'ait pas besoin d'un symlink dans le répertoire de cache principale...
  • Gérer les checkpoints et le internal_data pour récupérer la Job en cas d'arrêt
  • Ajouter des checkpoints au niveau des candidats, pour récupérer les jobs en cours et déjà complétées
  • Sauvegarder les messages d'erreur dans la tâche pour pouvoir les visualiser
  • S'assurer que les messages d'erreur sont tous compréhensibles et exhaustifs pour l'utilisateur (@kaligrafy)
  • Gérer l'annulation de la tâche
  • Faire fonctionner les tests
  • Ajouter de nouveaux tests
  • Emettre la progression de la tache, présentement stuck à "en attente" (@kaligrafy)
  • Fixer ratio des ODs à utiliser pour le calcul et vérifier implémentation (@kaligrafy)
  • Vérifier ce qui se passe avec des lignes directionnelles? Possiblement ajouter un param: ramener le véhicule ou téléportation (@kaligrafy)
  • Pondération à partir du fichier OD (@tahini, @kaligrafy)
  • Déplacer les fonction de "fitness" hors du fichier de préférence
  • Trouver probleme de l'interface qui gèle pour Yannick sur Chrome
  • Documenter et, peut-être, permettre de paramétrer les fonctions de fitness
  • Faire un sample du fichier des OD trips pour les tâches de calculs: mettre une heure de départ aléatoire entre 8 et 9 AM.
  • S'assurer que les scénarios sauvegardés ont des horaires pour la journée complète: pour simplifier la quantité de données à traiter, les différents services à simuler ne couvrent qu'une petite période de la journée (2x le plus long trajet avant 8AM et après 9AM). Si on ne conserve que ça, seuls les trips dans ces horaires seront routés
  • Add a friendly name to simulations so that scenarios associated with it can be easily identified and remove the GAL from scenario names. Add the jobID (in case someone copies the job parameters without changing the name, each run needs to have a unique name) to the name and if there is no name specified, only the jobID will identify the job
  • Add a README to packages/transition-backend/src/services/evolutionaryAlgorithm/ To describe the various directory
  • the maximum interval seems to be an exclusive value, putting 30 minutes seem to rather cap to 29 minutes
  • Generate result files even if the job failed
  • Dans les résultats, différencier non-routés des erreurs, au moins en les comptant.
  • s'assurer que la destruction de la job parent ne cause pas trop d'erreur aux enfants en cours. Tout doit se terminer de façon harmonieuse (il y a présentement beaucoup de lgos d'erreurs dans ce cas)
  • Dans une run sur l'infra, il y a eu un cas où les fichiers dans les resources ne se sont pas sauvegardés correctement. La tâche a terminé, les fichiers étaient bien sur le serveur, mais pas dans les resources de la tâche. Hypothèse: race condition, manque un await en qq part.
  • Valider la période pour laquelle on fait des horaires. Je crois que c'est 8 à 9 +/- 2 fois le plus long trajet, mais ça peut faire en sorte qu'il va manquer de service sur la zone à desservir si un trajet part à 9h de très loin.

@tahini tahini force-pushed the evolutionaryTransitNetworkDesign branch 6 times, most recently from 2a054d3 to 4028711 Compare December 1, 2025 21:51
@tahini tahini force-pushed the evolutionaryTransitNetworkDesign branch 6 times, most recently from 1221c70 to d51a1d8 Compare December 8, 2025 22:15
@kaligrafy kaligrafy force-pushed the evolutionaryTransitNetworkDesign branch from d51a1d8 to 5e6d988 Compare December 15, 2025 15:28
@tahini tahini force-pushed the evolutionaryTransitNetworkDesign branch 2 times, most recently from 8bfa962 to cac37ff Compare January 12, 2026 18:01
@tahini tahini force-pushed the evolutionaryTransitNetworkDesign branch from 4013509 to 6e332e1 Compare January 22, 2026 01:08
@tahini tahini force-pushed the evolutionaryTransitNetworkDesign branch 2 times, most recently from 9dda198 to 100d441 Compare February 7, 2026 02:15
@tahini tahini force-pushed the evolutionaryTransitNetworkDesign branch 2 times, most recently from e623079 to 9a493e6 Compare February 20, 2026 15:22
@coderabbitai

coderabbitai Bot commented Feb 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 44bf59b7-678f-413f-9fbf-a64e3a203a3c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch evolutionaryTransitNetworkDesign

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tahini tahini force-pushed the evolutionaryTransitNetworkDesign branch 3 times, most recently from 8cc48d1 to 8f0171c Compare February 26, 2026 22:27
@greenscientist greenscientist force-pushed the evolutionaryTransitNetworkDesign branch 2 times, most recently from 2b7bb4f to c1f4dcf Compare February 27, 2026 01:04
kaligrafy and others added 28 commits May 20, 2026 08:02
The network design form now supports an optional node weight file
(node UUID + weight columns) alongside the existing demand file.
When provided, weights will be used to allocate vehicles to lines
proportionally to total line weight and cycle time.

- Add NodeWeightFromCsvMapper and field descriptors reusing the
  existing csvFile descriptor pattern (OdTripSimulationMethod)
- Reorder simulation method options so file inputs render last
- Show help text for nested/csvFile options in OptionsDescriptorWidgets
- Handle node weight file upload and replay in TransitNetworkJobController

Note: the line weighting process from node weights is not yet implemented.
Replace ExecutableJobComponent table with compact ButtonList/ButtonCell
rows with action icons (cancel, pause/resume, edit, duplicate, delete)
and expandable job details section.

Add edit button that opens the 4-step form in read-only mode for
existing jobs (disabled state derived from jobId presence). Fix disabled
prop propagation in OptionsDescriptorWidgets for select, multiselect,
nested, and CSV file option types.
Allow users to save the current network design form configuration
(excluding CSV file data) to user preferences and reload it later.

- Save config: persists form parameters to preferences via socket,
  stripping CSV file fields before storage
- Load config: if form is untouched, applies saved config directly;
  if user has made changes, shows a conflict modal with options to
  replace all or only fill unchanged sections
- Uses configVersion key to force step form remount on load,
  ensuring input widgets re-initialize with loaded values
- Adds success/error notifications for both save and load operations
Load optional node weights from the job's CSV into a private map on
the job wrapper, keeping them scoped to the job and out of the shared
node collection. The GA now uses these weights (defaulting to 1) in
the line weight formula: (sum of node weights) × cycle time.

Path data is resolved from the wrapper's collection manager via
path_ids rather than line.paths, fixing line weights returning null
on jobs resumed from cache. Add a one-time line weights breakdown
log at simulation start for debugging.
Export the weighted trip count (totalCount) and per-trip user cost
(usersHourlyCost / totalCount) in the simulation results output file,
making the GA's internal normalized fitness visible for analysis.
Replace raw JSON display in expanded job view with a structured
generations table showing best candidate fitness, normalized fitness,
line count and vehicle count per generation. Clicking a row opens a
modal listing each line's assigned vehicles, cycle time and headway.
in node accessibility and network design, auto select mapping for lat and lon fields when easy to guess
show fitness, routed and non-routed count
and fix path ids not being saved between restart of jobs
no longer useful and would clutter the console logs during jobs
Add method fitness to compare with normalized fitness
Make no-route error log suppression opt-in via a new
suppressExpectedRouteErrors parameter on Routing.calculate, so only the
OdTripSimulation code path silences expected routing failures while all
other callers retain full error logging.

Rename TRROUTING_NOT_ROUTING_* error codes to TRROUTING_NO_ROUTING_*
for consistency across the codebase.

Add parametric tests covering suppression behaviour for expected and
unexpected error codes.
The line objects are modified when fetching the schedules from the
database. When saving the individual lines to the database, this means
it keeps the schedules in memory even after the object is saved. It
should be deleted after saving to avoid out of memory exceptions.
Pass the scenario when constructing next generation's candidates from
elites such that the new scenario can be prepared using the previous'
services.
The source explains where each candidate comes from: either and `elite`
, `random`, `selected` from a single parent, the result of a `crossover`
between multiple parents. The 2 latter can also be mutated.

This information is added in the simulation result file, where the
scenario name is for easier identification of the candidate names.
This reverts commit b8af814.

The label received as props is often already translated by the calling
components, translating it once again just puts a translation string in
the main locale prefix. It breaks the previous behavior. The label
received in params should already be translated. If not set, then we
should fallback to a translated "Yes".
Show line-based logs ("Routing odTrip N/total", "calc/sec") on pipes/CI;
keep the interactive carriage-return progress bar when stdout is a TTY.

The new TrRoutingBatchLogger module exposes a BatchRoutingLogProgress
interface and a createBatchRoutingLogProgress factory that selects the
variant based on process.stdout.isTTY. Variant implementations are
module-private. TrRoutingBatch invokes beforeOdTrip/afterOdTrip in the
same scope (try/finally of the promise queue task) so both hooks evolve
together and afterOdTrip always runs even when odTripTask throws.

Made-with: Cursor
BatchRoutingLogProgressParams is reduced to { odTripsCount, startIndex }.
Each variant now captures its own performance.now() as benchmarkStart and
the non-interactive variant derives its own progressStep (1% of the batch,
capped at 500 trips between two log lines to avoid spam on huge batches).

The caller keeps its own benchmarkStart and progressStep for unrelated
concerns (final summary, progress emit cadence) but no longer needs to
share them with the logger. Tests use mockReturnValueOnce to set up time
mocks upfront and parametrize beforeOdTrip cases by odTripsCount, which
exercises the internal step policy (including the cap at 500).
This allows to keep some data in candidates during simulation and
cleanup all candidates at the same time at the end of the generation's
simulation. It will allow to save simulation results to file for the
best candidates at the end of the job.
In the job's `getFiles` socket route, the return `title` is now of type
`TranslatableMessage` where the `filename` is a parameter.

To be able to support various output files not known in advance, and
translate their titles correctly, instead of putting the file key as
translation key, the file key is now a context, that can be used in
individual translations instead of an object with each key. The default
key can thus have a generic title, with the filename in it.

The translation string is now `transit:jobs:<jobName>:files`, with
params `filename` and `context`. The 'a' file of job named `b` can thus
be translated with a `jobs:b:files_a` key in the `transit.json` file.
The file result visitor, instead of receiving only a job in parameter,
now receives

- a job, which represents where the files will be outputted, it does not
  have to be batch routing job
- the batch routing parameter, these allow to define which files should
  be saved
- a file suffix, which will be appended to the filename, so that a job
  like the evolutionary transit network design can save multiple job
  output files for multiple jobs.
For each candidate for which the scenario is saved at the end of the
simulation, the results of the simulation jobs are also saved in the
main job's file storage, so it is available through the job's data.
The `OdTripSimulation` should not save the executorof the job, because
the object keeps some data in memory, like the odTrips, which may load
the memory when many candidates need to be run. We save the job instead
and simply recreate the executor when/if we need to handle the results.
@tahini tahini force-pushed the evolutionaryTransitNetworkDesign branch from 155d2cb to ec8cafe Compare May 20, 2026 12:30
With the ODTripSimulation, there is additional information in the
results data about the number of transfers, walking/travel/waiting
times, so these fields are added to the output file result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants