HiGHS icon indicating copy to clipboard operation
HiGHS copied to clipboard

highspy: updated highs_linear_expression to be immutable for issue #1888

Open mathgeekcoder opened this issue 1 year ago • 2 comments

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 qsum for faster aggregation
  • added expr == [lb,ub] -> lb <= expr <= ub syntax
  • 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.

mathgeekcoder avatar Aug 23 '24 00:08 mathgeekcoder

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.

odow avatar Aug 23 '24 02:08 odow

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.

mathgeekcoder avatar Aug 23 '24 15:08 mathgeekcoder

Abandoning this PR, as it has been replaced by #1942.

mathgeekcoder avatar Sep 23 '24 18:09 mathgeekcoder