Opened 6 years ago

Closed 5 months ago

#20331 closed enhancement (fixed)

A MIPVariable's repr should include some useful information

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-9.4
Component: numerical Keywords: lp
Cc: dimpase, vdelecroix, jdemeyer, yzh Merged in:
Authors: Yuan Zhou Reviewers: Matthias Koeppe
Report Upstream: N/A Work issues:
Branch: b2b9b36 (Commits, GitHub, GitLab) Commit: b2b9b366970d9a7aaa25ddfdfab6ef467f412342
Dependencies: Stopgaps:

Status badges

Description (last modified by mkoeppe)

sage: p = MixedIntegerLinearProgram(solver="glpk")
sage: bar = p.new_variable(name="bar")
sage: bar
MIPVariable of dimension 1
sage: bar[0]
x_0
sage: bar
MIPVariable of dimension 1
sage: bar[1]
x_1
sage: bar
MIPVariable of dimension 1
sage: p.solve()
0.0
sage: bar.values()
[x_0, x_1]
sage: p.get_values(bar)
{0: 0.0, 1: 0.0}

I think the print method should instead of "dimension 1" (which apparently means tensor order 1, rather than dimension 1 -- see #17643) print some useful information, such as the name of the variable and the dimension (number of components).

MIPVariable bar with 7 binary components

MIPVariable bar with 5 real components, >= 0, <= 17

Change History (13)

comment:1 Changed 6 years ago by mkoeppe

  • Cc dimpase vdelecroix jdemeyer added

comment:2 Changed 6 years ago by mkoeppe

  • Description modified (diff)

comment:3 Changed 6 years ago by mkoeppe

  • Description modified (diff)

comment:4 Changed 6 years ago by mkoeppe

  • Description modified (diff)
  • Summary changed from MIPVariable misreports its dimension (always 1) to A MIPVariable's repr should include some useful information
  • Type changed from defect to enhancement

comment:5 Changed 6 months ago by mkoeppe

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

comment:6 Changed 6 months ago by mkoeppe

  • Description modified (diff)

comment:7 Changed 5 months ago by mkoeppe

  • Description modified (diff)

comment:8 Changed 5 months ago by yzh

  • Branch set to u/yzh/a_mipvariable_s_repr_should_include_some_useful_information

comment:9 Changed 5 months ago by yzh

  • Authors set to Yuan Zhou
  • Commit set to dbe38b2c6a92cc470de5607d418113c6ef91fbe6
  • Status changed from new to needs_review

New commits:

dbe38b2change MIPVariable's repr to include useful info

comment:10 Changed 5 months ago by mkoeppe

It should be "0 real components" (plural)

comment:11 Changed 5 months ago by git

  • Commit changed from dbe38b2c6a92cc470de5607d418113c6ef91fbe6 to b2b9b366970d9a7aaa25ddfdfab6ef467f412342

Branch pushed to git repo; I updated commit sha1. New commits:

b2b9b36zero is followed by plural countable nouns

comment:12 Changed 5 months ago by mkoeppe

  • Reviewers set to Matthias Koeppe
  • Status changed from needs_review to positive_review

comment:13 Changed 5 months ago by vbraun

  • Branch changed from u/yzh/a_mipvariable_s_repr_should_include_some_useful_information to b2b9b366970d9a7aaa25ddfdfab6ef467f412342
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.