       MIXED INTEGER LINEAR PROGRAMMING USING GLPK VERSION 2.2
            Supplement to GLPK User's Guide, March 2001

          Andrew Makhorin <mao@mai2.rcnet.ru, mao@gnu.org>



This document is a supplement to GLPK User's Guide. It explains how to
use GNU Linear Programming Kit (GLPK) for solving mixed integer linear
programming (MIP) problems.



1. INTRODUCTION
===============

                                 "God created the integers, all else is
                                 the work of man."
                                          Leopold Kronecker (1823-1891)



Mixed integer linear programming (MIP) problem is a linear programming
problem in which some variables are required to be integer.

GLPK assumes that MIP problem has the same formulation as ordinary LP
problem (see "GLPK User's Guide", Subsection 1.1, formulae (1.1)-(1.3)),
i.e. includes auxiliary and structural variables which may have upper
and/or lower bounds. However, in case of MIP problem some variables may
be required to be integer. This additional constraint means that values
of *integer variables* must be only integer numbers. (Note that GLPK
allows only structural variables to be of integer kind.)

The current version of GLPK includes API routine glp_integer (see its
description in the next section). It is a *tentative* implementation of
the branch-and-bound procedure based on the dual simplex method. This
routine can be used in the same way as API routine glp_simplex (which
solves pure LP problems) and intended for solving MIP problems.

Note that currently GLPK MIP solver uses easy heuristics for branching
and backtracking, and therefore it is not perfect. It is fit for solving
MIP problems which are not very hard and have few integer variables.



2. ADDITIONAL GLPK API ROUTINES
===============================



2.1. glp_set_kind - set kind of the current row/column
------------------------------------------------------

*Synopsis*

#include "glpk.h"
int glp_set_kind(int what, int kind);

*Description*

If what = GLP_ROW, the glp_set_kind routine sets (changes) the kind of
the current row.

If what = GLP_COL, the glp_set_kind routine sets (changes) the kind of
the current column.

The parameter kind specifies the kind of the current row/column which
should be set. GLP_NO means the continuous variable, GLP_YES means the
integer (discrete) variable.

Note that only columns (structural variables) can be of integer kind.
(In the current version of GLPK kinds of auxiliary variables are not
used and reserved for the future.)

*Returns*

0 - no errors;
1 - the current row/column is undefined;
2 - the parameter what is invalid or the parameter kind is invalid or
    kind = GLP_YES is specified for row.



2.2. glp_get_kind - get kind of the current row/column
------------------------------------------------------

*Synopsis*

#include "glpk.h"
int glp_get_kind(int what, int *kind);

*Description*

If what = GLP_ROW, the glp_get_kind routine stores the kind of the
current row to the location which kind points to.

If what = GLP_COL, the glp_get_kind routine stores the kind of the
current column to the location which kind points to.

GLP_NO means that the variable is continuous, GLP_YES means that the
variable is integer (discrete).

*Returns*

0 - no errors;
1 - the current row/column is undefined;
2 - the parameter what is invalid.



2.3. glp_integer - solve MIP problem using branch-and-bound procedure
---------------------------------------------------------------------

*Synopsis*

#include "glpk.h"
int glp_integer(void);

*Description*

The glp_integer is a MIP problem solver based on the branch-and-bound
procedure and the revised dual simplex method.

This routine obtains problem data from the workspace, solves problem,
and stores the computed solution and other relevant information back to
the workspace in order that the application program could use this
information for further processing.

Since many MIP problems may take a long time, the glp_integer routine
reports some visual information about current status of the search. The
information is sent to stdout approximately once per second and has the
following format:

   +nnn: mip = xxx; lp = yyy (aaa; sss)

where nnn is total number of simplex iteration, xxx is a value of the
objective function that corresponds to the best MIP solution (if this
solution has not been found yet, xxx is the text "not found yet"), yyy
is a value of the objective function that corresponds to the initial
relaxed optimal solution (it is not changed during all the optimization
process), aaa is number of subroblems in the active list, sss is number
of subproblems which have been solved yet.

