• Gurobi Staff

The min_() helper function can only be used to set one variable equal to a group of variables and/or constants. This would be used if, e.g., you want to add a constraint like $$x = \min\{y, z, 2\}$$, where $$x$$, $$y$$, and $$z$$ are variables.

In your case, the elements of $$\texttt{index}$$ are not variables. Thus, the minimum of $$\texttt{100}$$ and $$\texttt{sum(100 for i in index if i.id == 0)}$$ is a constant value that doesn't depend on any variables. This means you can use Python's built-in $$\texttt{min()}$$ function:

model.addConstr(quicksum(100*schedule[i] for i in index) <= 100 - min(100, sum(100 for i in index if i.id == 0)))

Note that I used Python's built-in $$\texttt{sum()}$$ function instead of Gurobi's quicksum() function. The latter returns a LinExpr object, which won't work well with $$\texttt{min()}$$.

Thank you Eli for your help!