FilteredForeach Operator (Solver Foundation)

Evaluates an expression for each combination of values of some iterator variables where a condition holds, and returns the results.

FilteredForeach[iters…, cond, expr]

Example

Plus[FilteredForeach[{p, Products}, m[p] > 0, x[p]]]
Plus[FilteredForeach[{p, Products}, {s, Sources}, m[p] > 0, x[p, s]]]
Max[FilteredForeach[{i, 5}, i != 3, x[i]]]

The condition may not involve decision variables. FilteredForeach uses the same iterator forms as Foreach. If no iterators are specified, FilteredForeach evaluates the condition. If it is True the result is just expr, if it is False there are no results.

See Also

Concepts

Optimization Modeling Language (OML)