I have below code snippet - which is essentially a constraint in my LP problem that I am trying to solve. How can I put this in a single line with a min max range?
prob += lpSum([base[i] * id_vars[i] for i in ID]) >= 33, "P1_34_Min_Base"
prob += lpSum([base[i] * id_vars[i] for i in ID]) <= 37, "P2_37_Max_Base"
essentially what I want to be able to do is:
prob += lpSum([base[i] * id_vars[i] for i in ID]) between 33 and 37, "P1_Base"
any help would be awesome. thanks
personally I think what you got is fine. not sure this will work but you can try
prob += lpSum([base[i] * id_vars[i] for i in ID]) - 33 <= 4
this assumes your vars have a lower bound of 0