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:

Status badges


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]
sage: pv[77]
sage: pv[0].dict().keys()
sage: pv[77].dict().keys()

See also: #20461, #20602

Change History (9)

comment:1 Changed 6 years ago by mkoeppe

  • Branch set to u/mkoeppe/mixedintegerlinearprogram__remove__variables_dictionary

comment:2 Changed 6 years ago by mkoeppe

  • Authors set to Matthias Koeppe
  • Cc chapoton added
  • Commit set to b7906ffd31c2007d81cb556d23b8b814d2faaebb
  • Status changed from new to needs_review

New commits:

ca1298bMixedIntegerLinearProgram._linear_variable_index: New
b7906ffMixedIntegerLinearProgram: Remove _variables

comment:3 Changed 5 years ago by tscrim

  • 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 mkoeppe

I haven't done any timings regarding this patch.

comment:5 Changed 16 months ago by mkoeppe

  • Cc yzh added
  • Milestone changed from sage-7.3 to sage-9.4

comment:6 Changed 16 months ago by git

  • Commit changed from b7906ffd31c2007d81cb556d23b8b814d2faaebb to be0e0f0584e9cf78dc10f5a41917e760fc18139e

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

fe2a85fMixedIntegerLinearProgram._linear_variable_index: New
be0e0f0MixedIntegerLinearProgram: Remove _variables

comment:7 Changed 13 months ago by mkoeppe

  • 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 mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:9 Changed 5 months ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.