Concepts
Features
Reference
Implements a small set of functions equivalent to numpy that operate onthe array-like matrix-friendly API classesMVar,MLinExpr,MQuadExpr,MConstr,MQConstr, andMGenConstr.
Stack arrays in sequence horizontally (column wise). This is equivalentto concatenation along the second axis, except for 1-D arrays where itconcatenates along the first axis.
This method has the same behavior asnumpy.hstack, exceptthat it always returns a gurobipy matrix-friendly API object of theappropriate type.
tup – A sequence of matrix-friendly API objects
Returns a matrix-friendly API object. Note that the return typedepends on the types of the input objects.
X=model.addMVar((k,n))Y=model.addMVar((k,m))XY=gp.hstack((X,Y))# (k, n+m) MVar
Stack arrays in sequence vertically (row wise). This is equivalent toconcatenation along the first axis after 1-D arrays of shape(N,)have been reshaped to(1,N).
This method has the same behavior asnumpy.vstack, exceptthat it always returns a gurobipy matrix-friendly API object of theappropriate type.
tup – A sequence of matrix-friendly API objects
Returns a matrix-friendly API object. Note that the return typedepends on the types of the input objects.
X=model.addMVar((n,k))Y=model.addMVar((m,k))XY=gp.vstack((X,Y))# (n+m, k) MVar
Join a sequence of arrays along an existing axis.
This method has the same behavior asnumpy.concatenate,except that it always returns a gurobipy matrix-friendly API object ofthe appropriate type.
tup – A sequence of matrix-friendly API objects
axis – The axis along which the arrays will be joined. If axis isNone, arrays are flattened before use. Default is 0.
Returns a matrix-friendly API object. Note that the return typedepends on the types of the input objects.
X=model.addMVar((k,n))Y=model.addMVar((k,m))XY=gp.concatenate((X,Y),axis=1)# (k, n+m) MVar
Help and Feedback