When you initialize a constraint with a relational expression, Pyomo will break it apart into a LB, UB, and body. Any expression that looks like it might contain variables will be moved into the body (it is
not safe to assume that any constants will be moved to the bounds). The .body attribute on a constructed constraint will point to the body expression, so you can modify it by doing something like “constraint[i].body += c*v”.
However, be sure to watch out for cases where you define constraint expressions like “x <= y”, where both x and y are variables. It’s hard to know if the body will become “x - y” or “y - x”, and unless you are certain what happens, you might be adding variables to the body with the wrong sign.
You can also use the Expression component to accomplish this, but the caveat above still holds. Just make sure to write the constraint expressions in a way where it is obvious what the body will be (i.e., the body of “2 <= x - y” will never be stored as “y - x”).
Gabe