Sometimes, you do not want to use every element of a given index when expanding vectors. In MPL you can accomplish this by using conditional. This feature allows you to set conditions on the indexes in the index list that are based on current values of the other indexes. The following example explains this better:
SUM(i,j<i: formula)
The above condition defines a double sum over the indexes i and j with the additional condition that it only sums the values where j is less than i, i.e., the lower triangular matrix, excluding the diagonal. The conditions can also contain more complex subscript arithmetic. For example:
constr[i,k=2i+3] : ...
This example generates a constraint for all i and k where k is equal to 2i+3. The other constraints are still generated, but they do not contain any terms and are therefore specified as empty constraints. MPL will not send the empty constraints to the solver.
Please note that conditional indexes are also allowed in the definition part when you are defining data and variable vectors. However, these conditions do not have any effect until the vectors are used in the model formulation. For example, when you define the datavector A[i,j < =i] in the DATA section, the list of numbers that follows must also contain values for the elements where j is greater than i. The condition is not used until the datavector is referred to later in the model.
You can put a condition on every index in vectors, summations, and constraints. Be sure to keep in mind that this powerful tool can easily make the model very complex and, therefore, harder to maintain.