highspy: updated highs_linear_expression to be immutable for issue #1888
Changes should fix #1888
- changed highs_linear_expression to be immutable by default
- added
__repr__for easier debugging and pretty print linear expressions - added
__iadd__for mutable operations - added
qsumfor faster aggregation - added
expr == [lb,ub]->lb <= expr <= ubsyntax - updated chained comparison support to work in immutable setting
Note there are some low-risk caveats for the chained comparison support. I have documented them in the code. Though I believe the benefits outweigh the potential concerns.
I can't comment on the implementation (I don't know Python well), other than to say that, at minimum, this needs a bunch of tests.
I can't comment on the implementation (I don't know Python well), other than to say that, at minimum, this needs a bunch of tests.
Agreed. Working on this now, will update PR. BTW: the code changes for immutability are very simple. The chained comparison support definitely needs more testing, and I believe I've already found a couple of edge cases that need attention.
Abandoning this PR, as it has been replaced by #1942.