General Integer Example - CompuQuick Product Mix

To illustrate the use of @GIN in a full model, we will consider a variation on the CompuQuick Corporation model in Getting Started with LINGO. CompuQuick has successfully rebalanced the Standard computer's assembly line. In so doing, they are now able to build an additional 3 Standard computers on the line each day, for a daily total of 103 computers. As a result, the constraint on the Standard's assembly line will now be:

STANDARD <= 103;

Incorporating this constraint into the original CompuQuick model, we have:

! Here is the total profit objective function;

MAX = 100 * STANDARD + 150 * TURBO;

 

! Constraints on the production line capacity;

STANDARD <= 103;

TURBO <= 120;

 

! Our labor supply is limited;

STANDARD + 2 * TURBO <= 160;

Solving this modified model, we get the solution:

Global optimal solution found.

Objective value:                        14575.00

Infeasibilities:                        0.000000

Total solver iterations:                       0

Elapsed runtime seconds:                    0.03

 

Model Class:                                  LP

 

Total variables:                      2

Nonlinear variables:                  0

Integer variables:                    0

 

Total constraints:                    4

Nonlinear constraints:                0

 

Total nonzeros:                       6

Nonlinear nonzeros:                   0

 

   Variable           Value        Reduced Cost

   STANDARD        103.0000            0.000000

      TURBO        28.50000            0.000000

 

        Row    Slack or Surplus      Dual Price

          1        14575.00            1.000000

          2        0.000000            25.00000

          3        91.50000            0.000000

          4        0.000000            75.00000

Note that the new optimal number of Turbo computers, 28.5, is no longer an integer quantity. CompuQuick must produce whole numbers of computers each day. To guarantee this, we add @GIN statements to make both the STANDARD and TURBO variables general integer. The revised model follows:

! Here is the total profit objective function;

MAX = 100 * STANDARD + 150 * TURBO;

 

! Constraints on the production line capacity;

STANDARD <= 103;

TURBO <= 120;

 

! Our labor supply is limited;

STANDARD + 2 * TURBO <= 160;

 

! Integer values only;

@GIN( STANDARD); @GIN( TURBO);

Solving the modified model results in the integer solution we were hoping for:

Global optimal solution found.

Objective value:                        14550.00

Objective bound:                        14550.00

Infeasibilities:                        0.000000

Extended solver steps:                         0

Total solver iterations:                       0

Elapsed runtime seconds:                    0.06

 

Model Class:                                PILP

 

Total variables:                      2

Nonlinear variables:                  0

Integer variables:                    2

 

Total constraints:                    4

Nonlinear constraints:                0

 

Total nonzeros:                       6

Nonlinear nonzeros:                   0

 

   Variable           Value        Reduced Cost

   STANDARD        102.0000           -100.0000

      TURBO        29.00000           -150.0000

 

        Row    Slack or Surplus      Dual Price

          1        14550.00            1.000000

          2        1.000000            0.000000

          3        91.00000            0.000000

          4        0.000000            0.000000

 

Note that we now have a two new solution statistics: Extended solver steps and Objective bound.

For models with integer variables, such as this one, the extended solver steps statistic is a tally of the number of times integer variables had to be forced to an integer value during the branch-and-bound solution procedure. In general, this value is not of much practical use to the normal user, other than to give you a notion of how hard LINGO is working at finding an integer solution. If the number of steps gets quite large, LINGO is having a hard time finding good integer solutions to your model.  In this case, given that the model is quite small, LINGO's preprocessor was able to find the optimal solution without having to resort to the branch-and-bound solver.

The objective bound statistic gives us a bound on the best possible solution for the model.  In other words, there is no feasible solution to the model with an objective value better than the objective bound statistic.  Here we see that the bound and the objective value are both equal, which is further evidence that we have a globally optimal solution.  On larger models that take a while to run, you may decide to interrupt LINGO before a global solution is found.  In this case, the objective bound and the objective value will probably not agree.  In this case, the bound will let you know how far you are from the true optimal solution.  You may also find it useful to interrupt the solver once the bound and objective value get close to one another, with the idea being that any further potential gains in the best objective aren't worth the additional solve time.

Also of interest is the Model Class, which has changed from LP (Linear Program) to PILP (Pure Integer Linear Program).