TypeError: object of type 'gurobipy.LinExpr' has no len()

541 views
Skip to first unread message

s.sch...@gmail.com

unread,
Mar 26, 2019, 8:07:21 AM3/26/19
to Gurobi Optimization

Hi,
in my optimization code I get the error:

"TypeError: object of type 'gurobipy.LinExpr' has no len()"
I enclosed the full code in the appendix.
Does anyone know a solution to the problem?




Modell4_Prozesskette_Aktenkoffer.py

Robert Luce

unread,
Mar 26, 2019, 9:51:48 AM3/26/19
to Gurobi Optimization
The error message is indeed a bit cryptic, but looking at the line

38: m.addConstrs((e[(p,t)] == max_((s[(p,t-1)] - s[(p,t)]), 0.0) for p in processsteps for t in range(1,T)), name="process_end")

I see that you are trying to feed an LinExpr object s[(p,t-1)] - s[(p,t)] into the max_ function, causing the error.  You can only pass in a list of variables as arguments for the max, see


You could simply define auxiliary variables for each sum  s[(p,t-1)] - s[(p,t)], and use these variables as arguments for the max_ function.

Robert

Sascha Scheef

unread,
Mar 26, 2019, 12:58:04 PM3/26/19
to gur...@googlegroups.com
Thank you very 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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages