I have created a contrived example of my problem in an example here. It involves 2 water pipes which lead from a dam to a town. I want only 1 pipe to carry water over each timestamp, t.
I have created a linear optimisation program in Pyomo to determine how best to transfer water down the pipes, but it is failing to work based on one particular constraint – my constraint that only one pipe can transfer water at a time:
model.pipe_output1 = Var(model.T, domain = NonNegativeReals)
model.pipe_output2 = Var(model.T, domain = NonNegativeReals)
def bin_constraint1(model, t):
return model.pipe_output2[t] == model.pipe_output2[t] - model.pipe_output1[t]
model.bin_constraint1 = Constraint(model.T, rule = bin_constraint1)
The output is 0 for both pipes in every timestamp in this model, even though the logic makes complete sense to me. This shouldn’t happen, water should be travelling down 1 pipe and not the other. As a test, I used a friend’s Gurobi solver license, using the constraint below, and it worked!
def bin_constraint1(model, t):
return model.pipe_output2[t] * model.pipe_output1[t] == 0
model.bin_constraint1 = Constraint(model.T, rule = bin_constraint1)
I can’t use this constraint as I don’t personally have a Gurobi license. Is anyone able to help me to understand what I might be doing wrong – why does my logic fall through? Any workaround solutions?