9.3 Using Variables in Formulas

The decision variables are the elements under control of the model maker and their values determine the solution of the model. Decision variables in MPL are defined as they come in the input file. The name can be of any length. It starts with a letter, with the remainder consisting of letters and digits. MPL is case sensitive by default so you need to be careful to distinguish between upper and lower case letters. If you want MPL not to be case sensitive you can change the default by selecting MPL Language in the Options menu. See Chapter 4.9: The Options Menu for further details.

There are two types of decision variables: plain variables and vector variables (some-times called subscripted variables). A plain variable is setup as a single column in the matrix that is sent to the LP solver. A vector variable, on the other hand, is setup as range of columns in the matrix. The DECISION VARIABLES section is used to define the vector variables. See Chapter 8.1: Declaring Decision Variables for further details.

The most important thing to remember when referring to vector variables is that all the indexes defined for the vector must be accounted for in the domain, either by the constraint specification, the enclosing summation, or the subscript.

Vector variables can be referred in the model in a number of ways. The quickest is to enter the vector without the indexes and let MPL figure it out from the definition. Another way is to write the vector as it was defined, with all the indexes listed, for example Inventory[product,month]. The order of the indexes is actually irrelevant; MPL gets the correct order from the definition.

Sometimes the index of the constraint and the index of the vector may have to differ by some offset, for example, when the inventory for each month depends on the inventory of the previous month. You can enter this by using an offset value, which can be specified as a constant, a datavector or an index. To specify the offset value, the appropriate index is followed by either a plus or minus sign and the slide value. For example:

    Inventory  =  Inventory[month-1] + Production - Sales ;

When generated, the last constraint would look like this:

    Invt1Dec  =  Invt1Nov + Prod1Dec - Sale1Dec ;

In the constraint for the month of December, the November subscript is used for the initial inventory. This method works for any integer offset value, and the relevant index is the only one that must be specified. Entries that fall out of bounds are ignored. For example, the constraint for January would be:

    Invt1Jan  =  Prod1Jan - Sales1Jan ;

Values of index variables can also be fixed or set to a specific value, rather than range over the index domain. Simply use the value in place of the index variable. In that case, the order of the indexes becomes important. As a rule, when a fixed value is used, all indexes should be specified in the same order as when the vector was defined. For example:

    Inventory[1,December]  =  20000 ;

Another way to implement fixed values is to use subindexes in the constraint specification with a range of a single value. For more details see the Chapter 8.4: Specifying Constraints


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