Skip to content

Faster ignition placement; results identical - #30

Merged
eliotmcintire merged 1 commit into
developmentfrom
fasterIgnitionPlacement
Oct 12, 2026
Merged

eliotmcintire merged 1 commit into
developmentfrom
fasterIgnitionPlacement

Conversation

@eliotmcintire

Copy link
Copy Markdown
Collaborator

Each year the module picks which small map cells ignite inside every coarse cell that has a fire. It did this by searching the whole landscape table once or twice per fire, which was slow on large maps; it now sorts the candidates once. The fires, escapes and random numbers are exactly the same.

Affects: speed only; results identical.

Technical details

Defect: fireSense_ignitionPredict.R:196-206 (development f11d27e) did igs[chunkyPixels == n] and ig[pixelID %in% drawn] on the 1.26M-row fine-pixel table for every ignited coarse pixel (300+ a year). New placeIgnitions() (same file, after fineCoarseTable()) does one split() of the candidate rows and a pixelID -> row lookup. The sample() calls are the same, in the same order, on the same candidate vectors, so the random stream is unchanged. The sample(x, size) behaviour for a single candidate (draws from 1:x) is kept on purpose; it is a separate known issue, not fixed here. The module has no R/ folder and its helpers live in the module file, so the function is there; the test is tests/testthat/test-place-ignitions.R.

Tests: the new test compares against a labelled copy of the old code for 6 seeds, a coarse pixel with exactly one candidate, and coarse pixels with zero ignitions (identical output and .Random.seed). convertToPackage(buildDocuments = TRUE) + test_local: branch all pass (2 existing skips for the known single-candidate defect); base with only the new test file: 3 errors (no placeIgnitions), the rest pass.

Real 14.3 state (profile harness, 4 threads), seeds 11/2/3: identical() TRUE for ignitionsAndEscapes (335/344/328 ignitions), the probability rasters (seed 11) and .Random.seed. IgnitionPredictRun 2.2-2.3 s -> 0.4-0.5 s.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv

…xel full scans

Same sample() calls in the same order; ignitions and random stream unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
@eliotmcintire eliotmcintire added enhancement New feature or request backwards compatible Existing code and results keep working unchanged labels Oct 12, 2026
@eliotmcintire
eliotmcintire merged commit 15e3c13 into development Oct 12, 2026
6 checks passed
@eliotmcintire
eliotmcintire deleted the fasterIgnitionPlacement branch October 12, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant