Opened 6 years ago
Last modified 5 months ago
#20656 needs_info enhancement
MixedIntegerLinearProgram: Remove _variables dictionary
Reported by: | mkoeppe | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-9.7 |
Component: | numerical | Keywords: | lp |
Cc: | nbruin, dimpase, vdelecroix, jdemeyer, chapoton, yzh | Merged in: | |
Authors: | Matthias Koeppe | Reviewers: | |
Report Upstream: | N/A | Work issues: | |
Branch: | u/mkoeppe/mixedintegerlinearprogram__remove__variables_dictionary (Commits, GitHub, GitLab) | Commit: | be0e0f0584e9cf78dc10f5a41917e760fc18139e |
Dependencies: | #20461, #20462 | Stopgaps: |
Description
The '_variables' attribute dictionary maps a "variable" (an "element" of a MIPVariable
"dictionary") to an index in the backend. This is redundant because these "variables" are elements of type LinearFunction
, and as such know their index in the backend already.
sage: p = MixedIntegerLinearProgram(solver='GLPK') sage: pv = p.new_variable(nonnegative=True) sage: pv[0] x_0 sage: pv[77] x_1 sage: pv[0].dict().keys() [0] sage: pv[77].dict().keys() [1]
Change History (9)
comment:1 Changed 6 years ago by
- Branch set to u/mkoeppe/mixedintegerlinearprogram__remove__variables_dictionary
comment:2 Changed 6 years ago by
- Cc chapoton added
- Commit set to b7906ffd31c2007d81cb556d23b8b814d2faaebb
- Status changed from new to needs_review
comment:3 Changed 5 years ago by
- Status changed from needs_review to needs_info
Needs a rebase. However, I'm worried this could cause a speed regression as a dict
lookup is a system python call whereas you are now doing a number of python function calls. Also storing a (relatively?) small dict
doesn't cost much memory I would think.
comment:4 Changed 5 years ago by
I haven't done any timings regarding this patch.
comment:5 Changed 16 months ago by
- Cc yzh added
- Milestone changed from sage-7.3 to sage-9.4
comment:6 Changed 16 months ago by
- Commit changed from b7906ffd31c2007d81cb556d23b8b814d2faaebb to be0e0f0584e9cf78dc10f5a41917e760fc18139e
comment:7 Changed 13 months ago by
- Milestone changed from sage-9.4 to sage-9.5
Setting a new milestone for this ticket based on a cursory review.
comment:8 Changed 8 months ago by
- Milestone changed from sage-9.5 to sage-9.6
comment:9 Changed 5 months ago by
- Milestone changed from sage-9.6 to sage-9.7
New commits:
MixedIntegerLinearProgram._linear_variable_index: New
MixedIntegerLinearProgram: Remove _variables