sagemath / sage-numerical-backends-gurobi

Gurobi mixed integer linear programming backend for SageMath - can be installed on top of distributions providing SageMath. See also https://github.com/sagemath/sage-numerical-backends-cplex and https://github.com/sagemath/sage-numerical-backends-coin
GNU General Public License v2.0
7 stars 6 forks source link

installing sage_numerical_backends_gurobi changes output of certain __repr__ #2

Open saliola opened 4 years ago

saliola commented 4 years ago

I noticed this over at https://trac.sagemath.org/ticket/29955, but that ticket is not necessary to expose the problem. Basically, the __repr__ output changes when this package is installed.

First of all, I installed this package via:

sage -i sage_numerical_backends_gurobi

Here is an example that causes the problem:

sage: milp = MixedIntegerLinearProgram()
sage: x = milp.new_variable(binary=True, indices=[0,1])
sage: milp.add_constraint(x[0] + x[1] == 1)
sage: milp.show()
Maximization:

Constraints:
  R0: 1.0 <= x_ + x_ <= 1.0
Variables:
  x_ = x_0 is a boolean variable (min=0.0, max=1.0)
  x_ = x_1 is a boolean variable (min=0.0, max=1.0)

Note that both variables in the Constraints section are called x_ instead of x_0 and x_1.

Without this package I get the following:

sage: milp = MixedIntegerLinearProgram()
sage: x = milp.new_variable(binary=True, indices=[0,1])
sage: milp.add_constraint(x[0] + x[1] == 1)
sage: milp.show()
Maximization:

Constraints:
  1.0 <= x_0 + x_1 <= 1.0
Variables:
  x_0 is a boolean variable (min=0.0, max=1.0)
  x_1 is a boolean variable (min=0.0, max=1.0)

Version number: SageMath version 9.2.beta1, Release Date: 2020-06-13, but I also noticed this on version 9.1.

saliola commented 4 years ago

Note that this also causes problems for the command milp.write_lp, since that file will have the all the variable names x_i replaced with x_.