GurobiError: Invalid argument to LinExpr addition

1,864 views
Skip to first unread message

Danny

unread,
Aug 14, 2013, 5:36:51 PM8/14/13
to gur...@googlegroups.com
Hi all.,

I can't figure out why I get this error for this code:
"GurobiError: Invalid argument to LinExpr addition"


m.addConstr( yti[t][v] >= quicksum (buv[u,v]*yti[t][u] for u in range(1,n+1) - (Teta[v] - epsilon) ), 'c1_%s_%s' %(v,t) )

''' buv is a two dimensional array created using Numpi, while yti is a two dimensions list '''

While this following code works fine for another constraint:

m.addConstr ( quicksum ( yti[0][i] for i in range(1, n+1) )  <= 3, 'c00')


Jakob Sch.

unread,
Aug 15, 2013, 5:48:57 AM8/15/13
to gur...@googlegroups.com
Hi Danny,

please notice that gurobi has some issues with numpy. Try to convert the entries of the array to a float:

m.addConstr( yti[t][v] >= quicksum (float(buv[u,v])*yti[t][u] for u in range(1,n+1) - (Teta[v] - epsilon) ), 'c1_%s_%s' %(v,t) )

maybe this solves your problem.

Best regards,
Jakob

Danny

unread,
Aug 15, 2013, 10:10:17 AM8/15/13
to gur...@googlegroups.com
Jakob,

Thanks for the comment. The numpy array buv is already float, I used the convert command, it gives the same error after changing the code. 
You are right, it seems that it doesn't like Numpy arrays. I changed the array to a list, it worked fine.

Thanks again
Reply all
Reply to author
Forward
0 new messages