Skip to content

A MIPVariable's repr should include some useful information #20331

@mkoeppe

Description

@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

CC: @dimpase @videlec @jdemeyer @yuan-zhou

Component: numerical

Author: Yuan Zhou

Branch/Commit: b2b9b36

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/20331

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions