#15583: sage.numerical.linear_functions.LinearConstraint is not a hashable type
-------------------------------------------------+-------------------------
Reporter: cbowen | Owner:
Type: enhancement | Status: new
Priority: trivial | Milestone: sage-6.4
Component: linear programming | Resolution:
Keywords: linear constraint, mixed | Merged in:
integer linear program | Reviewers:
Authors: | Work issues:
Report Upstream: N/A | Commit:
Branch: | Stopgaps:
Dependencies: |
-------------------------------------------------+-------------------------
Old description:
> Hello,
>
> I'd like to have sage.numerical.linear_functions.LinearConstraint to be a
> hashable type for the following reasons:
>
> 1) 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.
> 2) 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
New 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:
1) 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.
2) 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
--
Comment (by mkoeppe):
Added example to the description.
--
Ticket URL: <http://trac.sagemath.org/ticket/15583#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.