Skip to content

13 Run several simulations at once (tools/run_many.py) - #29

Merged
seanth merged 1 commit into
seanth:terrain-orgfrom
adamf:pr13-run-many
Sep 27, 2026
Merged

seanth merged 1 commit into
seanth:terrain-orgfrom
adamf:pr13-run-many

Conversation

@adamf

@adamf adamf commented Sep 24, 2026

Copy link
Copy Markdown

Builds on PR 9 (#25), for the -seed option from PR 3. It doesn't touch any of Vida's code, and doesn't depend on PRs 10–12. This PR's changes on their own.

Run several simulations at once (tools/run_many.py)

Within one simulation everything happens in a set order, drawing on the same stream of random numbers, so one simulation can't be split across cores without changing its results. But separate simulations don't share anything. This tool runs each one as its own copy of Vida, side by side, so a computer with 4 or 8 cores gets through 4 or 8 times as many runs.

# the same simulation with the random seeds 1 to 8, four at a time
python tools/run_many.py -seeds 1-8 -jobs 4 -- -n forest -w 100 -s 400 -t 50

# a list of different simulations, one line of options each
python tools/run_many.py -file runs.txt
  • Names: with -seeds, each run is named after the -n name and its seed (forest-seed1, forest-seed2, ...). Its output goes where Vida puts it (Output-forest-seed1/), and what it prints goes to Output-forest-seed1.log next to it.
  • How many at once: -jobs defaults to the number of cores.
  • Summary: at the end it says how long everything took, and which runs failed, if any.

Checked

  • Speed: on a 4-core machine, four 100 m, 400-seed, 50-cycle runs took 41.0 s one after another and 11.7 s side by side.
  • Same results: each of those runs' viewer.jsonl (every plant, every cycle) is identical to the same seed run on its own, apart from the run's name.
  • Unit tests cover reading the seeds and the file, and naming the runs.

Also

The HOWTO gets a short section next to -x, which still runs its repeats one after another. The -x repeats share one stream of random numbers: the second repeat starts where the first one left off. So they can't simply run side by side with the same results. run_many gives each run its own seed instead.

🤖 Generated with Claude Code

https://claude.ai/code/session_013425y5x98TqAv3BvHodpdx

**Builds on PR 8 (seanth#24)**; it uses the `-rngstart` option from PR 3. It doesn't touch any of Vida's code, and doesn't depend on PRs 10–12. [This PR's changes on their own](pr8-web-viewer...pr13-run-many).

## Run several simulations at once (`tools/run_many.py`)

Within one simulation everything happens in a set order, drawing on the same stream of random numbers, so one simulation can't be split across cores without changing its results. But separate simulations don't share anything. This tool runs each one as its own copy of Vida, side by side, so a computer with 4 or 8 cores gets through 4 or 8 times as many runs.

```sh
# the same simulation with -rngstart 1 to 8, four at a time
python tools/run_many.py -rngstarts 1-8 -jobs 4 -- -n forest -w 100 -s 400 -t 50

# a list of different simulations, one line of options each
python tools/run_many.py -file runs.txt
```

- **Names:** with `-rngstarts`, each run is named after the `-n` name and its `-rngstart` (`forest-rng1`, `forest-rng2`, ...). Its output goes where Vida puts it (`Output-forest-rng1/`), and what it prints goes to `Output-forest-rng1.log` next to it.
- **How many at once:** `-jobs` defaults to the number of cores.
- **Summary:** at the end it says how long everything took, and which runs failed, if any.

### Checked
- **Speed:** on a 4-core machine, four 100 m, 400-seed, 50-cycle runs took 41.0 s one after another and 11.7 s side by side.
- **Same results:** each of those runs' `viewer.jsonl` (every plant, every cycle) is identical to a run with the same `-rngstart` on its own, apart from the run's name.
- **Unit tests** cover reading the `-rngstarts` list and the file, and naming the runs.

### Also
The HOWTO gets an example 9, next to example 8's `-x`, which still runs its repeats one after another. The `-x` repeats share one stream of random numbers: the second repeat starts where the first one left off. So they can't simply run side by side with the same results. `run_many` gives each run its own `-rngstart` instead.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_013425y5x98TqAv3BvHodpdx
@seanth
seanth changed the base branch from master to terrain-org September 27, 2026 21:07
@seanth
seanth merged commit ef95822 into seanth:terrain-org Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants