Binary variables

Top  Previous  Next

These can take on values of 0 or 1 only.  Binary variables are declared as follows

 

Binary Variable s1(i), t1(k,j), w1(i,k,j) ;

Example:

(basint.gms)

POSITIVE VARIABLE       X1

INTEGER VARIABLE        X2

BINARY VARIABLE         X3

VARIABLE                OBJ

EQUATIONS               OBJF

                        X1X2

                        X1X3;

OBJF..     7*X1-3*X2-10*X3 =E= OBJ;

X1X2..     X1-2*X2 =L=0;

X1X3..     X1-20*X3 =L=0;

option optcr=0.01;

MODEL IPTEST /ALL/;

SOLVE IPTEST USING MIP MAXIMIZING OBJ;

Notes:

The lower bound of zero and upper bound of one restrictions do not need to be added as they are automatically generated.
Often such variables are used in generating logical conditions such as imposing mutual exclusivity, complementarity, or other types of phenomenon as discussed in Chapter 15 of McCarl and Spreen.
Priorities (.prior attributes of variables) can be used to override binary specifications as discussed below.