8.6 Integer and Binary Variables

MPL can handle both integer and binary variables. To define integer variables, use the keyword INTEGER followed by list of the variables that are integer. The integer section can be placed anywhere after the constraints section. The variables can be both plain and vector variables. For more information on decision variables see Chapter 8.1: Declaring Decision Variables.

Binary variables are integer variables that can only have values of zero or one. You define them in the same way as integer variables, using the keyword BINARY instead.

    INTEGER
       Production[month,product] ;
    BINARY
       ShopOpen ;

MPL will direct the solver to use integer and binary variables if they are supported by the solver

Special Ordered Sets of Variables

MPL allows you to define Special Ordered Sets (SOS) of variables in the model. For each set, use one of the keywords SOS1, SOS2, or SOS3, and follow it with a list of the variables that belong to the set. This section can be anywhere after the constraints section. The variables can be either plain or structured. If you need to specify the reference row use the keyword REFERENCE immediately after the SOS keyword.

Examples:

    SOS1
       x1, x2, x3 ;

    SOS2 REFERENCE Capacity;
       Produce[product];

Please check if the solver you are using supports SOS by referencing the solver documentation. MPL will generate the sets for the solver if they are supported, but will otherwise ignore them.

MPL also supports specifying multiple SOS sets for subsets of a vector variable range. This can be very useful when you have a vector variable with multiple indexes, but there is a separate set for each element of one or more of the indexes. The indexes that are used in each set are specified using the SET keyword as shown here below:

Examples:

    SOS1
       s[i]: SET(k: x[i,k]);

This will create a separate SOS set for each i with each set containing the x variables for all the elements of the k index.


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