States that the expression f lies in set (see zero() and the other
constraint sets). With over, the constraint is repeated for every element
of one or more index sets, like a constraint written "for all i in S".
add() builds these for you.
Usage
constraint(f, set, over = list())Arguments
- f
The expression node.
- set
The set
fmust lie in:zero(),nonneg()orindicator().- over
A list of
list(idx, set_ref)pairs, each repeating the constraint for every element of the setset_ref(fromir_set_ref()), with the index namedidxstanding for the element inf.list()for a single constraint.
Value
A plain list without a class, with the fields f, set and
over. It is an element of the list a program() takes as
constraints.
Examples
# x <= 4, written as 4 - x >= 0
constraint(ir_apply("-", list(ir_const(4), ir_var("x"))), nonneg())
#> $f
#> $f$kind
#> [1] "apply"
#>
#> $f$op
#> [1] "-"
#>
#> $f$args
#> $f$args[[1]]
#> $f$args[[1]]$kind
#> [1] "const"
#>
#> $f$args[[1]]$value
#> [1] 4
#>
#>
#> $f$args[[2]]
#> $f$args[[2]]$kind
#> [1] "var"
#>
#> $f$args[[2]]$name
#> [1] "x"
#>
#> $f$args[[2]]$index
#> list()
#>
#>
#>
#>
#> $set
#> $set$kind
#> [1] "nonneg"
#>
#>
#> $over
#> list()
#>