6.8 Multi-dimensional Index Sets

Often, when formulating models with multiple indexes, some of the indexes are connected together. For example, if your model has one index defined as plant, and another index defined as machine, you might want to be able to create an index specifying which machines are available in which plants. This can be done in MPL using multi- dimensional index sets. They are defined in a similar way, such as normal subset indexes, but instead of only a single domain index being placed inside the brackets, you enter a list of domain indexes separated by commas.

    INDEX
       plant      := (Atlanta, Chicago, Dallas);
       machine    := (Grind, Drill, Press);

       PlantMachine[plant,machine] :=

                     (Atlanta.Grind,
                      Chicago.Drill,
                      Chicago.Press,
                      Dallas.Grind);

In the above example we created a two-dimensional index PlantMachine that contains, for each plant, the machines that are available.

When referring to multi-dimensional indexes we sometimes call it the parent index and the indexes it is derived from the domain indexes. When specifying which element pairs to include in the parent index you can, as in the above example, list all the elements you want to include, with each domain index element separated with a period so long as they are not numeric indexes. Alternatively, you can also separate each domain index element with a comma. For clarity, you can also group each parent index element with parentheses.

        PlantMachine[plant,machine] :=

                         ((Atlanta, Grind),
                          (Chicago, Drill),
                          (Chicago, Press),
                          (Dallas,  Grind));

Instead of listing all the elements manually, you can also use the WHERE command to specify which elements are included in the multi-dimensional index. We will now, on the following page, show several examples on how the WHERE command can be used when defining multi-dimensional indexes.

In the example below we want to create an index WinterRepair that contains all the months in the Repair index which are between November and March.

    INDEX
       month := (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);

       Repair[month] := (Jan,Mar,Jun,Oct,Nov);

       WinterRepair[month] :=

          Repair[month] WHERE (month <= Mar) OR (month >= Nov);

    !                      := (Jan, Mar, Nov);

In the next example we first define two indexes node1 and node2 that contains nodes that are in a network and then use the WHERE command to create a two-dimensional index arcs that connects together all the nodes except those that are the same.

    INDEX
       node1 := (n1,n2,n3,n4);
       node2 := node1;

       arcs[node1,node2] WHERE (node1 <> node2);

When defining indexes you can also use the WHERE command to make the index dependent on the values of a datavector. In the example below, we want to create an index that contains the routes between the plants and the warehouses that have shipping costs below 2400.

    INDEX
       plant     := (Atlanta, Chicago, Dallas);
       warehouse := (Pittsburgh, Charlotte, Memphis);
    DATA
       ShipCost[plant, warehouse]  := (1200, 3000, 2300,
                                       1800, 4200, 3300,
                                       2700, 2100, 1900);

    INDEX
       BestRoutes[plant,warehouse] WHERE (ShipCost <= 2400);

     !            := (Atlanta.Pittsburgh, Atlanta.Memphis,
     !                Chicago.Pittsburgh,
     !                Dallas.Charlotte, Dallas.Memphis);

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