Skip to content

[#416] Remove clamping from balance checks - #425

Open
priyanshusky0 wants to merge 2 commits into
PecanProject:masterfrom
priyanshusky0:416-remove-balance-clamping
Open

priyanshusky0 wants to merge 2 commits into
PecanProject:masterfrom
priyanshusky0:416-remove-balance-clamping

Conversation

@priyanshusky0

@priyanshusky0 priyanshusky0 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • What: Removes the clamping checks from the balance tracker and moves updateBalanceTrackerPostUpdate() to after ensureNonNegativeStocks(), replacing updateBalanceTrackerPostClamp().
  • Motivation: SIPNET now exits on negative stocks, so the clamping accounting is no longer needed.

As discussed in #416, the balance tolerance is now 10 * EPS to allow for small rounding adjustments adding up within a step.

This is built on top of #414, so that commit will show here until #414 is merged.

How was this change tested?

  • make unit and make smoke pass, no smoke output changes
  • Removed the clamping assertions from the existing tests

Related issues

Checklist

  • Related issues are listed above.
  • PR title has the issue number in it
  • Tests added/updated for new features (if applicable)
  • Documentation updated (if applicable)
  • docs/CHANGELOG.md updated with noteworthy changes
  • Code formatted with clang-format

@Alomir

Alomir commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@priyanshusky0 Please resolve the branch conflicts for this PR, thanks!

ensureNonNegative now exits on real violations, so the balance tracker no
longer needs to account for mass added by clamping. Drop the clamped and
final totals, take the post-update totals after ensureNonNegativeStocks(),
and compute system inputs and outputs in updateBalanceTrackerPostUpdate().

Widen the balance tolerance to 10 * EPS to allow for several sub-EPS
stocks being zeroed in the same step.
@priyanshusky0
priyanshusky0 force-pushed the 416-remove-balance-clamping branch from d0910e7 to 5cf89ab Compare November 5, 2026 12:38
@priyanshusky0

Copy link
Copy Markdown
Contributor Author

@Alomir Rebased onto master, conflicts resolved, and CI is passing. Ready for review, thanks!

This branch has not been deployed

No deployments
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.

Remove "clamping" from balance checks

2 participants