Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark mode
Gurobi Optimizer Reference Manual
Light LogoDark Logo

Concepts

Features

Reference

Gurobi
Back to top

Matrix-Friendly API Functions#

Implements a small set of functions equivalent to numpy that operate onthe array-like matrix-friendly API classesMVar,MLinExpr,MQuadExpr,MConstr,MQConstr, andMGenConstr.

hstack(tup)#

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.

Parameters:

tup – A sequence of matrix-friendly API objects

Returns:

Returns a matrix-friendly API object. Note that the return typedepends on the types of the input objects.

Example:
X=model.addMVar((k,n))Y=model.addMVar((k,m))XY=gp.hstack((X,Y))# (k, n+m) MVar
vstack(tup)#

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.

Parameters:

tup – A sequence of matrix-friendly API objects

Returns:

Returns a matrix-friendly API object. Note that the return typedepends on the types of the input objects.

Example:
X=model.addMVar((n,k))Y=model.addMVar((m,k))XY=gp.vstack((X,Y))# (n+m, k) MVar
concatenate(tup,axis)#

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.

Parameters:
  • 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:

Returns a matrix-friendly API object. Note that the return typedepends on the types of the input objects.

Example:
X=model.addMVar((k,n))Y=model.addMVar((k,m))XY=gp.concatenate((X,Y),axis=1)# (k, n+m) MVar

Help and Feedback

On this page

[8]ページ先頭

©2009-2025 Movatter.jp