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

Đang mở
#1,075 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
1.1k
Fork
280
Merge trung bình
3 ngày 2 giờ
Pull request đã merge (30 ngày)
24

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của RocketPy-Team/RocketPy

Tất cả issue của RocketPy-Team/RocketPy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.