Filter Content By
Version
Languages

addMConstr ( A, x, sense, b, name="" )

Add a set of linear constraints to the model using matrix semantics. The added constraints are (except that the constraint sense is determined by the sense argument). The A argument must be a NumPy dense ndarray or a SciPy sparse matrix.

Note that you will typically use overloaded operators to build and add constraints using matrix semantics. The overloaded @ operator can be used to build a linear matrix expression, which can then be used with an overloaded comparison operator to build a TempConstr object. This can then be passed to addConstr.

Arguments:

A: The constraint matrix - a NumPy 2-D dense ndarray or a SciPy sparse matrix.

x: Decision variables. Argument can be an MVar object, a list of Var objects, or None (None uses all variables in the model). The length of the argument must match the size of the second dimension of A.

sense: Constraint senses, provided as a NumPy 1-D ndarray or as a single character. Valid values are , , or . The length of the array must be equal the size of the first dimension of A. A character will be promoted to an ndarray of the appropriate length.

b: Right-hand side vector, stored as a NumPy 1-D ndarray. The length of the array must be equal the size of the first dimension of A.

name: Names for new constraints. The given name will be subscripted by the index of the constraint in the matrix.

Return value:

MConstr object.

Example usage:

  A = np.full((5, 10), 1)