Note that currently this solver uses easy heuristics for branching and
backtracking and therefore it is not perfect. Most probably this solver
fits for MIP problems that have not so many integer variables (several
tens, not more). Of course, hard or very large MIP problems can't be
solved by this routine.

*Control parameters*

The behavior of the glp_integer routine depends on a set of control
parameters which are described in the Section 3 (see below).

If the problem is not very hard, default values of control parameters
fit for most cases, so the user needn't take care of them.

*Returns*

0 - no errors. This means that the solver has successfully finished
    solving the problem (note that, for example, if the problem has no
    integer feasible solution, the solver returns zero code);
1 - it's not possible to start solving the problem due to incorrect
    data. All diagnostics was sent to stderr;
2 - the solver is not able to solve the problem. All diagnostics was
    sent to stderr.



3. ADDITIONAL CONTROL PARAMETERS
================================

mip_branch (type: I, getable: yes, setable: yes, default: GLP_DRTOM)
         Affect on the glp_integer routine. It specifies what branching
         heuristic should be used by the MIP solver:
         GLP_FIRST   - branch on the first integer variable;
         GLP_LAST    - branch on the last integer variable;
         GLP_DRTOM   - branch using heuristic by Driebeck and Tomlin.

mip_btrack (type: I, getable: yes, setable: yes, default: GLP_BESTP)
         Affect on the glp_integer routine. It specifies what backtrack-
         ing heuristic should be used by the MIP solver:
         GLP_FIFO    - backtrack using FIFO heuristic;
         GLP_LIFO    - backtrack using LIFO heuristic;
         GLP_BESTP   - backtrack using the best projection heuristic.

nc_int (type: I, getable: yes, setable: no)
         Reports number of integer structural variables in the problem.

nc_bin (type: I, getable: yes, setable: no)
         Reports number of binary structural variables (i.e. integer
         variables with lower bound is zero and upper bound is one) in
         the problem.

status (type: I, getable: yes, setable: yes, initial: GLP_UNDEF)
         This parameter is set by LP and MIP solvers and reports the
         status of the found basis solution:
         GLP_UNDEF   - solution status is undefined;
         GLP_OPT     - LP solution is optimal;
         GLP_FEAS    - LP solution is feasible;
         GLP_INFEAS  - LP solution is infeasible;
         GLP_NOFEAS  - LP problem has no feasible solution;
         GLP_UNBND   - LP problem has unbounded solution;
         GLP_INTOPT  - MIP solution is integer optimal;
         GLP_INTSOL  - MIP solution is integer feasible;
         GLP_DISINT  - MIP solution is integer infeasible;
         GLP_NOINT   - MIP problem has no integer feasible solution.

tol_int (type: R, getable: yes, setable: yes, default: 1e-7)
         Specifies the absolute tolerance which is used by the MIP
         solver for checking integer feasibility of the current basis
         solution. (It is not recommended to change this parameter
         without detailed understanding its purpose.)

tol_obj (type: R, getable: yes, setable: yes, default: 1e-7)
         Specifies the relative tolerance which is used by the MIP
         solver for comparing values of the objective function. (It is
         not recommended to change this parameter without detailed
         understanding its purpose.)



4. MIP FEATURES OF MPS FORMAT
=============================

This section describes additional features of MPS format which are
related to MIP. For complete description of MPS format see "GLPK User's
Guide", Appendix B.

MPS format provides two ways for introducing integer variables into LP
problem.

The first way which is most general and based on using special marker
cards 'INTORG' and 'INTEND'. These marker cards are placed in COLUMNS
section. The 'INTORG' card indicates the start of a group of integer
variables, the 'INTEND' cards indicates the end of a group. MPS deck
may contain arbitrary number of marker cards.

Marker cards have the same format as data cards.

The fields 1, 4, and 6 are not used and should be empty.

The field 2 should contain name of marker. This name may be arbitrary.

