sasoptpy.ConstraintGroup.get_expressions¶
-
ConstraintGroup.
get_expressions
(self, rhs=False)[source]¶ Returns constraints as a list of expressions
- Parameters
- rhsboolean, optional
When set to True, passes the the constant part (rhs) of the constraint
- Returns
- df
pandas.DataFrame
Returns a DataFrame that consists of constraints as expressions
- df
Examples
>>> m = so.Model(name='m') >>> var_ind = ['a', 'b', 'c', 'd'] >>> u = m.add_variables(var_ind, name='u') >>> t = m.add_variable(name='t') >>> cg = so.ConstraintGroup((u[i] + 2 * t <= 5 for i in var_ind), name='cg') >>> ce = cg.get_expressions() >>> print(ce) cg a u[a] + 2 * t b u[b] + 2 * t c u[c] + 2 * t d u[d] + 2 * t >>> ce_rhs = cg.get_expressions(rhs=True) >>> print(ce_rhs) cg a u[a] + 2 * t - 5 b u[b] + 2 * t - 5 c u[c] + 2 * t - 5 d u[d] + 2 * t - 5