I am trying to solve FLP using PuLP. I want to add logical constraint for variable value.
I have LpVariable f and C is list of LpVariables . I want to add f to the constraint of problem and which depends on values of c[i].
Below is code snippet >
prob = LpProblem("The MILP problem", LpMinimize)
Added 1st constraint :
prob += lpSum(c[i] for i in range (len(c))) == 2
Now I want to add following constraint:
if`lpSum(c[i] for i in range (len(c))) > 1:
` prob += f == 1
else:
prob += f == 0
prob += lpSum(c[i] for i in range (len(c)) + f )
Now problem is LpVariables c[i] are initialized with None
and hence it throws error while calculating lpSum()
.
I hope I am clear. Let me know if need any help in understanding this query but I think given code snippet is sufficient enough.