MonteCarlo `append=True` does not continue the same seeded run

Ouverte
#1,075 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
45/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
python
Domaine
backend

Piste de recherche

Start by reading simulate() and how _initial_sim_idx and num_of_loaded_sims are used, then inspect the output-file loading and parallel worker index handling. The issue proposes storing root state in a versioned sidecar and validating append seeds, but calls out migration or re-baselining for older files. Done means appended runs preserve the seeded sequence and use present simulation indices correctly, with tests covering interrupted runs and seed mismatches.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Monte Carlo
Context

Per-simulation seeding from #1054 makes a single simulate() run reproducible, but continuing a run across calls with append=True is a separate piece that still has two gaps. This came up while reviewing #1054, and I am filing it on its own so that PR can stay scoped to the per-index seeding in #1053.

The two gaps

The root seed is not persisted. simulate() re-derives the seed root from random_seed on every call, so:

mc.simulate(100, random_seed=42)
mc.simulate(200, append=True)          # random_seed defaults to None -> a fresh root

the second call draws a new root, and indices 100..199 belong to a different random draw than the first 100. Passing a different seed on the append is worse, since the output then mixes samples from two unrelated roots with no warning.

The next index comes from a row count. _initial_sim_idx is num_of_loaded_sims, which counts rows in the output file. If a parallel run is interrupted and leaves a gap (indices 0, 2, 3 written, 1 missing), the append starts at index 3: index 3 repeats and index 1 is never filled. Workers claim an index before running and finish out of order, so a gap after a failure is a real possibility rather than a corner case.

A possible direction

Persist the root state (plus a small schema version) in a sidecar next to the output. On append=True, load that root instead of deriving a new one, take the next index from the set of indices actually present rather than a row count, and reject an append whose random_seed disagrees with the stored root. Output files written before this exists would need an explicit migration or a re-baseline.

Happy to take this on as a follow-up to #1054.

Langage dominant
Python
Étoiles
1.1k
Forks
280
Merge moyen
3 j 2 h
PR mergées (30 j)
24

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de RocketPy-Team/RocketPy

Toutes les issues de RocketPy-Team/RocketPy

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.