Reputation: 11
I have an optimization problem using Python and Gurobi. In my problem formulation there is the following constraint:
Here, w_it is a decision variable and G_it is a parameter expressed using a dictionary. For example,
Git = {( 't1', 1): 4, ( 't1', 2): 3, ....}
The right side of the constraint is the sum of G_i1, G_i2, ... G_it
con3 = m.addConstrs(wit[i,t] <= gp.quicksum(Git[i,t]) for i in NC for t in time_shifts)
Upvotes: 1
Views: 1472
Reputation: 5653
There are several issues:
w[i,t] >= 0
, so there is no need to write this constraint explicitly.What you need looks like this:
con3 = m.addConstrs(w[i,t] <= gp.quicksum(G[i,tau] for tau in range(1,t+1))
for i in NC
for t in time_shifts)
You may need to adjust the range depending on whether time_shifts counts from 0 or from 1.
Upvotes: 0