Numeric indexes are specified within a range by entering the lowest value and the highest value separated by two periods. Data constants and any legal integer formula, including integer functions, can be used when specifying the numbers. Both numbers must be non-negative and the second must be larger than the first. The following example defines an integer index with three elements:
INDEX product := 1..3 ;
After you have defined an index you can then use it to define data, variable, and constraint vectors. For example, the following example would define a variable vector named Ship that contains three elements:
VARIABLES Ship[product]
This definition will generate three variables (one for each product), named Ship1, Ship2, and Ship3.
The name length of most LP solvers is limited to eight characters. Therefore, only the minimum number of characters are used, for each numeric index, is normally used when building variable and constraints names in MPL.
It is not always desirable to have the default subscript length for all indexes in the model. You can set a different length for each index by following the index definition with a colon and a new length. Here is an example:
INDEX i := 1..5 : 2;
This definition sets the subscript length for the i index to 2.