What's mean "AttributeError: 'int' object has no attribute 'addConstr'"

677 views
Skip to first unread message

Edgar Alan Avila Gomez

unread,
Nov 27, 2016, 8:38:42 AM11/27/16
to Gurobi Optimization
for i in range(len(Cultivos)):
for m in range(len(Temporada)):
for j in range(Hectareas):
m.addConstr(quicksum([x[str(i)+str(j)+str(k)] * Produccion[i][m]] for k in range(Dias_de_Siembra)) >= Demanda[i][m])
.
.
.

AttributeError: 'int' object has no attribute 'addConstr'

Michael Winkler

unread,
Nov 27, 2016, 8:44:57 AM11/27/16
to Gurobi Optimization
You use "m" as index in your second loop, so either you overwrote your model "m" that you want to reference in "m.addConstr()" or you did not use the correct model variable in this call, e.g., is should be "model.addConstr()"?!

Cheers,
Michael

Edgar Alan Avila Gomez

unread,
Nov 27, 2016, 5:05:18 PM11/27/16
to gur...@googlegroups.com
Thanks so much, 

--

---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
ING. Edgar Alan Avila Gomez

Reply all
Reply to author
Forward
0 new messages