MVar.sum()

sum ( axis=None )

Sum the elements of the MVar; returns an MLinExpr object.

Arguments:

axis: An int, or None. Sum along the specified axis. If set to None, summation takes place along all axes of this MVar.

Return value:

An MLinExpr representing the sum.

Example usage:

  x = model.addMVar((2, 2))
  sum_row = x.sum(axis=0)  # Sum along the rows of X
  sum_col = x.sum(axis=1)  # Sum along the columns of X
  sum_all = x.sum()  # Sum all variables in this MVar