Fix simplex and finance bugs, repair broken test suites, add CI#3
Open
shehio wants to merge 4 commits into
Open
Fix simplex and finance bugs, repair broken test suites, add CI#3shehio wants to merge 4 commits into
shehio wants to merge 4 commits into
Conversation
The pivot-column search and the optimality check only scanned the first `rows` entries of the objective row, so problems with more decision variables than tableau rows terminated early with a wrong optimum (e.g. max x+2y+3z s.t. x+y+z<=10 returned 20 instead of 30). Both loops now scan every coefficient column. simplex() also never returned its result and ran the demo example at module load. It now returns the final tableau, exports matrix/simplex, and keeps the demo behind a require.main guard. The previously empty simplex.test.ts (which failed the jest run) now covers the Richland example (P=330), the regression case above, and input validation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
calculateArithmaticReturnsForAdjClose divided the price change by the current price instead of the previous one; a 100 -> 110 move should be a 10% return, not ~9.09%. The test suite failed to even run: it imported `stockHelper` while the export is `StockHelper`, and its only test called the long-dead Yahoo Finance API with empty dates. Replaced with deterministic unit tests for the return calculation and getStats. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
travis-ci.org shut down and the config targeted Node 12 with the gulp pipeline. The new workflow runs npm install + npm test (jest) on Node 20 for pushes to develop/master and all pull requests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
README now shows how to install and run the tests, maps each directory to the algorithms it contains, and carries the CI badge. package.json repository/bugs/homepage URLs pointed at the repo's old name (shehio/nash); they now point at shehio/Project-Nash. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Improvements
Bug fixes (verified with reproducible cases)
src/linear-programming/simplex.js): the optimality check and pivot-column search only scanned the firstrowsentries of the objective row, so LPs with more decision variables than tableau rows returned a wrong optimum — e.g. maxx + 2y + 3zs.t.x + y + z <= 10returned 20 instead of 30. Both loops now scan every coefficient column.finance/stock.ts):calculateArithmaticReturnsForAdjClosedivided the price change by the current price instead of the previous one, so a 100 → 110 move reported ~9.09% instead of 10%.Test suite repairs (2 of 10 suites failed to run on develop)
src/linear-programming/test/simplex.test.tswas an empty file (jest errors on it).simplex()also never returned a result and ran its demo at module load — it now returns the final tableau, exportsmatrix/simplex, and keeps the demo behind arequire.mainguard. New tests cover the Richland example (P = 330), the regression case above, and input validation.finance/test/stock.test.tsimportedstockHelper(export isStockHelper) and its only test called the long-dead Yahoo Finance API with empty dates. Replaced with deterministic unit tests for the return calculation andgetStats.CI
npm install+npm teston Node 20 for pushes to develop/master and PRs.Docs & metadata
package.json: repository/bugs/homepage URLs pointed at the repo's old name (shehio/nash); nowshehio/Project-Nash.Result:
npx jestgoes from 8/10 suites (29 tests, 2 suites failing to run) to 10/10 suites, 34 tests passing.Note (not addressed here, flagging only):
npm installreports 51 vulnerabilities in the aging dependency tree; several deps (yahoo-finance,sync-request, mathjs 3.x) are unmaintained. Upgrading is a larger, behavior-affecting change.🤖 Generated with Claude Code
https://claude.ai/code/session_014qGzgE6vMaqymzipNFYTDT