RoutineBase.addConstrs#
- RoutineBase.addConstrs(name: str, e_str: str, info: str | None = None)[source]#
Add a Constraint to the routine at runtime.
e_strmust use canonical CVXPY syntax — callcp.multiply,cp.sum,cp.poweretc. 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 keepsconstr.vreporting slack-from-zero (negative = respected, positive = violated).- Parameters:
- namestr
Constraint name. The value of
namebecomes 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')