RoutineBase.addConstrs#

RoutineBase.addConstrs(name: str, e_str: str, info: str | None = None)[source]#

Add a Constraint to the routine at runtime.

e_str must use canonical CVXPY syntax — call cp.multiply, cp.sum, cp.power etc. directly — and embed the relational operator. Author every term on the left so the suffix is one of ' <= 0', ' == 0', or ' >= 0'. This LHS-zero discipline keeps constr.v reporting slack-from-zero (negative = respected, positive = violated).

Parameters:
namestr

Constraint name. The value of name becomes the symbol name used in expressions; pick a name that does not collide with a CVXPY atom (sum, multiply, vstack, …).

e_strstr

Constraint expression string in canonical CVXPY syntax, with the relational operator embedded.

infostr, optional

Descriptive information

Examples

Append a hard generation cap:

sp.RTED.addConstrs(name='pg_cap',
                   e_str='pg - pmax <= 0')

Force two variables equal:

sp.RTED.addConstrs(name='pg_match',
                   e_str='pg - pset == 0')