fast_sum
- titanq.fast_sum(values: Iterable[MathObject]) Expression
ℹ️ This feature is experimental and may change.
Computes the sum of all elements provided. This function is an faster alternative to the traditional sum() operation for vector-based expressions.
Parameters
- values
The VectorExpression or VariableVector whose elements are to be summed.
Returns
- Expression
An Expression representing the sum of the elements in exprVector.
Raises
- ValueError
If the provided input is not of type VectorExpression or VariableVector.
Examples
>>> from titanq import Model, Vtype >>> x = model.add_variable_vector('x', 1000, Vtype.BINARY) >>> y = model.add_variable_vector('y', 1000, Vtype.BINARY) >>> exprA = fastSum(x + (x * y) - 5 * y) >>> exprB = fastSum(x)