Integer Variables
LINGO gives the user the ability to define two types of integer variables-general and binary. A general integer variable is required to be a whole number. A binary integer variable is further required to be either zero or one. Any model containing one or more integer variables is referred to as an integer programming (IP) model.
In many modeling projects, you will be faced with Yes/No types of decisions. Some examples would include Produce/Don't Produce, Open Plant/Close Plant, Supply Customer I from Plant J/Don't Supply Customer I from Plant J, and Incur a Fixed Cost/Don't Incur a Fixed Cost. Binary variables are the standard method used for modeling these Yes/No decisions.
General integer variables are useful where rounding of fractional solutions is problematic. For instance, suppose you have a model that dictates producing 5,121,787.5 blue crayons in your crayon factory. Whether you round the solution to 5,121,787 or 5,121,788 is inconsequential. On the other hand, suppose your planning model for NASA determines the optimal number of space stations to deploy is 1.5. Because building 0.5 space stations is impossible, you must very carefully consider how to round the results. When whole numbers are required and rounding can make a significant difference, general integer variables are appropriate.
LINGO does not simply round or truncate values to come up with an integer answer. Rounding of a solution will typically lead to either infeasible or suboptimal solutions. To illustrate this point, consider the small model:
MAX = X;
X + Y = 25.5;
X <= Y;
By examining this model, one can deduce the optimal solution is X=Y=12.75. Now, suppose we want an optimal solution with X being integer. Simply rounding X to 13 would make the model infeasible, because there would be no value for Y that would satisfy both the constraints. Clearly, the optimal solution is X=12 and Y=13.5. Unfortunately, "eyeballing" the optimal solution on larger models with many integer variables is virtually impossible.
To solve these problems, LINGO performs a complex algorithm called branch-and-bound that implicitly enumerates all combinations of the integer variables to determine the best feasible answer to an IP model. Because of the extra computation time required by this algorithm, formulating your problem to avoid the use of integer variables is advised whenever possible. Even so, although computation times may grow dramatically when you add integer variables, it often makes sense to ask LINGO for integer solutions when fractional values are of little or no use.