sum_expr: Construct a sum expression

Description Usage Arguments Value See Also Examples

View source: R/helper.R

Description

This functions helps to create dynamic sum expression based on external variables. Should only be used within other 'ompr' functions.

Usage

1
sum_expr(expr, ...)

Arguments

expr

an expression that can be expanded to a sum

...

bind variables in expr using dots. See examples.

Value

the expanded sum as an AST

See Also

add_constraint

set_objective

Examples

1
2
3
4
# create a sum from x_1 to x_10
sum_expr(x[i], i = 1:10)
# create a sum from x_2 to x_10 with even indexes
sum_expr(x[i], i = 1:10, i %% 2 == 0)

dirkschumacher/romp documentation built on Oct. 6, 2018, 4:36 a.m.