A program that gurobi 7.0.2 can run, but gurobi 7.5.0 can't.

112 views
Skip to first unread message

Chuanxiong Kang

unread,
Jul 13, 2017, 8:25:15 AM7/13/17
to Gurobi Optimization
I use the gurobi python interface for optimization.
Today I updated gurobi to version 7.5.0, but a program that can previously run thought out an error when using the new gurobi 7.5.0.

I give a simplified python program here.
--------------------------------------------------------

import numpy as np
from gurobipy import *

a = np.array([1, 2, 3])

m = Model()
x = m.addVar()
y = m.addVar()

m.setObjective(x - y)
m.addConstr(a[0] * x + a[0] * y <= 2)
m.addConstr(a[0] * (x + y) <= 2)  # gurobi750 though out an error here, but it is OK to run on gurobi702

m.optimize()

Daniel Espinoza

unread,
Jul 13, 2017, 9:17:02 AM7/13/17
to Gurobi Optimization
Hi,

It has to do with how Python interprets commands and how numpy overwrite common operators.
If you try

m.addCostr((x+y) * a[0] <= 2)

then it will go through. In the first case, numpy product is accepting the linear expression (x+y) as a valid operand and returning a bool, whereas when is multiplied by a variable a[0] * x, numpy does not accept it as a valid operation and so Python tries the reverse x * a[0], where it just works. The difference between 7.0 and 7.5 is that in 7.5 linear expressions, quadratic expressions and columns are iterable objects, which (I guess) allows numpy to carry on with many operations (even thought at the element level they don't make any sense).

So, I guess there is no easy way to get out of this problem (besides changing order of the operations).

Best,
Daniel

Chuanxiong Kang

unread,
Jul 14, 2017, 5:08:49 PM7/14/17
to Gurobi Optimization
Thanks.
As NumPy is the fundamental package for scientific computing in Python, I hope gurobi can give a special guide for gurobi-numpy. If there already exists, please show the link.



在 2017年7月13日星期四 UTC+8下午9:17:02,Daniel Espinoza写道:

Daniel Espinoza

unread,
Jul 17, 2017, 8:55:10 AM7/17/17
to Gurobi Optimization
Dear Chuanxiong,

Indeed, thanks for reporting it, we will resolve this issue very soon.

Best,
Daniel

Michael Winkler

unread,
Jul 19, 2017, 8:21:24 AM7/19/17
to Gurobi Optimization
7.5.1 is out and the issue should be resolved.

Best,
Michael

Reply all
Reply to author
Forward
0 new messages