6.2 Named Indexes

Named indexes are specified by listing the subscript elements within parenthesis. Each item in the list has a separate name that is then used when referring to the subscripts. This is a convenient way of assigning meaning to indexes and the vectors that use them. Here is an example:

    month := (January,February,March,April,May,June,July,
              August,September,October,November,December) ;

In most cases MPL sends the matrix to the LP solver directly through memory, which means that the names are not used. But sometimes, there is a need to generate an input file either in MPS or the native solver format. Because of the name size of most LP solvers is limited to eight characters, only the first three characters, for each named index, are normally used when building variable and constraints names in MPL. The default number of characters used can be set in the Max Subscript Length option in the MPL Language dialog box in the Options menu. See Chapter 4.9: The Options Menu for more information.

To make sure there are no name conflicts, keep at least the first three characters of the named subscripts distinct. If that is difficult, you can abbreviate the names by using the becomes operator '->'. To use the becomes operator insert the '->' after the subscript list and place another list with shorter version of the names beneath. These abbreviated names are then used instead when generating the input file. Here is an example:

    City :=  (SanDiego, LosAngeles, SanFrancisco)
          -> (SD, LA, SF) ;

It is not always desirable to have the same subscript length for all indexes in the model. Therefore, you can use a different length for each index by following the index definition with a colon and a new length. Here is an example:

    INDEX
        month := (January,February,March,April,May,June) : 4;

This definition sets the subscript length for the month index to 4.

If the index contains numeric values, but you do want them treated as a named index, you can do so by adding the keyword NAMED in front of the INDEX keyword. This is, for example, necessary when you have product numbers that are all numeric, but you do not want them sorted according to their numerical values.


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