Prod

Top  Previous  Next

One might also wish to compute the product of items across a set as follows

 

r=prod(I,y[I]);

r=prod((I,j),y(i)+w(j));

eq5[I]..  zz[I]=e=prod[j,zz[i-1]+zq[j]];

 

Here the product is computed over all of

 

the elements in I for the first equation

the elements in I and j for the second equation

the elements in  j for the third equation

Notes:

The general syntax is prod(settovary,expression) where
the settovary is the name of the sets or sets that will be varied
When more than one set is to be varied they are enclosed in parentheses – prod((i,j),x(i,j)).
an expression is a generally a function of the set in the prod
a ( occurs just after the word prod and matches with a ) at the end of the prod.
In replacement statements only parameters, scalars, and table data may appear.  Variables can only be present if attributes of them are being addressed.
In model equation specification statements all the data items plus variables can appear.
The expression after the comma is fully computed and then applied to the product as if the term were in parentheses.