Repository navigation
Leave out products for a ceiling the water already exceeds (#86) - #87
Merged
Merged
Conversation
recommend() raised 'NNLS did not reach optimality' when the source water alone exceeded one declared maximum while another was binding, for example 9% of the station 104 well with Na and Cl maxima of 3 mmol/L. A ceiling the water already reaches cannot be met, so its Lagrange search (#68) never closed its bracket and grew the shift on every step until the right-hand side was about 2^60 times the limit; with a second active ceiling NNLS then failed. Any product carrying that ion only adds to the violation, so the fit now leaves those products out directly, the infinite-multiplier limit the search was approaching. The excess is still reported in limitViolations. Over 312 formula x water share x ceiling cases the recipes are identical wherever the old search succeeded; the failing cases equal the fit without chloride products.
rafatahmed
added a commit
that referenced
this pull request
Nov 7, 2026
Leave out products for a ceiling the water already exceeds (#86)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #86.
recommend()raisedNNLS did not reach optimalitywhen the water alone already exceeded one declared maximum while another maximum was binding. Example: 9% of the station 104 well with Na and Cl maxima of 3 mmol/L. Reproduction, root cause and a table of failing cases are in #86.Fix.
_fit_withinnow detects a ceiling that the water background already reaches. Any product carrying that ion can only add to the violation, so the fit leaves those products out directly. That is the limit the old Lagrange search was approaching: its shift grew without bound and, with a second active ceiling, overflowed NNLS. The excess is still reported inlimitViolations.Evidence.
mainwherevermainsucceeded.test_a_ceiling_the_water_already_breaks_is_reported_not_a_solver_failure: it fails onmainwith the NNLS error and passes here.Validation.
FLAHAX_REQUIRE_PHREEQC=1unittest: 424 tests OKverify_distribution: PASSsphinx -W: clean--check: okFound while writing the grower walkthrough (#80). That PR follows separately and builds on this one.