Hi,
Sorry for this naive question.
I'd like to optimize a classical linear production model with classical constraints through Python and pyomo
from pyomo.environ import *
model = ConcreteModel()
model.x = Var(domain=NonNegativeReals)
model.y = Var(domain=NonNegativeReals)
model.z = Var(domain=NonNegativeReals)
model.profit = Objective(expr = 40*model.x + 30*model.y + 50*model.z, sense=maximize)
model.demand = Constraint(expr = model.x <= 40)
model.laborA = Constraint(expr = model.x + model.y <= 80)
model.laborB = Constraint(expr = 2*model.x + model.z <= 100)
model.laborC = Constraint(expr = model.z <= 50)
However, the Objective function is sometimes different, depending on the values of 'y' and 'z':
if (model.y > 20):
expr = 40*model.x + 30*model.y + 50*model.z + 200
if (model.z > 30):
expr = 40*model.x + 30*model.y + 60*model.z + 300
I do not know to implement these conditions into my Python code. If I try with the previous lines of code, I get the "Cannot convert non-constant Pyomo expression (20 < y) to bool." error message.
I wondered if someone could give me any tip to implement this. How are called this kind of "non continuous" linear functions (just to Google them)?
Thank you very much in advance.