Sum over one or more indexing variables.
Details
The syntax is similar to the one used in math. For instance,
\( \sum_{i=1}^n \sum_{j=1}^m {x_{ij} * c_j} \)
would be written as
sum_over(i = 1:n, j = 1:n, x[i,j] * c[j]).
Examples
cost <- c(5, 2, 7)
p <- lp_problem() |>
lp_variable(x[1:2, 1:3]) |>
lp_minimize(sum_over(i = 1:2, j = 1:3, x[i, j] * cost[j]))
p$objective
#> minimize linear function:
#> sum_over(i = 1:2, j = 1:3, x[i, j] * cost[j])
#>