sum

picos.sum(lst, it=None, indices=None)

This is a replacement for Python’s sum that produces sensible string representations when summing PICOS expressions.

Parameters:
  • lst – A list of expressions.
  • it – DEPRECATED
  • indices – DEPRECATED

Example:

>>> import picos
>>> P = picos.Problem()
>>> x = P.add_variable("x", 5)
>>> e = [x[i]*x[i+1] for i in range(len(x) - 1)]
>>> sum(e)
<Quadratic Expression: x[0]·x[1] + x[1]·x[2] + x[2]·x[3] + x[3]·x[4]>
>>> picos.sum(e)
<Quadratic Expression: ∑(x[i]·x[i+1] : i ∈ [0…3])>