Skip to content

adjustSizeGrid(): warn on per-species diet loss instead of resource biomass#453

Merged
gustavdelius merged 1 commit into
masterfrom
diet-loss-warnings
Jul 15, 2026
Merged

adjustSizeGrid(): warn on per-species diet loss instead of resource biomass#453
gustavdelius merged 1 commit into
masterfrom
diet-loss-warnings

Conversation

@gustavdelius

Copy link
Copy Markdown
Member

Summary

Reworks the resource-truncation warnings in adjustSizeGrid() so they report what actually matters for the model dynamics — how much of each species' food (encounter) is discarded — rather than resource biomass.

Changes

  • High-end resource truncation now warns on diet loss, not resource biomass. The previous check warned when a non-negligible fraction of resource biomass was discarded above the new maximum size. Biomass loss is not the relevant quantity: encounter feeds growth and reproduction only through the fish's total food intake. The new check mirrors the existing low-end (smallest-fish) check but is evaluated at the largest size each species occupies, where the largest resource particles matter most. It reports the lost resource encounter as a fraction of that fish's total encounter.

  • Consistent wording. The low-end and high-end messages now read symmetrically — "Non-negligible diet of smallest/largest fish was lost due to resource truncation: ...". Both are the same kind of ratio (lost resource encounter ÷ total encounter), sampled at the most-exposed fish size for the part of the resource being removed.

  • Per-species clarity in the docs. The tol parameter documentation now states explicitly that all three checks — species biomass, smallest-fish diet, largest-fish diet — are applied separately to each species, and the warning lists the affected species.

  • More useful precision. Lost fractions are reported with 3 significant figures (%g of signif(x, 3)) instead of two decimal places. With the default tol = 1e-6, a loss just above threshold now shows as 0.0001% rather than the uninformative 0.00%.

Testing

testthat::test_file("tests/testthat/test-manipulate_species.R") — all 137 tests pass. The existing high-end-truncation test was updated to expect the new largest-fish diet message.

🤖 Generated with Claude Code

The high-end resource truncation check previously warned when
non-negligible resource *biomass* was discarded above the new maximum
size. Biomass loss is not the relevant quantity: what matters is whether
truncation changes the food a fish actually gets. This replaces that
check with a per-species diet-loss check, mirroring the existing low-end
check, evaluated at the largest size each species occupies (where the
largest resource matters most). It reports the fraction of the fish's
total encounter that is lost.

The low-end and high-end resource checks now use consistent wording
("diet of smallest/largest fish ... lost due to resource truncation"),
and the tol documentation makes clear that all three checks (biomass,
smallest-fish diet, largest-fish diet) are applied separately to each
species.

Lost fractions are now reported with 3 significant figures rather than
two decimal places, so a loss just above the default tol = 1e-6 shows as
0.0001% instead of 0.00%.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gustavdelius gustavdelius merged commit 52951e2 into master Jul 15, 2026
@gustavdelius gustavdelius deleted the diet-loss-warnings branch July 15, 2026 09:49
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.

1 participant