mdl.addConstrs((t[i,k] * X[i,j,k] - te1[i] <= 5) >> (z1[i,k] == 1) for i,j,k in arcos if i != 0 and i != 23)(t and X and variables). This is not accepted, and the following error message is issued:
AttributeError: 'gurobipy.QuadExpr' object has no attribute 'getVar'
- Indicator constraints have a simple binary variable as condition, not a general (boolean) expression
- Only linear constraints are supported in indicator constraints
Indicator constraints have the form:binary variable == 0 ==> linear constraintorbinary variable == 1 ==> linear constraintYour constraint does not have this form. You need to reformulate it to fit this format, or use a different (big-M) formulation.
Well-formed and meaningful error messages are very important. The user is already confused, otherwise (s)he would formulate a correct constraint. Adding confusing error messages to this confusion is not a good idea. A good error message could have prevented this post. We can think of error messages as the UI (User Interface) when it really matters: when the user needs help. Developers should pay much more attention to this.
A question for another day is of course: why are only linear constraints supported?
References
- AttributeError: 'gurobipy.QuadExpr' object has no attribute 'getVar', https://stackoverflow.com/questions/71153625/attributeerror-gurobipy-quadexpr-object-has-no-attribute-getvar/71158372