prod
OPL keyword to compute products.
Purpose
OPL keyword to compute products of a collection of related expressions.
context |
---|
Model files (.mod) |
Syntax
AggregateExpression: "sum" '(' Qualifiers ')' Expression | "min" '(' Qualifiers ')' Expression | "max" '(' Qualifiers ')' Expression | "prod" '(' Qualifiers ')' Expression
Description
Integer
and float expressions can be constructed using aggregate operators
for computing summations (sum
), products
(prod
), minima (min
),
and maxima (max
) of a collection of related
expressions. Behavior on empty sets:
prod(empty set)=1
Example
int n=6;
int factorial=prod(i in 1..n) i;
assert(factorial==720);