sum_over: Sum over indexes

View source: R/linear-optimization-model-impl.R

sum_overR Documentation

Sum over indexes

Description

This functions helps to create summations over indexes.

Usage

sum_over(.expr, ...)

sum_expr(.expr, ...)

Arguments

.expr

an expression that can be expanded to a sum

...

bind variables in expr using dots. See examples.

Value

the sum over all the indexes

See Also

add_constraint

set_objective

Please note that sum_expr is deprecated when used together with MIPModel.

Examples

if (FALSE) {
  # create a sum from x_1 to x_10
  sum_over(x[i], i = 1:10)
  # create a sum from x_2 to x_10 with even indexes
  sum_over(x[i], i = 1:10, i %% 2 == 0)
  sum_over(x[i, j], i = 1:10, j = 1:i)
}

ompr documentation built on Sept. 9, 2023, 9:06 a.m.