Calculation Error in Difference Operator
System dynamics program with additional features for economics
Brought to you by:
hpcoder,
profstevekeen
Going to have to do a git bisect to figure out where this regression came in. No work has taken place around the difference operator for more than a year, Also funny that the difference operator is a plain delta, rather than delta^- like it is in 3.18.
Reducing priority to 3, as this is not fatal or critical.
This issue turns out to be collateral damage from the fix for https://sourceforge.net/p/minsky/tickets/1886/, which also brought in unordered index elements (for performance reasons).
It would have been present in 3.21 beta, but because of the deadlock issue with Ravels, you didn't get to see that issue before it got pushed to production releases.
The workaround for now is to downgrade to the latest 3.20 version. Originally, I thought to reinstate the version of civita used in 3.20, but then that would revert the fix for #1886. So I'll need to fix the actual root of the problem, which is the assumption of sorted indices, both in the difference operator, and audit the codebase to see if any other operator is affected.
Also need to see what unit tests can be added that would have picked up this problem before it got pushed to production.
Took a bit to create a unit test that actually triggered this bug, so unit testing actually would have really caught this issue anyway. I did audit the codebase, and potentially flagged outerproduct, gather and index operators as affected by this "collateral damage" as well. I modified unit tests to try to trigger any bugs, so far they all passed, so as far as I know ATM, there are no issues with those operators. I also tried asking Github Copilot to audit the codebase as well, and it was completely clueless. It flagged a bunch of lines that were irrelevant, and didn't flag the lines I found.
So ultimately, one line of code needed changing to use sorted indices in computing the difference.