-
-
Couldn't load subscription status.
- Fork 683
Closed
Description
I'd like to have sage.numerical.linear_functions.LinearConstraint to be a hashable type.
Currently it is not:
sage: p = MixedIntegerLinearProgram()
sage: b = p.new_variable()
sage: b[0] <= b[1] <= 2
x_0 <= x_1 <= 2
sage: hash(b[0] <= b[1] <= 2)
...
TypeError: unhashable type: 'sage.numerical.linear_functions.LinearConstraint'
This is for the following reasons:
- When adding constraints to an instance of a
MixedIntegerLinearProgram, it is not necessary to add the same or equivalent constraint multiple times. A hash could be used to determine distinct linear constraints that are added into a MILP instance. - By having hashable linear constraints, one could allow for linear constraints to be added into sets (http://docs.python.org/2/library/sets.html) or used as keys in dictionaries.
Thanks,
Clinton
CC: @nathanncohen @vbraun @dimpase
Component: linear programming
Keywords: linear constraint, mixed integer linear program
Reviewer: Dima Pasechnik
Issue created by migration from https://trac.sagemath.org/ticket/15583