Soheil MT
Soheil MT

Reputation: 13

Update Param with constraint

i want to define a constraint, which update param when assignment is occur. The constraint is as follow.

Where d is Param and Z is decision variable define as:

model.d = Param(model.V, mutable=True)
model.Z = Var(model.Vs, model.Vc2, within = Binary)

I have tried:

def Cons24_rule(model,i):
    return model.d[i] == sum(model.d[j] * model.Z[i,j] for j in model.Vc2)
model.Cons24 = Constraint(model.Vs , rule = Cons24_rule)

but i get infeasibility error. How Can i able to define this constraint?

Pyomo code and test data can be found here.

Thanks - Soheil

Upvotes: 0

Views: 83

Answers (1)

LarrySnyder610
LarrySnyder610

Reputation: 2397

Your instance is infeasible. Your constraint says:

d[i] = sum {j in V_c2} d[j] * Z[i,j]

for all i. This means the amount shipped out of i must exactly equal its d, and the amount shipped must fully equal the d of the destinations. But for example, d[9] = 6, and there are no other nodes j such that sum {j} d[j] = 6. So, there is no way to satisfy this constraint, i.e., no way to ship exactly 6 units out of node 9.

I suspect that the real problem is in the logic of your constraint formulation, not in your data. I don't think you want to assume that if i ships to j, then it must ship all of d[j]. Either that, or you don't want to require the total shipped out of i to equal d[i] exactly.

Upvotes: 1

Related Questions