@PROD Set Looping Function
The @PROD function is used to find the product of an expression across members of a set. As an example, consider the model:
MODEL:
SETS:
COMPONENTS: P;
ENDSETS
DATA:
P = .95 .99 .98;
ENDDATA
P_FAIL = 1 - @PROD( COMPONENTS( I): P( I));
END
Here we have a system of three components arranged in a series. The probability that each component functions successfully (.95, .99, and .98) is loaded into attribute P in the model’s data section. We then compute the probability that the entire system will fail, P_FAIL, by taking the product of the component probabilities and subtracting it from 1:
P_FAIL = 1 - @PROD( COMPONENTS( I): P( I));
As an aside, an interesting feature to note about this model is that we never initialized the COMPONENTS set. When LINGO sees that an attribute of an undefined primitive set being initialized to n values in a data section, it automatically initializes the parent primitive set to contain the members: 1, 2, …, n. So, in this example, LINGO automatically assigned the member 1, 2 and 3 to the COMPONENTS set.