I am trying to implement a delayed column generation approach in pyomo. However, I cannot find a way to add a variable to a constraint. I can add variables to the objective function, simply by adding to the objective expression, but that does not seem to work with constraints. So my question is "can you add a variable to an existing constraint in pyomo"? To illustrate what I want to do, here is small example (which does not work):
import pyomo.environ as pyomo # Create model and variable model = pyomo.ConcreteModel() model.x = pyomo.Var(within=pyomo.NonNegativeReals) # Create simple initial model model.obj = pyomo.Objective(expr=model.x, sense=pyomo.minimize) model.cst = pyomo.Constraint(expr=model.x >= 2) # Solve the model solver = pyomo.SolverFactory('gurobi') solver.solve(model, tee=True) # Create new variable model.y = pyomo.Var(within=pyomo.NonNegativeReals) # Add a new variable to the objective and to the constraint model.obj.expr += model.y model.cst.body += model.y # This does not work!