The field 3 should contain the word 'MARKER' (including apostrophes).

The field 5 should contain either the word 'INTORG' (including apostro-
phes) for the marker that begins a group of integer columns, or the word
'INTEND' (including apostrophes) for the marker that ends a group of
integer columns.

The second way is more convenient in some particular cases. It allows
the user to declare integer columns using two additional types of bounds
which are specified in the field 1 of data cards of BOUNDS section:

UI - upper integer. This bound type specifies that the corresponding
     column (whose name is specified in the field 3) is of integer kind.
     In this case upper bound of the corresponding column should be
     specified in the field 4 (as in case of UP bound type).

BV - binary variable. This bound type specifies that the corresponding
     column (whose name is specified in the field 3) is of integer kind,
     its lower bound is equal to zero, and its upper bound is equal to
     one (thus, such variable can have only two values - zero and one).
     In this case a number specified in the field 4 is not used.

Let's consider the following example of MIP problem:

   minimize

      Z = 3 * x1 + 7 * x2 - x3 + x4

   subject to linear constraints

      r1 = 2 * x1 -     x2 +     x3 -     x4
      r2 =     x1 -     x2 - 6 * x3 + 4 * x4
      r3 = 5 * x1 + 3 * x2 +              x4

   and bounds of (auxiliary and structural) variables

      1 <= r1 < +inf    0 <= x1 <= 4 (continuous variable)
      8 <= r2 < +inf    2 <= x2 <= 5 (integer variable)
      5 <= r3 < =inf    0 <= x3 <= 1 (integer variable)
                        3 <= x4 <= 8 (continuous variable)

The corresponding MPS file may look like the following:

NAME          SAMP1
ROWS
 N  Z
 G  R1
 G  R2
 G  R3
COLUMNS
    X1        R1                2.0    R2                 1.0
    X1        R3                5.0    Z                  3.0
    MARK0001  'MARKER'                 'INTORG'
    X2        R1               -1.0    R2                -1.0
    X2        R3                3.0    Z                  7.0
    X3        R1                1.0    R2                -6.0
              Z                -1.0
    MARK0003  'MARKER'                 'INTEND'
    X4        R1               -1.0    R2                 4.0
    X4        R3                1.0    Z                  1.0
RHS
    RHS1      R1                1.0
    RHS1      R2                8.0
    RHS1      R3                5.0
BOUNDS
 UP BND1      X1                4.0
 LO BND1      X2                2.0
 UP BND1      X2                5.0
 UP BND1      X3                1.0
 LO BND1      X4                3.0
 UP BND1      X4                8.0
ENDATA

The same example MIP problem can be coded without markers 'INTORG' and
'INTEND' if we specify bound types 'UI' for x2 and 'BV' for x3:

NAME          SAMP2
ROWS
 N  Z
 G  R1
 G  R2
 G  R3
COLUMNS
    X1        R1                2.0    R2                 1.0
    X1        R3                5.0    Z                  3.0
    X2        R1               -1.0    R2                -1.0
    X2        R3                3.0    Z                  7.0
    X3        R1                1.0    R2                -6.0
              Z                -1.0
    X4        R1               -1.0    R2                 4.0
    X4        R3                1.0    Z                  1.0
RHS
    RHS1      R1                1.0
    RHS1      R2                8.0
    RHS1      R3                5.0
BOUNDS
 UP BND1      X1                4.0
 LO BND1      X2                2.0
 UI BND1      X2                5.0
 BV BND1      X3
 LO BND1      X4                3.0
 UP BND1      X4                8.0
ENDATA

------------------------------------------------------------------------

The GLPK package is a part of the GNU project, released under the aegis
of GNU.

Copyright (C) 2001 Andrew Makhorin, Department for Applied Informatics,
Moscow Aviation Institute, Moscow, Russia. All rights reserved.

Free Software Foundation, Inc., 59 Temple Place -- Suite 330, Boston,
MA 02111, USA.

Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions.
