9.7 Referring to Indexes in Formulas

Indexes can be used in formulas as any other data element. As in previous versions, all indexes must be accounted for in the underlying index list (sum or constraint specification). Here are two examples to illustrate this:

   DATA
      A[i,j] := DENSE(10*(i-1)+j);

      MAX Z = SUM(i: i*x[i]);

Furthermore, the integer functions FIRST(index), LAST(index), and COUNT(index) are available. They provide the first subscript, the last subscript, and the number of subscripts, respectively, of the given index and can be used both in formulas and in subscript arithmetic.

    INDEX
       i    := 1..10;
       k[i] := i - (first(i), last(i))

    DATA
       A[i] := i;
       B[i] := DENSE(count(i)-i+1);


Back To Top | Maximal Home Page | Table of Contents | Previous Page | Next Page