addGenConstrMax:'gurobipy.LinExpr' object has no attribute '__cindex__'
AnsweredI was trying to add a constraint as following:
for i in demand_list:
maxVarsList = [data1.loc[i,j]*x[j] for j in truck_list]
m.addGenConstrMax(sum(z[i,j] for j in truck_list), maxVarsList)
note: x[j] is a binary decision variable, z[i,j] is a decision variable, data1.loc[i,j] is a given variable.
AttributeError: 'gurobipy.LinExpr' object has no attribute '__cindex__'
How to add this max constraint correctly?
-
Dear Yutong,
could you please share a minimal reproducible example of the code which throws the error you mention?
Best regards
Jonasz0 -
Dear Yutong,
On top of providing a minimal reproducible example as noted by Jonasz, please note that the addGenConstrMax method does not accept an expression as its input. You have to provide a single optimization variable as first argument. Thus, you have to introduce an auxiliary variable \(aux\) and add the auxiliary equality constraint \(aux = \sum z_{ij}\), \(aux = \max(\dots)\).
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
2 comments