Skip to content Skip to sidebar Skip to footer

I There A Way To Specify Two Constraints For The Same Variable When Using Puthon Pulp For A Linear Program

I was wondering if there is a way two have a variable with two different constraints when using Python PuLP. prob += lpSum([evaptwohundredF[i] * component_vars[i] for i in name]) &

Solution 1:

I'm not a big pulp-user, but what you ask for is obviously allowed in Linear-Programming (and therefore in probably all modelling-tools).

The problem in your case: pulp expects a unique identifier / str for each constraint (and your's are equal).

Do something like (only changed the constraint-names):

prob += lpSum([evaptwohundredF[i] * component_vars[i] for i in name]) >= 30.0000, "evaptwohundredFrequirement_a"
prob += lpSum([evaptwohundredF[i] * component_vars[i] for i in name]) <=70.0000, "evaptwohundredFrequirement_b"

Post a Comment for "I There A Way To Specify Two Constraints For The Same Variable When Using Puthon Pulp For A Linear Program"