sasoptpy.Model.add_constraint

Model.add_constraint(self, c, name)[source]

Adds a single constraint to the model

Parameters
cConstraint

Constraint to be added to the model

namestring

Name of the constraint

Returns
cConstraint

Reference to the constraint

Examples

>>> x = m.add_variable(name='x', vartype=so.INT, lb=0, ub=5)
>>> y = m.add_variables(3, name='y', vartype=so.CONT, lb=0, ub=10)
>>> c1 = m.add_constraint(x + y[0] >= 3, name='c1')
>>> print(c1)
 x  +  y[0]  >=  3
>>> c2 = m.add_constraint(x - y[2] == [4, 10], name='c2')
>>> print(c2)
 -  y[2]  +  x  =  [4, 10]