\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename guide
@settitle GLPK 3.0.5 User's Guide
@setchapternewpage odd
@exampleindent 0
@c %**end of header

@ifinfo
Sorry, this document is not intended to be formatted as @samp{info}.
@bye
@end ifinfo

@ifhtml
Sorry, this document is not intended to be formatted as @samp{html}.
@bye
@end ifhtml

@titlepage
@title GLPK
@subtitle GNU Linear Programming Kit
@subtitle Version 3.0.5
@subtitle User's Guide
@subtitle January 2002
@author Andrew Makhorin
@page
@vskip 0pt plus 1filll
The GLPK package is a part of the GNU project, released under the aegis
of GNU.

Copyright @copyright{} 2000, 2001, 2002 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.
@end titlepage

@contents

@chapter Introduction

GLPK (GNU Linear Programming Kit) is a set of routines written in the
ANSI C programming language and organized in the form of a library. It
is intended for solving linear programming (LP), mixed integer linear
programming (MIP), and other related problems.

@section LP Problem

GLPK assumes the following formulation of linear programming (LP)
problem:

@tex
\parindent = 0 in
\leftskip = 1 in
minimize (or maximize)
$$ Z = c_1 x_{m+1} + c_2 x_{m+2} + \dots + c_n x_{m+n} + c_0
\eqno (1.1) $$
subject to linear constraints
$$ x_1 = a_{11} x_{m+1} + a_{12} x_{m+2} + \dots + a_{1n} x_{m+n} $$
$$ x_2 = a_{21} x_{m+1} + a_{22} x_{m+2} + \dots + a_{2n} x_{m+n}
\eqno (1.2)$$
$$ \dots \dots \dots $$
$$ x_m = a_{m1} x_{m+1} + a_{m2} x_{m+2} + \dots + a_{mn} x_{m+n} $$
and bounds of variables
$$ l_1 \leq x_1 \leq u_1 $$
$$ l_2 \leq x_2 \leq u_2 \eqno (1.3) $$
$$ \dots \dots \dots $$
$$ l_{m+n} \leq x_{m+n} \leq u_{m+n} $$
\leftskip = 0 in
where:
$x_1, x_2, \dots, x_m$ --- auxiliary variables (rows);
$x_{m+1}, x_{m+2}, \dots, x_{m+n}$ --- structural variables (columns);
$Z$ --- objective function;
$c_1, c_2, \dots, c_n$ --- coefficients of the objective function;
$c_0$ --- constant term of the objective function;
$a_{11}, a_{12}, \dots, a_{mn}$ --- constraint coefficients;
$l_1, l_2, \dots, l_{m+n}$ --- lower bounds of variables;
$u_1, u_2, \dots, u_{m+n}$ --- upper bounds of variables.
@end tex

Auxiliary variables are called @dfn{rows}, because they correspond to
rows of the constraint matrix (i.e. the matrix formed by constraint
coefficients). Note that the value of an auxiliary variable is the value
of the corresponding linear form. Analogously, structural variables are
called @dfn{columns}, because they correspond to columns of the
constraint matrix.

Bounds of variables can be finite as well as infinite. Besides, a lower
bound can be equal to an upper bound. Thus, the following types of
variables are possible:

@tex
$$\vbox
{
\settabs 3 \columns
\+ \hfil Bounds of variable & Type of variable \cr
\+ \hrulefill & \hrulefill & \cr
\+ \hfil $-\infty < x_k < +\infty$ & Free (unbounded) variable & \cr
\+ \hfil $l_k \leq x_k < +\infty$ & Variable with lower bound & \cr
\+ \hfil $-\infty < x_k \leq u_k$ & Variable with upper bound & \cr
\+ \hfil $l_k \leq x_k \leq u_k$ & Double-bounded variable & \cr
\+ \hfil $l_k = x_k = u_k$ & Fixed variable & \cr
}
$$
@end tex

@noindent
Note that the types of variables shown above are applicable to
structural as well as to auxiliary variables.

To solve LP problem (1.1)---(1.3) is to find such values of all
structural and auxiliary variables which:

a) satisfy to all the linear constraints (1.2), and

b) are within their bounds (1.3), and

c) provide the smallest (in case of minimization) or the largest (in
case of maximization) value of the objective function (1.1).

For solving LP problems GLPK uses well known numerical procedure called
@dfn{the simplex method}. The simplex method performs iterations, where
on each iteration it transforms the original system of linear
constraints (1.3) resolving them through different sets of variables
(the original system is resolved through auxiliary variables). Such
transformed system is called @dfn{the simplex table} (or
@dfn{the tableau}) and has the following form:

@tex
\parindent 0 in
$$ Z = d_1 (x_N)_1 + d_2 (x_N)_2 + \dots + d_n (x_N)_n $$
$$ (x_B)_1 = \alpha_{11} (x_N)_1 + \alpha_{12} (x_N)_2 + \dots +
    \alpha_{1n} (x_N)_n $$
$$ (x_B)_2 = \alpha_{21} (x_N)_1 + \alpha_{22} (x_N)_2 + \dots +
    \alpha_{2n} (x_N)_n \eqno (1.4) $$
$$ \dots \dots \dots $$
$$ (x_B)_m = \alpha_{m1} (x_N)_1 + \alpha_{m2} (x_N)_2 + \dots +
    \alpha_{mn} (x_N)_n \eqno $$
where
$(x_B)_1, (x_B)_2, \dots, (x_B)_m$ --- basic variables;
$(x_N)_1, (x_N)_2, \dots, (x_N)_n$ --- non-basic variables;
$d_1, d_2, \dots, d_n$ --- reduced costs (also called marginal values);
$\alpha_{11}, \alpha_{12}, \dots, \alpha_{mn}$ --- coefficients of the
simplex table.
@end tex

From the linear programming theory it is known that if the optimal
solution of LP problem exists, it can be represented in the form of the
simplex table (1.4), where all non-basic variables are placed on their
bounds, and values of basic variables are defined by equalities of the
corresponding simplex table.

The set of values of all basic variables is called @dfn{basic solution}.
If all basic variables are within their bounds, the solution is called
@dfn{feasible basic solution}, otherwise the solution is called
@dfn{infeasible basic solution}. The feasible basic solution, which
provides the smallest (in case of minimization) or the largest (in case
of maximization) value of the objective function, is called @dfn{optimal
(basic) solution}. Thus, for solving LP problem the simplex method tries
to find its optimal basic solution.

Feasibility of some basic solution may be determined by simple checking
whether all basic variables are within their bounds. Basic solution is
optimal if the following @dfn{optimality conditions} are satisfied for
all non-basic variables:

@tex
$$\vbox
{
\settabs 4 \columns
\+ \hfil Status of $(x_N)_j$ & \hfil Minimization & \hfil Maximization
& \cr
\+ \hrulefill & \hrulefill & \hrulefill & \cr
\+ \hfil $(x_N)_j$ is free variable & \hfil $d_j = 0$ & \hfil $d_j = 0$
& \cr
\+ \hfil $(x_N)_j$ is on its lower bound & \hfil $d_j \geq 0$ &
    \hfil $d_j \leq 0$ & \cr
\+ \hfil $(x_N)_j$ is on its upper bound & \hfil $d_h \leq 0$ &
    \hfil $d_j \geq 0$ & \cr
}
$$
@end tex

@noindent
In other words, the solution is optimal if there is no non-basic
variable, which changing in the feasible direction (i.e. increasing if
it is free or on its lower bound, or decreasing if it is free or on its
upper bound), can improve (i.e. decreasing in case of minimization or
increase in case of maximization) the objective function.

It may happen that some LP problem has no feasible solutions due to
incorrect formulation. This means that its constraints conflict with
each other. It also may happen that some LP problem has unbounded
solution again due to incorrect formulation. This means that some
non-basic variable can improve the objective function (i.e. the
optimality conditions (1.6) are violated) and at the same time this
variable can be infinitely changed in its feasible direction meeting
no resistance from the basic variables.

@section MIP Problem

@dfn{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
(pure) LP problem (see (1.1)---(1.3), Section 1.1), 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
@emph{integer variables} must be only integer numbers. (Note that GLPK
allows only structural variables to be of integer kind.)

@section Brief Example

In order to understand what GLPK is from the user's standpoint, consider
the following example of LP problem:

@tex
\parindent = 0 in
\leftskip = 1 in
maximize
$$ Z = 10 x_1 + 6 x_2 + 4 x_3 $$
subject to
$$ x_1 + x_2 + x_3 \leq 100 $$
$$ 10 x_1 + 4 x_2 + 5 x_3 \leq 600 $$
$$ 2 x_1 + 2 x_2 + 6 x_3 \leq 300 $$
and all variables are non-negative
$$ x_1 \geq 0, x_2 \geq 0, x_3 \geq 0 $$
@end tex

At first, this LP problem should be transformed to the standard form
(1.1)---(1.3). It is easy to do that introducing auxiliary variables, by
one for each original linear constraint. Thus, the considered LP problem
can be rewritten as follows:

@tex
\parindent = 0 in
\leftskip = 1 in
maximize
$$ Z = 10 x_1 + 6 x_2 + 4 x_3 $$
subject to linear constraints
$$ p = x_1 + x_2 + x_3 $$
$$ q = 10 x_1 + 4 x_2 + 5 x_3 $$
$$ r = 2 x_1 + 2 x_2 + 6 x_3 $$
and bounds of variables
$$\vbox
{
\settabs 3 \columns
\+ \hfil $-\infty < p \leq 100$ & \hfil $0 \leq x_1 < +\infty$ & \cr
\+ \hfil $-\infty < q \leq 600$  & \hfil $0 \leq x_2 < +\infty$ & \cr
\+ \hfil $-\infty < r \leq 300$  & \hfil $0 \leq x_3 < +\infty$ & \cr
}
$$
where $p, q, r$ are auxiliary variables; $x_1, x_2, x_3$ are structural
(original) variables.
@end tex

The C program shown below uses GLPK API routines in order to solve this
example LP problem.

@sp 1
@example
/* sample.c */

#include <stdio.h>
#include <stdlib.h>
#include "glpk.h"

int main(void)
@{     LPI *lp;
      double Z, x1, x2, x3;

s1:   lp = glp_create_prob("sample");

s2:   glp_new_col(lp, "x1"), glp_set_obj_coef(lp, 1, 10.0);
s3:   glp_new_col(lp, "x2"), glp_set_obj_coef(lp, 2, 6.0);
s4:   glp_new_col(lp, "x3"), glp_set_obj_coef(lp, 3, 4.0);

s5:   glp_new_row(lp, "p");
s6:   glp_set_row_bnds(lp, 1, 'U', 0.0, 100.0);
s7:   glp_new_aij(lp, 1, 1, 1.0);
s8:   glp_new_aij(lp, 1, 2, 1.0);
s9:   glp_new_aij(lp, 1, 3, 1.0);

s10:  glp_new_row(lp, "q");
s11:  glp_set_row_bnds(lp, 2, 'U', 0.0, 600.0);
s12:  glp_new_aij(lp, 2, 1, 10.0);
s13:  glp_new_aij(lp, 2, 2, 4.0);
s14:  glp_new_aij(lp, 2, 3, 5.0);

s15:  glp_new_row(lp, "r");
s16:  glp_set_row_bnds(lp, 3, 'U', 0.0, 300.0);
s17:  glp_new_aij(lp, 3, 1, 2.0);
s18:  glp_new_aij(lp, 3, 2, 2.0);
s19:  glp_new_aij(lp, 3, 3, 6.0);

s20:  glp_set_obj_sense(lp, '+');

s21:  glp_simplex2(lp, NULL);

s22:  Z = glp_get_obj_val(lp);
s23:  glp_get_col_soln(lp, 1, NULL, &x1, NULL);
s24:  glp_get_col_soln(lp, 2, NULL, &x2, NULL);
s25:  glp_get_col_soln(lp, 3, NULL, &x3, NULL);

s26:  printf("\nZ = %g; x1 = %g; x2 = %g; x3 = %g\n", Z, x1, x2, x3);

s27:  glp_delete_prob(lp);

      return 0;
@}

/* eof */
@end example
@sp 1

The statement @code{s1} creates the linear problem instance using the
routine @code{glp_create_prob}. The character string passed to this
routine is a symbolic name assigned to the problem.

The statement @code{s2} creates the first structural variable (column)
named @samp{x1} and sets the corresponding coefficient of the objective
function. Being created a column initially is non-negative, so in this
case no additional actions are needed. The statements @code{s3} and
@code{s4} are used in the same way to create the second column named
@samp{x2} and the third column named @samp{x3}. Note that in order to
refer to some column its sequential number is used (like the second
parameter passed to the routine @code{glp_set_obj_coef}). Sequential
numbers are assigned to columns by the routine @code{glp_new_col}, which
always adds a new column to the end of the column list. Thus, in this
case the column @samp{x1} has the number 1, the column @samp{x2} has the
number 2, and the column @samp{x3} has the number 3.

The statement @code{s5} creates the first auxiliary variable (row) named
@samp{p}. The statement @code{s6} sets type and bounds of the row
@samp{p}, where @samp{U} means that the corresponding auxiliary variable
has an upper bound, but no lower bound. The statements @code{s7},
@code{s8}, and @code{s9} create constraint coefficients for the first
row at the variables with sequential numbers 1, 2, and 3, respectively.
The statements @code{s10}---@code{s14} are used in the same to create
the second row named @samp{q}, and the statements
@code{s15}---@code{s19} are used to create the third row named @samp{r}.
As in the case of columns all rows have sequential numbers that, which
are assigned by the routine @code{glp_new_row}. This routine always adds
a new row to the end of the row list, thus in this case the rows
@samp{p}, @samp{q}, and @samp{r} have the numbers 1, 2, and 3,
respectively.

The statement @code{s20} sets the optimization sense. It calls the
routine @code{glp_set_obj_sense}, where the code @samp{+} means
maximization.

At this point all data have been entered to the problem object,
therefore the statement @code{s21} calls the routine
@code{glp_simplex2}, which performs searching for optimal solution of
the problem using the revised simplex method and stores the found
solution and other relevant information back to the problem object.

The statement @code{s22} obtains the computed value of the objective
function found by the solver. The statements @code{s23}, @code{s24}, and
@code{s25} obtain computed values of the structural variables @samp{x1},
@samp{x2}, and @samp{x3}, respectively.

The statement @code{s26} prints the found optimal solution to the
standard output. The corresponding printout may look like the following:

@sp 1
@example
Z = 733.333; x1 = 33.3333; x2 = 66.6667; x3 = 0
@end example
@sp 1

Finally the statement @code{s27} calls the routine
@code{glp_delete_prob}, which frees all the memory allocated to the
problem object.

@chapter API Routines

This chapter describes all GLPK API routines (except solver routines,
which are carried out to the next chapter) in the alphabetical order.

@subsubheading Error handling

If some GLPK API routine detects erroneous or incorrect data passed by
the application program, it sends an appropriate diagnostic message to
@code{stdout} and abnormally terminates the application program via
@code{abort} function. In most practical cases this allows to simplify
programming. Thus, in order to prevent crashing the application program
should check all data, which are suspected to be incorrect, before
calling GLPK API routines.

Should note that this kind of error handling is used only in the cases
of incorrect data passed by the application program. If, for instance,
the application program calls some GLPK API routine to read data from an
input file and these data are incorrect, the GLPK API routine reports
about error by means of return code.

@subsubheading Thread safety

GLPK routines are not re-enterant and therefore cannot be used in
multi-threaded programs.

@subsubheading Time complexity

Description of some routines include so called @dfn{time complexity}.
This characteristic shows how the time of an operation depends on the
size of particular data in the problem object participating in the
operation. For example, the routine @code{glp_set_col_name}, which
assigns a symbolic name to a column, has time complexity
@i{O}(log@i{n}), where @i{n} is current number of named columns in the
problem object. This means that if the operation takes @i{t} time units
in case of @i{n} columns, it will take 10@i{t} time units in case of
1000@i{n} columns, i.e. increasing number of rows in 1000 times involves
increasing the time of operation approx. in 10 times, because @tex
$\log 1000 \approx 10$
@end tex
(the base of logarithm is not essential). The time complexity @i{O}(1)
means that an operation takes the constant time, i.e. the operation time
doesn't depend on the current size of data in the problem object.
Knowing the time complexity of GLPK routines the user can estimate this
characteristic for its own routines which are based on GLPK routines.

@subsubheading Scaling the problem

Scaling the problem means replacing the constraint matrix @i{A} of the
original problem by a new, scaled constraint matrix
@tex
$A' = RAS$,
@end tex
where @math{R} and @math{S} are diagonal scaling matrices. Diagonal
elements of the matrix @math{R} are called @i{row scale factors},
diagonal elements of the matrix @math{S} are called @i{column scale
factors}. As a rule good scaling involves improving numerical properties
of the problem.

By default the solver routines automatically perform scaling before
solving the problem. However, the user can scale the problem explicitly
using API routines described in this chapter.

Note that changing scale factors by the scaling routines doesn't affect
on numerical values of problem components (i.e. bounds of variables as
well as objective and constraint coefficients are not chaged) -- scale
factors are applied to the problem only for a time of its processing by
the solver. (See also the Section 1.8 Scaling LP problem in the document
"GLPK: Implementation of the revised simplex method".)

@section @code{glp_check_data} --- turn on/off data consistency check
@fnindex glp_check_data

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_check_data(LPI *lp, int check);
@end example

@subsubheading Description

If the parameter @code{check} is non-zero, the routine
@code{glp_check_data} turn on the data consistency checking flag, in
which case some other API routines perform additional checking data
entered into the problem object. If the parameter @code{check} is zero,
the routine turn the flag off.

@section @code{glp_check_name} --- check symbolic name for correctness
@fnindex glp_check_name

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_check_name(char *name);
@end example

@subsubheading Description

The routine @code{glp_check_name} checks the given symbolic @code{name}
for correctness.

A symbolic name is considered as correct, if it contains 1 up to 255
graphic characters.

@subsubheading Returns

If the given symbolic name is correct, the routine returns zero.
Otherwise the routine returns non-zero.

@section @code{glp_clear_mat_cols} --- clear columns of constraint matrix
@fnindex glp_clear_mat_cols

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_clear_mat_cols(LPI *lp, int flag[]);
@end example

@subsubheading Description

The routine @code{glp_clear_mat_cols} deletes all elements from the
specified columns of the constraint matrix.

The array @code{flag} should have at least @math{1+n} locations, where
@math{n} is number of columns in the problem object. The location
@code{flag[0]} is not used. If @code{flag[j]} is non-zero, the routine
deletes all elements (i.e. constraint coefficients) from the @math{j}-th
column. Otherwise, if @code{flag[j]} is zero, the @math{j}-th column is
not changed.

@subsubheading Complexity

The time complexity is @math{O(nz)}, where @math{nz} is total number of
(non-zero) elements in the constraint matrix.

@section @code{glp_clear_mat_rows} --- clear rows of constraint matrix
@fnindex glp_clear_mat_rows

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_clear_mat_rows(LPI *lp, int flag[]);
@end example

@subsubheading Description

The routine @code{glp_clear_mat_rows} deletes all elements from the
specified rows of the constraint matrix.

The array @code{flag} should have at least @math{1+m} locations, where
@math{m} is number of rows in the problem object. The location
@code{flag[0]} is not used. If @code{flag[i]} is non-zero, the routine
deletes all elements (i.e. constraint coefficients) from the @math{i}-th
row. Otherwise, if @code{flag[i]} is zero, the @math{i}-th row is not
changed.

@subsubheading Complexity

The time complexity is @math{O(nz)}, where @math{nz} is total number of
(non-zero) elements in the constraint matrix.

@section @code{glp_create_prob} --- create problem instance
@fnindex glp_create_prob

@subsubheading Synopsis

@example
#include "glpk.h"
LPI *glp_create_prob(char *name);
@end example

@subsubheading Description

The routine @code{glp_create_prob} creates and initializes a new problem
instance, which is "empty", i.e. has no rows and no columns.

The parameter @code{name} specifies a symbolic name, which is to be
assigned to the new problem. If this parameter is @code{NULL}, no name
is assigned.

@subsubheading Returns

The routine returns a pointer to the created problem object.

@section @code{glp_delete_cols} --- delete columns from problem instance
@fnindex glp_delete_cols

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_delete_cols(LPI *lp, int flag[]);
@end example

@subsubheading Description

The routine @code{glp_delete_cols} deletes the specified columns from
the problem instance.

The array @code{flag} should have at least @math{1+n} locations, where
@math{n} is number of columns in the problem object. The location
@code{flag[0]} is not used. If @code{flag[j]} is non-zero, the routine
deletes the @math{j}-th column. Otherwise, if @code{flag[j]} is zero,
the @math{j}-th column is kept.

Note that deleting some columns involves renumbering (i.e. changing
sequential numbers) the columns that are kept in the problem instance.
For example, if before deleting the problem has five columns
@math{a, b, c, d, e} with sequential numbers 1, 2, 3, 4, 5,
respectively, and the columns @math{a} and @math{d} have been deleted,
after the operation the columns @math{b, c, e} will have new sequential
numbers 1, 2, 3, respectively.

@subsubheading Complexity

The time complexity is @math{O(nz)}, where @math{nz} is total number of
(non-zero) elements in the constraint matrix before the operation.

@section @code{glp_delete_prob} --- delete problem instance
@fnindex glp_delete_prob

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_delete_prob(LPI *lp);
@end example

@subsubheading Description

The routine @code{glp_delete_prob} deletes the problem instance, which
the parameter @code{lp} points to, freeing all the memory allocated to
this program object.

@section @code{glp_delete_rows} --- delete rows from problem instance
@fnindex glp_delete_rows

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_delete_rows(LPI *lp, int flag[]);
@end example

@subsubheading Description

The routine @code{glp_delete_rows} deletes the specified rows from the
problem instance.

The array @code{flag} should have at least @math{1+m} locations, where
@math{m} is number of rows in the problem object. The location
@code{flag[0]} is not used. If @code{flag[i]} is non-zero, the routine
deletes the @math{i}-th row. Otherwise, if @code{flag[i]} is zero, the
@math{i}-th row is kept.

Note that deleting some rows involves renumbering (i.e. changing
sequential numbers) the rows that are kept in the problem instance. For
example, if before deleting the problem has five rows
@math{a, b, c, d, e} with sequential numbers 1, 2, 3, 4, 5,
respectively, and the rows @math{a} and @math{d} have been deleted,
after the operation the rows @math{b, c, e} will have new sequential
numbers 1, 2, 3, respectively.

@subsubheading Complexity

The time complexity is @math{O(nz)}, where @math{nz} is total number of
(non-zero) elements in the constraint matrix before the operation.

@section @code{glp_find_col} --- find column by symbolic name
@fnindex glp_find_col

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_find_col(LPI *lp, char *name);
@end example

@subsubheading Description

The routine @code{glp_find_col} finds a column (structural variable)
that has the given symbolic @code{name}.

@subsubheading Complexity

The time complexity is @math{O(@log{}n')}, where @math{n'} is number of
named columns in the problem object.

@subsubheading Returns

If a column with the given symbolic name has been found, the routine
returns its sequential number. Otherwise the routine returns zero.

@section @code{glp_find_row} --- find row by symbolic name
@fnindex glp_find_row

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_find_row(LPI *lp, char *name);
@end example

@subsubheading Description

The routine @code{glp_find_row} finds a row (auxiliary variable) that
has the given symbolic @code{name}.

@subsubheading Complexity

The time complexity is @math{O(@log{}m')}, where @math{m'} is number of
named rows in the problem object.

@subsubheading Returns

If a row with the given symbolic name has been found, the routine
returns its sequential number. Otherwise the routine returns zero.

@section @code{glp_get_bstat} --- determine basis status
@fnindex glp_get_bstat

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_bstat(LPI *lp);
@end example

@subsubheading Returns

The routine @code{glp_get_bstat} reports the current status of the
basis, which can be one of the following:

@table @samp
@item ?
basis is undefined;
@item N
basis is neither primal nor dual feasible;
@item P
basis is primal feasible, but dual infeasible;
@item D
basis is primal infeasible, but dual feasible;
@item O
basis is primal and dual feasible (optimal).
@end table

@section @code{glp_get_col_bnds} --- determine column bounds
@fnindex glp_get_col_bnds

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_get_col_bnds(LPI *lp, int j, int *type, double *lb, double *ub);
@end example

@subsubheading Description

The routine @code{glp_get_col_bnds} stores the type, lower bound, and
upper bound of the @code{j}-th column (structural variable) to
locations, which the parameters @code{type}, @code{lb}, and @code{ub}
point to, respectively.

If some of the parameters @code{type}, @code{lb}, or @code{ub} is
@code{NULL}, the corresponding value is not stored.

Types and bounds reported by the routine are the following:

@tex
$$\vbox
{
\settabs 4 \columns
\+ \hfil Type & \hfil Bounds & Description & \cr
\+ \hrulefill & \hrulefill & \hrulefill & \cr
\+ \hfil {\tt 'F'} & \hfil $-\infty < x < +\infty$
& Free (unbounded) variable & \cr
\+ \hfil {\tt 'L'} & \hfil $lb \leq x < +\infty$
& Variable with lower bound & \cr
\+ \hfil {\tt 'U'} & \hfil $-\infty < x \leq ub$
& Variable with upper bound & \cr
\+ \hfil {\tt 'D'} & \hfil $lb \leq x \leq ub$
& Double-bounded variable & \cr
\+ \hfil {\tt 'S'} & \hfil $lb = x = ub$ & Fixed variable & \cr
}
$$
@end tex

@noindent
where @i{x} is a structural variable that corresponds to the @math{j}-th
column.

If the column has no lower bound, @code{(*lb)} is set to zero. If the
column has no upper bound, @code{(*ub)} is set to zero. If the column is
of fixed type, @code{(*lb)} and @code{(*ub)} are set to the same value.

@section @code{glp_get_col_coef} --- get column of constraint matrix
@fnindex glp_get_col_coef

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_col_coef(LPI *lp, int j, int rn[], double aj[]);
@end example

@subsubheading Description

The routine @code{glp_get_col_coef} scans elements of the @code{j}-th
column of the constraint matrix and stores their row indices and values
to locations @code{rn[1]}, @code{rn[2]}, @dots{}, @code{rn[nz']} and
@code{aj[1]}, @code{aj[2]}, @dots{}, @code{aj[nz']} respectively, where
@math{0 @leq{} nz' @leq{} m} is number of (non-zero) elements in the
@math{j}-th column, @math{m} is number of rows in the problem instance.
(Note that the order of stored elements may be arbitrary.)

@subsubheading Returns

The routine returns @math{nz'}, which is number of stored elements.

@section @code{glp_get_col_fctr} --- determine column scale factor
@fnindex glp_get_col_fctr

@subsubheading Synopsis

@example
#include "glpk.h"
double glp_get_col_fctr(LPI *lp, int j);
@end example

@subsubheading Returns

The routine @code{glp_get_col_fctr} returns a scale factor assigned to
the @code{j}-th column.

@section @code{glp_get_col_kind} --- determine column kind
@fnindex glp_get_col_kind

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_col_kind(LPI *lp, int j);
@end example

@subsubheading Returns

The routine @code{glp_get_col_kind} returns the kind of a structural
variable that corresponds to the @code{j}-th column of the problem
instance:

@table @samp
@item C
continuous variable;
@item I
integer variable.
@end table

@section @code{glp_get_col_name} --- obtain column name
@fnindex glp_get_col_name

@subsubheading Synopsis

@example
#include "glpk.h"
char *glp_get_col_name(LPI *lp, int j);
@end example

@subsubheading Returns

The routine @code{get_col_name} returns a pointer to a static buffer
that contains symbolic name of the @code{j}-th column (structural
variable). However, if the @math{j}-th column has no assigned name, the
routine returns @code{NULL}.

@section @code{glp_get_col_soln} --- obtain column solution information
@fnindex glp_get_col_soln

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_get_col_soln(LPI *lp, int j, int *tagx, double *valx, double *dx);
@end example

@subsubheading Description

The routine @code{glp_get_col_soln} stores the status, primal value, and
dual value (Lagrange multiplier) of the @code{j}-th column (structural
variable) to locations, which the parameters @code{tagx}, @code{valx},
and @code{dx} point to, respectively.

If some of the pointers @code{tagx}, @code{valx}, or @code{dx} is
@code{NULL}, the corresponding value is not stored.

The status code has the following meaning:

@table @samp
@item B
basic variable;
@item L
non-basic variable on its lower bound;
@item U
non-basic variable on its upper bound;
@item F
non-basic free (unbounded) variable;
@item S
non-basic fixed variable.
@end table

Should note that if the routine @code{glp_get_bstat} reports that the
basis is undefined, the status code is not applicable. Analogously, if
the routine @code{glp_get_status} reports that the solution is
undefined, the primal and dual values are meaningless.

@section @code{glp_get_num_bin} --- determine number of binary columns
@fnindex glp_get_num_bin

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_num_bin(LPI *lp);
@end example

@subsubheading Returns

The routine @code{glp_get_num_bin} returns number of binary columns in
the problem instance, i.e. number of structural variables that are
marked as integer and have zero lower bound and unity upper bound.

@section @code{glp_get_num_cols} --- determine number of columns
@fnindex glp_get_num_cols

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_num_cols(LPI *lp);
@end example

@subsubheading Returns
The routine @code{glp_get_num_cols} returns total number of columns
(structural variables) in the problem instance.

@section @code{glp_get_num_int} --- determine number of integer columns
@fnindex glp_get_num_int

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_num_int(LPI *lp);
@end example

@subsubheading Returns

The routine @code{glp_get_num_int} returns number of integer columns in
the problem instance, i.e. number of structural variables that are
marked as integer.

@section @code{glp_get_num_nz} --- determine number of constraint coefficients
@fnindex glp_get_num_nz

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_num_nz(LPI *lp);
@end example

@subsubheading Returns

The routine @code{glp_get_num_nz} returns number of constraint
coefficients in the problem instance, i.e. number of (non-zero) elements
of the constraint matrix.

@section @code{glp_get_num_rows} --- determine number of rows
@fnindex glp_get_num_rows

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_num_rows(LPI *lp);
@end example

@subsubheading Returns

The routine @code{glp_get_num_rows} returns total number of rows
(auxiliary variables) in the problem instance.

@section @code{glp_get_obj_coef} --- determine objective function coefficient
@fnindex glp_get_obj_coef

@subsubheading Synopsis

@example
#include "glpk.h"
double glp_get_obj_coef(LPI *lp, int j);
@end example

@subsubheading Returns

The routine @code{glp_get_obj_coef} returns a coefficient of the
objective function at the @code{j}-th column (structural variable).

If the parameter @code{j} is zero, the routine returns the constant term
of the objective function.

@section @code{glp_get_obj_sense} --- determine objective function sense
@fnindex glp_get_obj_sense

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_obj_sense(LPI *lp);
@end example

@subsubheading Returns

The routine @code{glp_get_obj_sense} returns the sense of the objective
function for the specified problem instance:

@table @samp
@item -
problem is minimization;
@item +
problem is maximization.
@end table

@section @code{glp_get_obj_val} --- obtain objective function value
@fnindex glp_get_obj_val

@subsubheading Synopsis

@example
#include "glpk.h"
double glp_get_obj_val(LPI *lp);
@end example

@subsubheading Returns

The routine @code{glp_get_obj_val} returns the computed value of the
objective function for the specified problem instance. Should note that
if the routine @code{glp_get_status} reports that the solution is
undefined, the returned value is meaningless.

@section @code{glp_get_prob_name} --- obtain problem name
@fnindex glp_get_prob_name

@subsubheading Synopsis

@example
#include "glpk.h"
char *glp_get_prob_name(LPI *lp);
@end example

@subsubheading Returns

The routine @code{glp_get_prob_name} returns a pointer to a static
buffer that contains a symbolic name of the problem instance. However,
if the problem instance has no assigned name, the routine returns
@code{NULL}.

@section @code{glp_get_row_bnds} --- determine row bounds
@fnindex glp_get_row_bnds

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_get_row_bnds(LPI *lp, int i, int *type, double *lb, double *ub);
@end example

@subsubheading Description

The routine @code{glp_get_row_bnds} stores the type, lower bound, and
upper bound of the @code{i}-th row (auxiliary variable) to locations,
which the parameters @code{type}, @code{lb}, and @code{ub} point to,
respectively.

If some of the parameters @code{type}, @code{lb}, or @code{ub} is
@code{NULL}, the corresponding value is not stored.

Types and bounds reported by the routine are the following:

@tex
$$\vbox
{
\settabs 4 \columns
\+ \hfil Type & \hfil Bounds & Description & \cr
\+ \hrulefill & \hrulefill & \hrulefill & \cr
\+ \hfil {\tt 'F'} & \hfil $-\infty < x < +\infty$
& Free (unbounded) variable & \cr
\+ \hfil {\tt 'L'} & \hfil $lb \leq x < +\infty$
& Variable with lower bound & \cr
\+ \hfil {\tt 'U'} & \hfil $-\infty < x \leq ub$
& Variable with upper bound & \cr
\+ \hfil {\tt 'D'} & \hfil $lb \leq x \leq ub$
& Double-bounded variable & \cr
\+ \hfil {\tt 'S'} & \hfil $lb = x = ub$ & Fixed variable & \cr
}
$$
@end tex

@noindent
where @i{x} is an auxiliary variable that corresponds to the @math{i}-th
row.

If the row has no lower bound, @code{(*lb)} is set to zero. If the row
has no upper bound, @code{(*ub)} is set to zero. If the row is an
equality constraint (i.e. the auxiliary variable is of fixed type),
@code{(*lb)} and @code{(*ub)} are set to the same value. (Note that the
order of stored elements may be arbitrary.)

@section @code{glp_get_row_coef} --- get row of constraint matrix
@fnindex glp_get_row_coef

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_row_coef(LPI *lp, int i, int cn[], double ai[]);
@end example

@subsubheading Description

The routine @code{glp_get_row_coef} scans elements of the @code{i}-th
row of the constraint matrix and stores their column indices and values
to locations @code{cn[1]}, @code{cn[2]}, @dots{}, @code{cn[nz']} and
@code{ai[1]}, @code{ai[2]}, @dots{}, @code{ai[nz']} respectively, where
@math{0 @leq{} nz' @leq{} n} is number of (non-zero) elements in the
@math{i}-th row, @math{n} is number of columns in the problem instance.

@subsubheading Returns

The routine returns @math{nz'}, which is number of stored elements.

@section @code{glp_get_row_fctr} --- determine row scale factor
@fnindex glp_get_row_fctr

@subsubheading Synopsis

@example
#include "glpk.h"
double glp_get_row_fctr(LPI *lp, int i);
@end example

@subsubheading Returns

The routine @code{glp_get_row_fctr} returns a scale factor assigned to
the @code{i}-th row.

@section @code{glp_get_row_name} --- obtain row name
@fnindex glp_get_row_name

@subsubheading Synopsis

@example
#include "glpk.h"
char *glp_get_row_name(LPI *lp, int i);
@end example

@subsubheading Returns

The routine @code{get_row_name} returns a pointer to a static buffer
that contains symbolic name of the @code{i}-th row (auxiliary variable).
However, if the @math{i}-th row has no assigned name, the routine
returns @code{NULL}.

@section @code{glp_get_row_soln} --- obtain row solution information
@fnindex glp_get_row_soln

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_get_row_soln(LPI *lp, int i, int *tagx, double *valx, double *dx);
@end example

@subsubheading Description

The routine @code{glp_get_row_soln} stores the status, primal value, and
dual value (Lagrange multiplier) of the @code{i}-th row (auxiliary
variable) to locations, which the parameters @code{tagx}, @code{valx},
and @code{dx} point to, respectively.

If some of the pointers @code{tagx}, @code{valx}, or @code{dx} is
@code{NULL}, the corresponding value is not stored.

The status code has the following meaning:

@table @samp
@item B
basic variable;
@item L
non-basic variable on its lower bound;
@item U
non-basic variable on its upper bound;
@item F
non-basic free (unbounded) variable;
@item S
non-basic fixed variable.
@end table

Should note that if the routine @code{glp_get_bstat} reports that the
basis is undefined, the status code is not applicable. Analogously, if
the routine @code{glp_get_status} reports that the solution is
undefined, the primal and dual values are meaningless.

@section @code{glp_get_status} --- determine solution status
@fnindex glp_get_status

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_get_status(LPI *lp);
@end example

@subsubheading Returns

The routine @code{glp_get_status} returns one of the following codes
that shows the current status of the problem solution:

@table @code
@item GLP_UNDEF
solution is undefined;
@item GLP_OPT
solution is optimal;
@item GLP_FEAS
solution is feasible;
@item GLP_INFEAS
solution is infeasible;
@item GLP_NOFEAS
problem has no feasible solution;
@item GLP_UNBND
problem has unbounded solution;
@item GLP_INTOPT
solution is integer optimal;
@item GLP_INTSOL
solution is integer feasible;
@item GLP_DISINT
solution is integer infeasible;
@item GLP_NOINT
problem has no integer solution.
@end table

@section @code{glp_new_aij} --- create new constraint coefficient
@fnindex glp_new_aij

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_new_aij(LPI *lp, int i, int j, double aij);
@end example

@subsubheading Description

The routine @code{glp_new_aij} creates a new constraint coefficient,
which is placed in the @code{i}-th row and the @code{j}-th column and
has the numeric value @code{aij}.

Although constraint coefficients may be created in an arbitrary order,
multiplets (i.e. coefficients with identical row and column indices) are
not allowed. Note that the routine @code{glp_new_aij} checks for
multiplets only if the data consistency checking flag is turned on (see
the routine @code{glp_check_data}).

The application program needn't to specify zero coefficients, because if
a coefficient is not specified, it is considered as zero.

@subsubheading Complexity

If the data consistency checking flag is off, the time complexity is
@math{O(1)}. Otherwise the time complexity is @math{O(nz')}, where
@math{nz'} is number of existing non-zero elements in the @math{j}-th
column.

@section @code{glp_new_col} --- create new column
@fnindex glp_new_col

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_new_col(LPI *lp, char *name);
@end example

@subsubheading Description

The routine @code{glp_new_col} creates a new column (structural
variable) and adds it to the end of the column list (thus, sequential
numbers of existing columns are not changed). Initially the new column
is empty, corresponds to a continuous non-negative variable, and has
zero coefficient in the objective function.

The parameter @code{name} specifies a symbolic name, which is to be
assigned to the new column. If this parameter is @code{NULL}, no name is
assigned.

@subsubheading Complexity

If the parameter @code{name} is not @code{NULL}, the time complexity is
@math{O(nz')}, where @math{nz'} is number of named columns in the column
list. Otherwise the time complexity is @math{O(1)}.

@section @code{glp_new_row} --- create new row
@fnindex glp_new_row

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_new_row(LPI *lp, char *name);
@end example

@subsubheading Description

The routine @code{glp_new_row} creates a new row (auxiliary variable)
and adds it to the end of the row list (thus, sequential numbers of
existing rows are not changed). Initially the new row is empty and
corresponds to an equality constraint with zero right-hand side.

The parameter @code{name} specifies a symbolic name, which is to be
assigned to the new row. If this parameter is @code{NULL}, no name is
assigned.

@subsubheading Complexity

If the parameter @code{name} is not @code{NULL}, the time complexity is
@math{O(nz')}, where @math{nz'} is number of named rows in the row list.
Otherwise the time complexity is @math{O(1)}.

@section @code{glp_print_soln} --- write problem solution in printable format
@fnindex glp_print_soln

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_print_soln(LPI *lp, char *fname);
@end example

@subsubheading Description

The routine @code{glp_print_soln} writes the problem solution associated
with the given problem instance, to an output text file, whose name is
the character string fname.

Information reported by this routine is intended mainly for the visual
analysis and has the meaning only if the problem has been successfully
solved.

The output format used by the @code{glp_print_soln} routine is described
in Appendix C.

@subsubheading Returns

If no errors occured, the routine returns zero. Otherwise the routine
sends all diagnostics to @code{stdout} and returns non-zero.

@section @code{glp_put_col_soln} --- store column solution information
@fnindex glp_put_col_soln

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_put_col_soln(LPI *lp, int j, int tagx, double valx, double dx);
@end example

@subsubheading Description

The routine @code{glp_put_col_soln} stores solution information for
@code{j}-th column (structural variable) to the specified problem
object.

The parameters @code{tagx}, @code{valx}, and @code{dx} specify status,
primal value, and dual value (Lagrange multiplier), respectively.

This routine is intended mainly for using by solvers.

@section @code{glp_put_row_soln} --- store row solution information
@fnindex glp_put_row_soln

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_put_row_soln(LPI *lp, int i, int tagx, double valx, double dx);
@end example

@subsubheading Description

The routine @code{glp_put_row_soln} stores solution information for
@code{i}-th row (structural variable) to the specified problem object.

The parameters @code{tagx}, @code{valx}, and @code{dx} specify status,
primal value, and dual value (Lagrange multiplier), respectively.

This routine is intended mainly for using by solvers.

@section @code{glp_put_soln_info} --- store main solution information
@fnindex glp_put_soln_info

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_put_soln_info(LPI *lp, int bstat, int status, double objv);
@end example

@subsubheading Description

The routine @code{glp_put_soln_info} stores main solution information to
the specified problem object.

The parameters @code{bstat}, @code{status}, and @code{objv} specify
basis status, solution status, and value of the objective function,
respectively.

This routine is intended mainly for using by solvers.

@section @code{glp_read_lpm1} --- read LP model written in GLPK/L
@fnindex glp_read_lpm1

@subsubheading Synopsis

@example
#include "glpk.h"
LPI *glp_read_lpm1(char *infile, char *outfile);
@end example

@subsubheading Description

The routine @code{glp_read_lpm1} reads an LP model written in the
modeling language GLPK/L from an input text file, whose name is the
character string @code{infile}.

If the parameter @code{outfile} is not @code{NULL}, the routine
additionally writes the LP/MIP problem generated by the language
processor to an output text file, whose name is the corresponding
character string.

GLPK/L modeling language is a part of the GLPK package. It is described
in the document "Modeling Language GLPK/L". The routine
@code{glp_read_lpm} is an interface to the language processor, a program
that analyzes model description statements and translates them into
internal data structures.

@subsubheading Returns

If no errors occured, the routine returns a pointer to the created
problem instance. Otherwise the routine sends all diagnostics to
@code{stdout} and returns @code{NULL}.

@section @code{glp_read_mps1} --- read problem data using MPS format
@fnindex glp_read_mps1

@subsubheading Synopsis

@example
#include "glpk.h"
LPI *glp_read_mps1(char *fname);
@end example

@subsubheading Description

The @code{glp_read_mps1} routine reads LP problem data using MPS format
from an input text file, whose name is the character string
@code{fname}.

The MPS format is described in Appendix A.

@subsubheading Returns

If no errors occured, the routine returns a pointer to the created
problem instance. Otherwise the routine sends all diagnostics to
@code{stdout} and returns @code{NULL}.

@section @code{glp_scale_prob} --- scale problem
@fnindex glp_scale_prob

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_scale_prob(LPI *lp, int how);
@end example

@subsubheading Description

The routine @code{glp_scale_prob} performs scaling the problem data
depending on the parameter @code{how}:

@table @asis
@item 0
equilibration scaling;
@item 1
geometric mean scaling;
@item 2
geometric mean scaling, then equilibration scaling.
@end table

In order to scale the problem the routine uses current coefficients of
the constrint matrix.

A result of this operation are row and column scale factors, which are
stored by the routine into the problem object.

@section @code{glp_set_col_bnds} --- set (change) column bounds
@fnindex glp_set_col_bnds

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_col_bnds(LPI *lp, int j, int type, double lb, double ub);
@end example

@subsubheading Description

The routine @code{glp_set_col_bnds} sets (changes) the type and bounds
of the @code{j}-th column (structural variable).

Parameters @code{type}, @code{lb}, and @code{ub} specify respectively
the type, lower bound, and upper bound as follows:

@tex
$$\vbox
{
\settabs 4 \columns
\+ \hfil Type & \hfil Bounds & Description & \cr
\+ \hrulefill & \hrulefill & \hrulefill & \cr
\+ \hfil {\tt 'F'} & \hfil $-\infty < x < +\infty$
& Free (unbounded) variable & \cr
\+ \hfil {\tt 'L'} & \hfil $lb \leq x < +\infty$
& Variable with lower bound & \cr
\+ \hfil {\tt 'U'} & \hfil $-\infty < x \leq ub$
& Variable with upper bound & \cr
\+ \hfil {\tt 'D'} & \hfil $lb \leq x \leq ub$
& Double-bounded variable & \cr
\+ \hfil {\tt 'S'} & \hfil $lb = x = ub$ & Fixed variable & \cr
}
$$
@end tex

@noindent
where @i{x} is a structural variable that corresponds to the @math{j}-th
column.

If the column has no lower bound, the parameter @code{lb} is ignored.
If the column has no upper bound, the parameter @code{ub} is ignored.
If the column is of fixed type, the parameter @code{lb} is used, but the
parameter @code{ub} is ignored.

@section @code{glp_set_col_fctr} --- set column scale factor
@fnindex glp_set_col_fctr

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_col_fctr(LPI *lp, int j, double fctr);
@end example

@subsubheading Description

The routine @code{glp_set_col_fctr} sets (changes) the scale factor of
the @code{j}-th column specified by the parameter @code{fctr} (should be
positive).

Column scale factor is an optional quantity, which may be used by the
solver in order to scale the problem.

@section @code{glp_set_col_kind} --- set (change) column kind
@fnindex glp_set_col_kind

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_col_kind(LPI *lp, int j, int kind);
@end example

@subsubheading Description

The routine @code{glp_set_col_kind} sets (changes) the kind of a
structural variable that corresponds to the @code{j}-th column of the
specified problem instance.

The parameter @code{kind} specifies the kind as follows:

@table @samp
@item C
continuous variable;
@item I
integer variable.
@end table

@section @code{glp_set_col_name} --- assign (change) column name
@fnindex glp_set_col_name

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_col_name(LPI *lp, int j, char *name);
@end example

@subsubheading Description

The routine @code{glp_set_col_name} assignes the given symbolic
@code{name} to the @code{j}-th column (structural variable) of the
specified problem instance.

If the parameter @code{name} is @code{NULL}, the routine just erases an
existing name of the @math{j}-th column.

@subsubheading Complexity

The time complexity is @math{O(@log{}n')}, where @math{n'} is number of
named columns in the problem object.

@section @code{glp_set_obj_coef} --- set (change) objective function coefficient
@fnindex glp_set_obj_coef

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_obj_coef(LPI *lp, int j, double coef);
@end example

@subsubheading Description

The routine @code{glp_set_col_name} sets (changes) a coefficient of the
objective function at a structural variable that corresponds to the
@code{j}-th column.

If the parameter @code{j} is zero, the routine sets (changes) the
constant term of the objective function.

@section @code{glp_set_obj_sense} --- set (change) objective function sense
@fnindex glp_set_obj_sense

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_obj_sense(LPI *lp, int sense);
@end example

@subsubheading Description

The routine @code{glp_set_obj_sense} sets (changes) the sense of the
objective function for the specified problem instance.

The parameter @code{sense} specifies the sense as follows:

@table @samp
@item -
problem is minimization;
@item +
problem is maximization.
@end table

@section @code{glp_set_prob_name} --- assign (change) problem name
@fnindex glp_set_prob_name

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_prob_name(LPI *lp, char *name);
@end example

@subsubheading Description

The routine @code{glp_set_prob_name} assigns the given symbolic
@code{name} to the specified problem instance.

If the parameter @code{name} is @code{NULL}, the routine just erases an
existing name of the problem instance.

@section @code{glp_set_row_bnds} --- set (change) row bounds
@fnindex glp_set_row_bnds

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_row_bnds(LPI *lp, int i, int type, double lb, double ub);
@end example

@subsubheading Description

The routine @code{glp_set_row_bnds} sets (changes) the type and bounds
of the @code{i}-th row (auxiliary variable).

Parameters @code{type}, @code{lb}, and @code{ub} specify respectively
the type, lower bound, and upper bound as follows:

@tex
$$\vbox
{
\settabs 4 \columns
\+ \hfil Type & \hfil Bounds & Description & \cr
\+ \hrulefill & \hrulefill & \hrulefill & \cr
\+ \hfil {\tt 'F'} & \hfil $-\infty < x < +\infty$
& Free (unbounded) variable & \cr
\+ \hfil {\tt 'L'} & \hfil $lb \leq x < +\infty$
& Variable with lower bound & \cr
\+ \hfil {\tt 'U'} & \hfil $-\infty < x \leq ub$
& Variable with upper bound & \cr
\+ \hfil {\tt 'D'} & \hfil $lb \leq x \leq ub$
& Double-bounded variable & \cr
\+ \hfil {\tt 'S'} & \hfil $lb = x = ub$ & Fixed variable & \cr
}
$$
@end tex

@noindent
where @i{x} is an auxiliary variable that corresponds to the @math{i}-th
row.

If the row has no lower bound, the parameter @code{lb} is ignored. If
the row has no upper bound, the parameter @code{ub} is ignored. If the
row is an equality constraint (i.e. the corresponding auxiliary variable
is of fixed type), the parameter @code{lb} is used, but the parameter
@code{ub} is ignored.

@section @code{glp_set_row_fctr} --- set row scale factor
@fnindex glp_set_row_fctr

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_row_fctr(LPI *lp, int i, double fctr);
@end example

@subsubheading Description

The routine @code{glp_set_row_fctr} sets (changes) the scale factor of
the @code{i}-th row specified by the parameter @code{fctr} (should be
positive).

Row scale factor is an optional quantity, which may be used by the
solver in order to scale the problem.

@section @code{glp_set_row_name} --- assign (change) row name
@fnindex glp_set_row_name

@subsubheading Synopsis

@example
#include "glpk.h"
void glp_set_row_name(LPI *lp, int i, char *name);
@end example

@subsubheading Description

The routine @code{glp_set_row_name} assigns the given symbolic
@code{name} to the @code{i}-th row (auxiliary variable) of the specified
problem instance.

If the parameter @code{name} is @code{NULL}, the routine just erases an
existing name of the @math{i}-th row.

@subsubheading Complexity

The time complexity is @math{O(@log{}m')}, where @math{m'} is number of
named rows in the problem object.

@section @code{glp_write_mps} --- write problem data in MPS format
@fnindex glp_write_mps

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_write_mps(LPI *lp, char *fname, struct wmps *parm);
@end example

@subsubheading Description

The routine @code{glp_write_mps} writes LP problem data using MPS format
to the output text file whose name is the character string @code{fname}.

The parameter @code{parm} is a pointer to the parameter block used by
the routine. It is allowed to specify @code{NULL}, in which case
standard values are used by default. If the parameter block is used,
before a call to the routine @code{glp_write_mps} the block should be
initialized by means of the statement @code{glp_init_wmps(parm)}, and
the the application program can change some of the control parameters.
Description of the control parameters used by the routine is given
below.

For description of MPS format see the Appendix A.

@subsubheading Returns

@table @asis
@item 0
no errors;
@item 1
invalid control parameters;
@item 2
operation failed due to errors.
@end table

In case of non-zero return code the routine sends all diagnostics to
stdout.

@subsubheading Control parameters

The behavior of the routine @code{glp_write_mps} depends on the
following control parameters, which are members of the structure
@code{wmps}, pointer to which is passed to the routine. (Initializers
means standard values set by default):

@table @code
@item int prob_info = 1;
If this flag is set, the routine writes several comment cards that
contains some information about the problem. Otherwise the routine
writes no comment cards.
@item int make_obj = 2;
This parameter controls output objective function row:
   @table @code
   @item 0
   never output objective function row;
   @item 1
   always output objective function row;
   @item 2
   output objective function row if and only if the problem has no free
   rows.
   @end table
@item int use_names = 1;
If this flag is set, the routine tries to generate standard 8-char MPS
names using orifinal row and column names as templates. Otherwise the
routine generates plain names using sequential numbers of rows and
columns.
@item int one_entry = 0;
If this flag is set, the routine keeps fields 5 and 6 empty. Otherwise
the routine uses all fields.
@item int pedantic = 0;
If this flag is set, the routine never omits column and vector names.
Otherwise the routine omits these names every time when possible.
@item int skip_empty = 0;
If this flag is set, the routine writes all columns, including empty
ones (which have no constraint coefficients). Otherwise the routine
writes only non-empty columns.
@end table

@chapter Solver Routines

@section @code{glp_call_rsm1} --- solve LP problem using simplex method
@fnindex glp_call_rsm1

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_call_rsm1(LPI *lp, struct rsm1 *parm);
@end example

@subsubheading Description

The routine @code{glp_call_rsm1} is an interface to an LP problem solver
based on two-phase revised simplex method.

This routine obtains problem data from the problem object, which the
parameter @code{lp} points to, calls the solver to solve the problem,
and stores the computed solution back to the problem object.

The parameter @code{parm} is a pointer to the parameter block used by
the solver. It is allowed to specify @code{NULL}, in which case standard
values are used by default. If the problem is not very hard, standard
default values fit for most cases. If the parameter block is used,
before a call to the routine @code{glp_call_rsm1} the block should be
initialized by means of the statement @code{glp_init_rsm1(parm)}, and
then the application program can change some of control parameters.
Detailed description of control parameters used by the solver is given
below.

Generally, the simplex solver performs the following actions:

preparing internal data structures;

searching for feasible basis solution (phase I);

searching for optimal basis solution (phase II);

storing the obtained solution to the problem object.

Since large scale problems may take a long time, the solver reports some
information about the current status of the searching. This information
is sent to stdout approximately once per second and has the following
format:

@example
   *nnn:   objval = xxx   infsum = yyy (ddd)
@end example

@noindent
where @samp{nnn} is iteration number, @samp{xxx} is the current value of
the objective function (which is unscaled and has correct sign),
@samp{yyy} is the current value of sum of infeasibilities (which is
scaled, therefore may be used only for visual estimating), @samp{ddd} is
the current number of basis fixed variables. If the asterisk @samp{*}
precedes to @samp{nnn}, the solver is searching for optimal solution
(i.e. the feasible solution has been found yet), otherwise the solver is
searching for some feasible solution.

Note that the simplex solver is not perfect. Although it has been
successfully tested on a wide set of LP problems, there are hard
problems @footnote{Hard problem is not the same as large scale problem.
@emph{Large scale problem} is just a problem which has many (for
example, several thousands) rows and columns. If the computer has
enough memory and appropriate processing unit, many large scale problems
can be successfully solved by the simplex solver. @emph{Hard problem} is
a "pathological" problem which has some unusual properties the makes it
very hard to be solved by the simplex method.} which can't be solved by
this solver.

@subsubheading Returns

The routine @code{glp_call_rsm1} returns one of the following codes:

@table @asis
@item 0
no errors. This code means that the solver has successfully finished
solving the problem (note that, for example, if the problem has
no feasible solution, the returned code will be zero).
@item 1
iteration limit exceeded. In this case the solver reports the recently
obtained basis solution.
@item 2
numerical problems with basis matrix. This case means that the solver is
not able to solve the problem.
@end table

@subsubheading Control parameters

The behavior of the simplex solver depends on the following control
parameters, which are members of the structure @code{rsm1}, pointer to
which may be passed to the routine @code{glp_call_rsm1}. (Initializers
mean standard values of the controls parameters used by default.)

@table @code
@item int what = 2;
specifies what solution should be found by the solver:
    @table @code
    @item 0
    only initial solution;
    @item 1
    any feasible solution;
    @item 2
    optimal solution.
    @end table
@item int form = 1;
specifies what form of the basis matrix should be used by the solver:
    @table @code
    @item 0
    PFI (Product Form of the Inverse);
    @item 1
    RFI (Reid's Form of the Inverse) with updating technique proposed by
    Bartels and Golub;
    @item 2
    RFI (Reid's Form of the Inverse) with updating technique proposed by
    Forrest and Tomlin.
    @end table
@item int scale = 1;
if this flag is set, the solver performs automatic scaling of the
problem. Otherwise scaling is not used.
@item int dual = 0;
if this flag is set, the solver uses the dual simplex method on the
phase I in order to find a primal feasible basis solution. Otherwise the
solver uses the primal simplex method.
@item int steep = 1;
if this flag is set, the solver uses the steepest edge pricing technique
(for both primal and dual simplex) proposed by Goldfarb and Reid.
Otherwise the solver uses the "textbook" pricing.
@item int relax = 1;
if this flag is set, the solver uses the advanced two-pass ratio test
(for both primal and dual simplex0 proposed by P. Harris. Otherwise the
solver uses the "textbook" ratio test.
@item double tol_bnd = 1e-8;
specifies the relative tolerance which is used by the solver for
checking primal feasibility of the current basis solution. It is not
recommended to change this parameter without detailed understanding its
purpose.
@item double tol_dj = 1e-7;
specifies the relative tolerance which is used by the solver for
checking dual feasibility of the current basis solution. It is not
recommended to change this parameter without detailed understanding its
purpose.
@item double tol_piv = 1e-10;
specifies the relative tolerance which is used by the solver for
pivoting. It is not recommended to change this parameter without
detailed understanding its purpose.
@item int iter_max = 0;
maximal allowed number of simplex iterations (0 means no limit).
@item int round = 1;
if this flag is set, the solver replaces computed values of the basic
variables, which are close to zero, by exact zeros (such rounding is
performed after the final basis solution has been obtained). Otherwise
the solver keeps values of all basic variables "as is".
@end table

@section @code{glp_call_ipm1} --- solve LP problem using interior point method
@fnindex glp_call_ipm1

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_call_ipm1(LPI *lp);
@end example

@subsubheading Description

The routine @code{glp_call_ipm1} is an interface to an LP problem solver
based on the primal-dual interior point method.

This routine obtains problem data from the problem object, which the
parameter @code{lp} points to, calls the solver to solve the problem,
and stores the computed solution back to the problem object.

The interior point method is more modern and more powerful numerical
method for large scale linear programming. It is especially fits for
very sparse LP problems and allows solving such problems much faster
than the revised simplex method.

So far as large scale LP problems may take a long time, therefore the
interior point solver displays information about every interior point
iteration @footnote{Unlike the simplex method the interior point method
usually needs about 30---50 iterations (independently on the size of LP
problem) in order to find the final point.}. This information is sent to
@code{stdout} and has the following format:

@example
   nnn: F = xxx; rpi = ppp; rdi = ddd; gap = ggg
@end example

@noindent
where @code{nnn} is iteration number, @code{xxx} is the current value of
the objective function, @code{ppp} is the relative primal infeasibility,
@code{ddd} is the relative dual infeasibility, @code{gap} is the
primal-dual gap.

Note that currently the interior point solver doesn't include many
important features, in particular:

it is not able to process dense columns. Therefore if the constraint
matrix of LP problem has dense columns, the solving will be extremely
inefficient;

it has no special features agains numerical instability. Some LP
problems may cause premature termination of the solving process when the
matrix
@tex
$ADA^T$
@end tex
becomes singular or ill-conditioned;

it computes only values of primal (auxiliary and structural) variables
and doesn't compute values of dual variables (i.e. reduced costs) which
are just set to zero;

it is not able to identify optimal basis that corresponds to the found
interior point solution. Therefore all variables in the solution are
just marked as basic variables.

@subsubheading Returns

The routine @code{glp_call_ipm1} returns one of the following codes:

@table @asis
@item 0
optimal solution found;
@item 1
problem has no feasible (primal or dual) solution;
@item 2
no convergence;
@item 3
iteration limit exceeded;
@item 4
numerical instability on solving Newtonian system.
@end table

In case of non-zero error code the solver returns the best point, which
has been reached during the optimization process.

@section@code{glp_call_bbm1} --- solve MIP problem using branch-and-bound method
@fnindex glp_call_bbm1

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_call_bbm1(LPI *lp, struct bbm1 *parm);
@end example

@subsubheading Description

The routine @code{glp_call_bbm1} is an interface to a MIP problem solver
based on the branch-and-bound procedure.

This routine obtains problem data from the problem object, which the
parameter @code{lp} points to, calls the solver to solve the problem,
and stores the computed solution back to the problem object.

The parameter @code{parm} is a pointer to the parameter block used by
the solver. It is allowed to specify @code{NULL}, in which case standard
values are used by default. If the problem is not very hard, standard
default values fit for most cases. If the parameter block is used,
before a call to the routine @code{glp_call_bbm1} the block should be
initialized by means of the statement @code{glp_init_bbm1(parm)}, and
then the application program can change some of control parameters.
Detailed description of control parameters used by the solver is given
below.

Generally, the branch-and-bound solver performs the following actions:

preparing internal data structures;

solving MIP problem as pure LP (when all integer variables are
considered as continuous) in order to obtain relaxed optimal solution;

investigating the neighbourhood of the relaxed optimal solution in order
to find an optimal integer feasible solution;

storing the computed solution to the problem object.

So far as many MIP problems may take a long time, the solver reports
some visual information about the current progress of the search. This
information is sent to @code{stdout} approximately once per second and
has the following format:

@example
   +nnn: mip = xxx; lp = yyy (mmm, nnn)
@end example

@noindent
where @code{nnn} is total number of simplex iterations performed by the
solver, @code{xxx} is a value of the objective function that corresponds
to the best known integer feasible solution (if no integer feasible
solution has been found yet, @code{xxx} is the text @code{not found
yet}), @code{yyy} is a value of the objective function that corresponds
to the optimal solution of the initial relaxed problem (this value is
not changed during all the search), @code{mmm} is current number of
generated subproblems in the active list, @code{nnn} is total number of
subproblems, which have been solved (considered).

Note that currently the branch-and-bound solver uses easiest heuristics
for branching and backtracking, therefore it is not perfect. Most
probably this solver fits for MIP problems, which have not so many
integer variables (one or two hundreds, not more). Hard or very large
scale MIP problems can't be solved by this routine.

@subsubheading Returns

The routine @code{glp_call_bbm1} returns one of the following codes:

@table @asis
@item 0
no errors. This code means that the solver has successfully finished
solving the problem (note that, for example, if the problem has
no integer feasible solution, the returned code will be zero);
@item 1
iteration limit exceeded. In this case the solver reports the recently
obtained basis solution.
@item 2
numerical problems with basis matrix. This case means that the solver is
not able to solve the problem.
@end table

@subsubheading Control parameters

The behavior of the branch-and-bound solver depends on the following
control parameters, which are members of the structure @code{bbm1},
pointer to which may be passed to the routine @code{glp_call_bbm1}.
(Initializers mean standard values of the controls parameters used by
default.)

@table @code
@item int what = 2;
specifies what solution should be found by the solver:
    @table @code
    @item 0
    initial relaxed solution;
    @item 1
    integer feasible solution;
    @item 2
    integer optimal solution.
    @end table
@item int branch = BB_DRTOM;
specifies what branching heuristic should be used by the solver:
    @table @code
    @item BB_FIRST
    branching on the first variable;
    @item BB_LAST
    branching on the last variable;
    @item BB_DRTOM
    branching using heuristic proposed by Driebeck and Tomlin.
    @end table
@item int btrack = BB_BESTP;
specifies what backtracking heuristic should be used by the solver:
    @table @code
    @item BB_FIFO
    backtracking using FIFO (breadth first search) heuristic;
    @item BB_LIFO
    backtracking using LIFO (depth first search) heuristic;
    @item BB_BESTP
    backtracking using the best projection heuristic.
    @end table
@item double tol_int = 1e-6;
specifies the absolute tolerance which is used by the solver for
checking integer feasibility of the current basis solution. It is not
recommended to change this parameter without detailed understanding its
purpose.
@item double tol_obj = 1e-7;
specifies the relative tolerance which is used by the solver for
comparing values of the objective function. It is not recommended to
change this parameter without detailed understanding its purpose.
@item int form = 1;
specifies what form of the basis matrix should be used by the solver:
    @table @code
    @item 0
    PFI (Product Form of the Inverse);
    @item 1
    RFI (Reid's Form of the Inverse) with updating technique proposed by
    Bartels and Golub;
    @item 2
    RFI (Reid's Form of the Inverse) with updating technique proposed by
    Forrest and Tomlin.
    @end table
@item int scale = 1;
if this flag is set, the solver performs automatic scaling of the
problem. Otherwise scaling is not used.
@item int dual = 0;
if this flag is set, the solver uses the dual simplex method on the
phase I in order to find a primal feasible basis solution. Otherwise the
solver uses the primal simplex method.
@item int steep = 1;
if this flag is set, the solver uses the steepest edge pricing technique
(for both primal and dual simplex) proposed by Goldfarb and Reid.
Otherwise the solver uses the "textbook" pricing.
@item int relax = 1;
if this flag is set, the solver uses the advanced two-pass ratio test
(for both primal and dual simplex0 proposed by P. Harris. Otherwise the
solver uses the "textbook" ratio test.
@item double tol_bnd = 1e-8;
specifies the relative tolerance which is used by the solver for
checking primal feasibility of the current basis solution. It is not
recommended to change this parameter without detailed understanding its
purpose.
@item double tol_dj = 1e-7;
specifies the relative tolerance which is used by the solver for
checking dual feasibility of the current basis solution. It is not
recommended to change this parameter without detailed understanding its
purpose.
@item double tol_piv = 1e-10;
specifies the relative tolerance which is used by the solver for
pivoting. It is not recommended to change this parameter without
detailed understanding its purpose.
@item int iter_max = 0;
maximal allowed number of simplex iterations (0 means no limit).
@item int round = 1;
if this flag is set, the solver replaces computed values of the basic
continuous variables, which are close to zero, by exact zeros (such
rounding is performed after the final basis solution has been obtained).
Otherwise the solver keeps values of all basic continuous variables
"as is".
@end table

@section @code{glp_simplex1} --- comprehensive driver to the simplex method
@fnindex glp_simplex1

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_simplex1(LPI *lp, struct spx1 *parm);
@end example

@subsubheading Description

The routine @code{glp_simplex1} is a comprehensive driver to the
routines which implement components of the revised simplex method for
linear programming.

This routine obtains problem data from the problem object, which the
parameter @code{lp} points to, calls the simplex method routines to
solve the problem, and stores the computed solution back to the problem
object.

The parameter @code{parm} is a pointer to the parameter block used by
the routine. It is allowed to specify @code{NULL}, in which case
standard values are used by default. If the problem is not very hard,
standard default values fit for most cases. If the parameter block is
used, before a call to the routine @code{glp_simplex1()} the block
should be initialized by means of the statement
@code{glp_init_spx1(parm)}, and then the application program can change
some of control parameters. Detailed description of control parameters
used by the solver is given below.

@subsubheading Returns

The routine @code{glp_simplex1} returns one of the following codes:

@table @asis
@item 0
no errors;
@item --1
iteration limit exceeded;
@item --2
time limit exceeded;
@item --3
objective lower limit reached;
@item --4
objective upper limit reached;
@item +1
invalid control parameter;
@item +2
invalid initial basis;
@item +3
numerical problems with basis matrix.
@end table

Negative return codes mean that there is no error, but the solver was
unable to finish the search because of some limitation and therefore the
most recently obtained solution is reported.

@subsubheading Control parameters

The behavior of the driver @code{glp_simplex1} depends on the following
control parameters, which are members of the structure @code{spx1},
pointer to which is passed to the routine. (Initializers mean standard
values set by default):

@table @code
@item int form = 1;
This parameter specifies what form of the basis matrix should be used by
the solver:
   @table @asis
   @item 0
   PFI;
   @item 1
   RFI + Bartels & Golub updating technique;
   @item 2
   RFI + Forrest & Tomlin updating technique.
   @end table
@item int scale = 0;
This parameter controls the scaling option:
   @table @asis
   @item 0
   do not scale the problem
   @item 1
   scale the problem using scale factors specified in the problem
   object.
   @end table
@item int initb = 0;
This parameter controls the initial basis option:
   @table @asis
   @item 0
   use the standard basis, where all auxiliary variables are basic and
   all structural variables are non-basic;
   @item 1
   use the basis specified in the problem object (this allows using an
   advanced basis provided by the application).
   @end table
@item int feas = 0;
This parameter specifies by what method the solver should search for
primal feasible solution if the initial basis is not primal feasible:
   @table @asis
   @item 0
   use the primal simplex method and implicit artificial variables
   technique;
   @item 1
   use the dual simplex method and artificial objective function
   technique.
   @end table
@item int dual = 1;
This parameter specifies what the solver should undertake if the initial
basis is dual feasible:
   @table @asis
   @item 0
   ignore dual feasibility, i.e. search for primal feasible solution
   (phase I) and then search for optimal solution (phase II) using the
   primal simplex method;
   @item 1
   search for optimal solution using the dual simplex method, i.e. skip
   the phase I.
   @end table
@item int steep = 1;
This parameter controls the pricing option (for both primal and dual
simplex methods):
   @table @asis
   @item 0
   use the standard ("textbook") pricing;
   @item 1
   use the steepest edge pricing proposed by Goldfarb and Reid.
   @end table
@item int relax = 1;
This parameter controls the ratio test option (for both primal and dual
simplex methods):
   @table @asis
   @item 0
   use the standard ("textbook") ratio test;
   @item 1
   use two-pass ratio test proposed by P. Harris.
   @end table
@item int round = 1;
This parameter controls the final solution rounding option:
   @table @asis
   @item 0
   keep all computed primal and dual values "as is";
   @item 1
   replace computed primal and dual values, which are close to zero, by
   exact zeros (this rounding is performed once after the final solution
   has been obtained).
   @end table
@item double tol_bnd = 1e-8;
Relative tolerance which is used to see if the solution is primal
feasible. It is not recommended to change this parameter without
detailed understanding its purpose.
@item double tol_dj = 1e-7;
Relative tolerance which is used to see if the solution is dual
feasible. It is not recommended to change this parameter without
detailed understanding its purpose.
@item double tol_piv = 1e-10;
Relative tolerance which is used to choose the pivot element of the
simplex table. It is not recommended to change this parameter without
detailed understanding its purpose.
@item int max_iter = INT_MAX;
Maximal allowed number of simplex iterations; if this parameter is zero,
the solver performs no simplex iterations, but reports solution that
corresponds to the initial basis.
@item int max_time = DBL_MAX;
Maximal allowed time of computations, in seconds (fractional values may
be used); if this parameter is zero, the solver performs no simplex
iterations, but reports solution that corresponds to the initial basis.
@item double obj_min = -DBL_MAX, obj_max = +DBL_MAX;
Allowed range of the objective function. The solver stops searching as
soon as on the phase II the current value of the objective function
becomes less than @code{obj_min} and continue decreasing or greater than
@code{obj_max} and continue increasing. In order to avoid computing the
objective function on each simplex iteration, the "infinte" range
(-@code{DBL_MAX}, +@code{DBL_MAX}) should be specified.
@item int quiet = 0;
This parameter controls displaying informative messages:
   @table @asis
   @item 0
   display all informative messages;
   @item 1
   don't display any informative messages.
   @end table
@item double delay = 0.0;
Initial delay interval, in seconds. The solver doesn't display
information about current solution the first @code{delay} seconds.
@item double freq = 1.0;
Output frequency, in seconds. The solver displays information about
current solution approx. once per @code{freq} seconds.
@item int iter_used;
On entry this parameter is ignored. On exit this parameter is number of
actually performed simplex iterations.
@item double time_used;
On entry this parameter is ignored. On exit this parameter is elapsed
time (in seconds) actually spent by the solver.
@end table

@section @code{glp_pivot_in} --- push auxiliary variables into the basis
@fnindex glp_pivot_in

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_pivot_in(LPI *lp, int flag[], struct piv1 *parm);
@end example

@subsubheading Description

The routine @code{glp_pivot_in} is a special version of the simplex
method. It performs necessary amount of simplex iterations in order to
enter specified auxiliary variables into the basis.

On entry the current basis should be specified in the problem object
@code{lp}. On exit the problem object will contain information about the
new basis constructed by the routine.

The array @code{flag} should have at least 1+@code{m} locations, where
@code{m} is number of rows (auxiliary variables). The location
@code{flag[0]} is not used. If @code{flag[i]}
@tex
$(1 \leq i \leq m)$
@end tex
is non-zero, the routine tries to make the @code{i}-th auxiliary
variable be basic. Otherwise, the @code{i}-th auxiliary variable is
not considered.

The parameter @code{parm} is a pointer to the parameter block used by
the routine. It is allowed to specify @code{NULL}, in which case
standard values are used by default. If the parameter block is used,
before a call to the routine @code{glp_pivot_in} the block should be
initialized by means of the statement @code{glp_init_piv1(parm)}, and
then the application program can change some of the control parameters.
Description of the control parameters used by the routine
@code{glp_pivot_in} is given below.

@subsubheading Returns

@table @asis
@item 0
no errors;
@item --1
all required auxiliary variables are basic, therefore no basis
transformations were performed;
@item +1
invalid control parameter;
@item +2
invalid current basis;
@item +3
some required auxiliary variable can't be made basic;
@item +4
numerical problems with the basis matrix.
@end table

If the return code is non-zero, the current basis specified in the
problem object is not changed.

@subsubheading Control parameters

The behavior of the routine @code{glp_pivot_in} depends on the following
control parameters, which are members of the structure @code{piv1},
pointer to which is passed to the routine. (Initializers means standard
values set by default):

@table @code
@item int form = 1;
This parameter specifies what form of the basis matrix should be used
by the routine:
   @table @asis
   @item 0
   PFI;
   @item 1
   RFI + Bartels & Golub updating technique;
   @item 2
   RFI + Forrest & Tomlin updating technique.
   @end table
@item int scale = 0;
This parameter controls the scaling option:
   @table @asis
   @item 0
   do not scale the constraint matrix;
   @item 1
   scale the constraint matrix using scale factors specified in the
   problem object.
   @end table
@item double tol = 0.01;
A relative tolerance used to choose a pivot element of the simplex
table. Increasing this parameter involves better numerical stability
at the expense of worse sparsity of the basis matrix and vice versa.
This parameter should be in the range @math{0 < tol < 1}.
@end table

@section @code{glp_pivot_out} -- pull structural variables from the basis
@fnindex glp_pivot_out

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_pivot_out(LPI *lp, int flag[], struct piv1 *parm);
@end example

@subsubheading Description

The routine @code{glp_pivot_out} is a special version of the simplex
method. It performs necessary amount of simplex iterations in order to
pull specified structural variables from the basis.

On entry the current basis should be specified in the problem object
@code{lp}. On exit the problem object will contain information about the
new basis constructed by the routine.

The array @code{flag} should have at least 1+@code{n} locations, where
@code{n} is number of columns (structural variables). The location
@code{flag[0]} is not used. If @code{flag[j]}
@tex
$(1 \leq j \leq n)$
@end tex
is non-zero, the routine tries to make @code{j}-th structural variable
be non-basic. Otherwise, the @code{j}-th structural variable is not
considered.

The parameter @code{parm} is a pointer to the parameter block used by
the routine. It is allowed to specify @code{NULL}, in which case
standard values are used by default. If the parameter block is used,
before a call to the routine @code{glp_pivot_out} the block should be
initialized by means of the statement @code{glp_init_piv1(parm)}, and
the the application program can change some of the control parameters.
The control parameters used by the routine @code{glp_pivot_out} are the
same as for the routine @code{glp_pivot_in} (see above).

@subsubheading Returns

@table @asis
@item 0
no errors;
@item --1
all required structural variables are non-basic, therefore no basis
transformations were performed;
@item +1
invalid control parameter;
@item +2
invalid current basis;
@item +3
some required structural variables can't be made non-basic;
@item +4
numerical problems with the basis matrix.
@end table

If the return code is non-zero, the current basis specified in the
problem object is not changed.

@section @code{glp_simplex2} --- solve LP problem using primal simplex method
@fnindex glp_simplex2

@subsubheading Synopsis

@example
#include "glpk.h"
int glp_simplex2(LPI *lp, struct spx2 *parm);
@end example

@subsubheading Description

The routine @code{glp_simplex2} is an LP problem solver, which is based
on the two-phase primal simplex method.

This routine obtains problem data from a problem object, which the
parameter @code{lp} points to, solves the problem, and stores the
computed solution back to the problem object.

The parameter @code{parm} is a pointer to the parameter block used by
the routine. It is allowed to specify @code{NULL}, in which case
standard values are used by default. If the problem is not very hard,
standard default values fit for most cases. If the parameter block is
used, before a call to the routine @code{glp_simplex2} the block should
be initialized by means of the statement @code{glp_init_spx2(parm)}, and
then the application program can change some of control parameters.
Detailed description of control parameters used by the solver is given
below.

Since large-scale problems may take a long time, the solver reports
some visual information about current status of the search. This
information is sent to stdout once per 100 simplex iterations using the
following format:

@example
   nnn:   objval = xxx   infeas = yyy (ddd)
@end example

where @code{nnn} is the iteration count, @code{xxx} is the current value
of the objective function (which is unscaled and has correct sign),
@code{yyy} is a measure of primal infeasibility (which is the current
value of the artificial variable introduced on the phase I), @code{ddd}
is the number of basic fixed variables.

Please note that this solver is not perfect. Although it has been
successfully tested on a wide set of real LP problems, there are so
called hard problems, which can't be resolved by this solver.

@subsubheading Returns

The routine @code{glp_simplex2} returns one of the following codes:

@table @asis
@item 0
no errors. This case means that the solver has successfully finished
solving the problem. (Note, for example, if the problem has no feasible
solution, the solver returns zero code);
@item 1
(reserved for future use);
@item 2
numerical problems with basis matrix. This case means that the solver is
unable to solve the problem.
@end table

@subsubheading Control parameters

The behavior of the solver @code{glp_simplex2} depends on the following
control parameters, which are members of the structure @code{spx2},
pointer to which is passed to the routine. (Initializers mean standard
values set by default):

@table @code
@item int scale = 1;
This parameter controls the scaling option:
   @table @asis
   @item 0
   do not scale the problem;
   @item 1
   scale the problem;
   @item 2
   scale the problem using scale factors specified in the problem
   object.
   @end table
@item int initb = 1;
   This parameter controls the initial basis option:
   @table @asis
   @item 0
   use the standard basis, where all auxiliary variables are basic and
   all structural variables are non-basic;
   @item 1
   use an advanced initial basis;
   @item 2
   use the basis specified in the problem object.
   @end table
@item int round = 1;
   This parameter controls the final solution rounding option:
   @table @asis
   @item 0
   keep all computed primal and dual values "as is"
   @item 1
   replace computed primal and dual values, which are close to zero, by
   exact zeros (this is performed once after the final solution has been
   obtained);
   @end table
@item double tol_bnd = 1e-8;
Relative tolerance which is used to check if the solution is primal
feasible. It is not recommended to change this parameter without
detailed understanding its purpose.
@item double tol_dj = 1e-7;
Relative tolerance which is used to check if the solution is dual
feasible. It is not recommended to change this parameter without
detailed understanding its purpose.
@item double tol_piv = 1e-8;
Relative tolerance which is used to check the pivot element of the
simplex table. It is not recommended to change this parameter without
detailed understanding its purpose.
@end table

@appendix MPS Format

@section Prelude

The MPS format @footnote{The MPS format was proposed in 1960's by IBM as
input format for their mathematical programming system MPS/360. Today
the MPS format is the most widely used format understood by most
packages intended for solving mathematical programming problems. This
appendix describes only the features of the MPS format, which are used
in the GLPK package.} is intended for coding LP problem data. This
format assumes the formulation of LP problem (1.1)---(1.3) (see Section
1.1).

A file in the MPS format is a text file which contains two types of
cards @footnote{In 1960's MPS file was a deck of 80-column punching
cards. Therefore the author decided to keep the word "card", which
should be understood as "line of text file".}: indicator cards and data
cards.

Indicator cards determine a kind of following data. Each indicator card
has one word in uppercase letters beginning at the column 1.

Data cards contain LP problem data. Each data card is divided into six
fixed fields:

@tex
$$\vbox
{
\settabs 8 \columns
\+ & \hfil Field 1 & \hfil Field 2 & \hfil Field 3 & \hfil Field 4 &
    \hfil Field 5 & \hfil Field 6 & \cr
\+ \hrulefill & \hrulefill & \hrulefill & \hrulefill & \hrulefill &
    \hrulefill & \hrulefill & \cr
\+ \hfil Columns & \hfil 2---3 & \hfil 5---12 & \hfil 15---22 &
    \hfil 25---36 & \hfil 40---47 & \hfil 50---61 & \cr
\+ \hfil Contents & \hfil Code & \hfil Name & \hfil Name &
    \hfil Number & \hfil Name & \hfil Number & \cr
}
$$
@end tex

On a particular data card some fields may be optional.

Names are used for identifying LP rows, LP columns, and some vectors
(see below).

Aligning the indicator code to the left margin of the field 1 is
optional.

All names specified in fields 2, 3, and 5 should contain from 1 to 8
arbitrary characters (except control characters). If a name is placed in
the field 3 or 5, its first character should not be the dollar sign
@samp{$}. If a name contains spaces, these spaces are ignored.

All numerical values placed in fields 4 and 6 should be coded in the
form @i{sxx}@code{E}@i{syy}, where @i{s} is the plus @samp{+} or the
minus @samp{-} sign, @i{xx} is a real number with optional decimal
point, @i{yy} is an integer decimal exponent. Any number should contain
up to 12 characters. If the sign @i{s} is omitted, the plus sign is
assumed. The exponent part is optional. If a number contains spaces,
these spaces are ignored.

If a card has the asterisk @samp{*} in the column 1, this card is
considered as a comment and ignored. Besides, if the first character in
the field 3 or 5 is the dollar sign @samp{$}, all characters from the
dollar sign to the end of the card are considered as a comment and
ignored.

MPS file should contain cards in the following order:

@itemize @bullet
@item
the NAME indicator card;
@item
the ROWS indicator card;
@item
data cards specifying LP rows (constraints or auxiliary variables);
@item
the COLUMNS indicator card;
@item
data cards specifying LP columns (structural variables) and constraint
coefficients;
@item
the RHS indicator card;
@item
data cards specifying right-hand sides of constraints;
@item
the RANGES indicator card;
@item
data cards specifying double-sided constraints;
@item
the BOUNDS indicator card;
@item
data cards specifying types and bounds of LP columns;
@item
the ENDATA indicator card.
@end itemize

@dfn{Section} is a group of cards consisting of an indicator card and
data cards following the indicator card. For example, the ROWS section
consists of the ROWS indicator card and data cards specifying LP rows.

Sections RHS, RANGES, and BOUNDS are optional and may be omitted.

@section NAME indicator card

The NAME indicator card should be the first card of MPS file (except
optional comment cards). This card should contain the word @samp{NAME}
in columns 1---4 and the problem name in the field 3. The problem name
is optional and may be omitted.

@section ROWS section

The ROWS section should start with the indicator card, which contains
the word @samp{ROWS} in columns 1---3.

Each data card of the ROWS section specifies one row (constraint) of the
LP problem. These data cards have the following format.

The filed 1 specifies the row type (see (1.2), Section 1.1):

@samp{N} in the filed 1 means that the row is free (unbounded), i.e. the
corresponding constraint has the form:
@tex
$$ -\infty < x_i = a_{m1} x_{m+1} + a_{m2} x_{m+2} + \dots \ +
a_{mn} x_{m+n} < +\infty; $$
@end tex

@samp{L} in the field 1 means that the constraint is of "less than or
equal to" type:
@tex
$$ -\infty < x_i = a_{m1} x_{m+1} + a_{m2} x_{m+2} + \dots \ +
a_{mn} x_{m+n} \leq b_i; $$
@end tex

@samp{G} in the field 1 means that the constraint is of "greater than or
equal to" type:
@tex
$$ b_i \leq x_i = a_{m1} x_{m+1} + a_{m2} x_{m+2} + \dots \ +
a_{mn} x_{m+n} < +\infty; $$
@end tex

@samp{E} in the field 1 means that the row is the constraint of "equal
to" type:
@tex
$$ x_i = a_{m1} x_{m+1} + a_{m2} x_{m+2} + \dots \ + a_{mn} x_{m+n} =
b_i. $$ where $b_i$ is the right hand side. Note that each constraint is
connected with the corresponding auxiliary variable ($x_i$ above),
therefore bounds of the linear form can be understood as bounds of such
auxiliary variable.
@end tex

The field 2 specifies the row name (i.e. the name of the corresponding
auxiliary variable).

Fields 3, 4, 5, and 6 are not used and should be empty.

Numerical values of all non-zero right-hand sides
@tex
$b_i$
@end tex
should be specified in the RHS section. All double-sided constraints
should be specified in the RANGES section.

@section COLUMNS section

The COLUMNS section should start with the indicator card, which contains
the word @samp{COLUMNS} in columns 1---7.

Each data card of the COLUMNS section specifies one or two constraint
coefficients and introduces names of LP columns, i.e. names of
structural variables. These data cards have the following format.

The field 1 is not used and should be empty.

The field 2 specifies the column name. If this field is empty, the name
from the previous data card is used.

The field 3 specifies the row name defined in the ROWS section.

The field 4 specifies the numerical value of the constraint coefficient
@tex
$a_{ij},$
@end tex
which is placed in the corresponding row and column.

Fields 5 and 6 are optional. If they are used, they should contain the
second pair "row name---constraint coefficient" for the same column.

Elements of the constraint matrix (i.e. constraint coefficients) should
follow in the column-wise manner: all elements for the current column
should be specified before specifying elements for the next column.
However, the order of rows in the COLUMNS section may differ from the
order of rows in the ROWS section.

Constraint coefficients, which are not specified in the COLUMNS section,
are considered as zeros. Therefore zero coefficients may be omitted,
although it is allowed to specify them.

Bounds of columns should be specified in the BOUNDS section.

@section RHS section

The RHS section should start with the indicator card, which contains the
word @samp{RHS} in columns 1---3.

Each data card of the RHS section specifies one or two right-hand sides
@tex
$b_i$
@end tex
(see the description of the ROWS section).

The field 1 is not used and should be empty.

The field 2 specifies the name of the right-hand side (RHS) vector
@footnote{This allows the user to specify several RHS vectors in the
same MPS file. However, for solving the problem the user should choose
a particular RHS vector.}. If this field is empty, the name from the
previous data card is used.

The field 3 specifies the row name defined in the ROWS section.

The field 4 specifies the right-hand side
@tex
$b_i$
@end tex
for the row, whose name is specified in the field 3. Depending on the
row type
@tex
$b_i$
@end tex
defines the lower bound (in case of G type), or the upper bound (in case
of L type), or the fixed value (in case of E type).

Fields 5 and 6 are optional. If they are used, they should contain the
second pair "row name---right hand side value" for the same RHS vector.

All right hand sides for the current RHS vector should be specified
before right hand sides for the next RHS vector. However, the order of
rows in the RHS section may differ from the order of rows in the ROWS
section. Each RHS vector should have unique name.

Right-hand sides not specified in the RHS section are considered as
zeros. Therefore zero right hand sides may be omitted, although it is
allowed to specify them.

@section RANGES section

The RANGES section should start with the indicator card, which contains
the word @samp{RANGES} in columns 1---6.

Each data card of the RANGES section specifies one or two ranges for
double-sided constraints, i.e. for constraints that have types L and G
at the same time:
@tex
$$ l_i \leq x_i = a_{i1} x_{m+1} + a_{i2} x_{m+2} + \dots +
a_{in} x_{m+n} \leq u_i, $$
where $x_i$ is an auxiliary variable, $l_i$ is a lower bound, $u_i$ is
an upper bound.
@end tex

The field 1 is not used and should be empty.

The field 2 specifies the name of the range vector @footnote{This allows
the user to specify several range vectors in the same MPS file. However,
for solving the problem the user should choose a particular range
vector.}. If this field is empty, the name from the previous data card
is used.

The field 3 specifies the row name defined in the ROWS section.

The field 4 specifies the range value ri for the row, whose name is
specified in the field 3.

Fields 5 and 6 are optional. If they are used, they should contain the
second pair "row name---range value" for the same range vector.

All range values for the current range vector should be specified before
range values for the next range vector. However, the order of rows in
the RANGES section may differ from the order of rows in the ROWS
section. Each range vector should have unique name.

Lower and upper bounds are determined by the following table:

@tex
$$\vbox
{
\settabs 5 \columns
\+ \hfil Row type & \hfil Sign of $r_i$ & \hfil Lower Bound &
    \hfil Upper Bound & \cr
\+ \hrulefill & \hrulefill & \hrulefill & \hrulefill & \cr
\+ \hfil G & \hfil + or -- & \hfil $b_i$ & \hfil $b_i + |r_i|$ & \cr
\+ \hfil L & \hfil + or -- & \hfil $b_i - |r_i|$ & \hfil $b_i$ & \cr
\+ \hfil E & \hfil + & \hfil $b_i$ & \hfil $b_i + |r_i|$ & \cr
\+ \hfil E & \hfil -- & \hfil $b_i - |r_i|$ & \hfil $b_i$ & \cr
}
$$
@end tex

@noindent
@tex
where $b_i$ is the right-hand side specified in the RHS section (if
$b_i$ is not specified, it is considered to be equal to zero), $r_i$ is
the range value specified in the RANGES section).
@end tex

@section BOUNDS section

The BOUNDS section should start with the indicator card. which contains
the word @samp{BOUNDS} in columns 1---6.

Each data card of the BOUNDS section specifies one bound of one column
(structural variable).

The field 1 specifies the bound type:
@table @samp
@item LO
lower bound;
@item UP
upper bound;
@item FX
fixed variable (lower bound equal to upper bound);
@item FR
free variable (no bounds);
@item MI
no lower bound (lower bound is "minus infinity");
@item PL
no upper bound (upper bound is "plus infinity").
@end table

The field 2 contains the name of the bound vector @footnote{This allows
the user to specify several bound vectors in the same MPS file. However,
for solving the problem the user should choose a particular bound
vector.}. If this field is empty, the name from the previous data card
is used.

The field 3 contains the column name defined in the COLUMNS section.

The field 4 specifies the bound value. If the bound type in the field 1
differs from LO, UP, or FX, this value is ignored and may be omitted.

Fields 5 and 6 are not used and should be empty.

All bound values for the current bound vector should be specified before
bound values for the next bound vector. However, the order of columns in
the BOUNDS section may differ from the order of columns in the COLUMNS
section. Each bound vector should have unique name. The specification of
the lower bound should precede the specification of the upper bound for
the same column (if both they are explictly specified).

By default all columns (structural variables) are considered as
non-negative, i.e. with lower bound equal to zero and upper bound equal
to
@tex
$+\infty$. Lower ($l_j$) or/and upper ($u_j$) bounds of each column
(i.e. structural variable $x_j$) specified in the BOUNDS section are set
in the following way ($s_j$ denotes the corresponding bound value):
@end tex

@table @samp
@item LO
@tex
sets $l_j$ to $s_j$;
@end tex
@item UP
@tex
sets $u_j$ to $s_j$;
@end tex
@item FX
@tex
sets both $l_j$ and $u_j$ to $s_j$;
@end tex
@item FR
@tex
sets $l_j$ to $-\infty$ and $u_j$ to $+\infty$;
@end tex
@item MI
@tex
sets $l_j$ to $-\infty$;
@end tex
@item PL
@tex
sets $u_j$ to $+\infty$.
@end tex
@end table

If only zero upper bound is specified, it is the same as if FX type
would be specified.

@section ENDATA indicator card

The ENDATA indicator card should be the last card of MPS file (except
optional comment cards). This card should contain the word @samp{ENDATA}
in columns 1---6.

There is no way to explicitly specify the objective function and the
optimization sense in the MPS file. However, the following rule is used
by default in all cases: the first row of N type is considered as the
row of the objective function (i.e. the objective function is the same
as the corresponding auxiliary variable), which should be minimized.

@section Example of MPS file

In order to illustrate what the MPS format is, let us consider the
following example LP problem:

@sp 1
@example
   minimize

      Z = COST

   subject to linear constraints

COST = 0.03 MIX1 + 0.08 MIX2 + 0.17 MIX3 + 0.12 MIX4 + 0.15 MIX5 + 0.21 ALUM
     + 0.38 SILC
SUM  =      MIX1 +      MIX2 +      MIX3 +      MIX4 +      MIX5 +      ALUM
     + SILC
FE   = 0.15 MIX1 + 0.04 MIX2 + 0.02 MIX3 + 0.04 MIX4 + 0.02 MIX5 + 0.01 ALUM
     + 0.03 SILC
CU   = 0.03 MIX1 + 0.05 MIX2 + 0.08 MIX3 + 0.02 MIX4 + 0.06 MIX5 + 0.01 ALUM
MN   = 0.02 MIX1 + 0.04 MIX2 + 0.01 MIX3 + 0.02 MIX4 + 0.02 MIX5
MG   = 0.02 MIX1 + 0.03 MIX2 + 0.01 MIX5
AL   = 0.70 MIX1 + 0.75 MIX2 + 0.80 MIX3 + 0.75 MIX4 + 0.80 MIX5 + 0.97 ALUM
SI   = 0.02 MIX1 + 0.06 MIX2 + 0.08 MIX3 + 0.12 MIX4 + 0.02 MIX5 + 0.01 ALUM
     + 0.97 SILC

   and bounds of (auxiliary and structural) variables

      -inf <  COST < +inf        0 <= MIX1 <=  200
              SUM  =  200        0 <= MIX2 <= 2500
      -inf <  FE   <=  60      400 <= MIX3 <=  800
      -inf <  CU   <= 100      100 <= MIX4 <=  700
      -inf <  MN   <=  40        0 <= MIX3 <= 1500
      1500 <= AL   < +inf        0 <= ALUM <  +inf
       250 <= SI   <= 300        0 <= SILC <  +inf
@end example
@sp 1

The MPS file which specifies data for this example LP problem is shown
below (two top comment lines show card positions).

@page
@example
*000000001111111111222222222233333333334444444444555555555566
*234567890123456789012345678901234567890123456789012345678901
NAME          PLAN
ROWS
 N  COST
 E  SUM
 L  FE
 L  CU
 L  MN
 L  MG
 G  AL
 L  SI
COLUMNS
    MIX1      COST            .03000   SUM            1.00000
              FE              .15000   CU              .03000
              MN              .02000   MG              .02000
              AL              .70000   SI              .02000
    MIX2      COST            .08000   SUM            1.00000
              FE              .04000   CU              .05000
              MN              .04000   MG              .03000
              AL              .75000   SI              .06000
    MIX3      COST            .17000   SUM            1.00000
              FE              .02000   CU              .08000
              MN              .01000   AL              .80000
              SI              .08000
    MIX4      COST            .12000   SUM            1.00000
              FE              .04000   CU              .02000
              MN              .02000   AL              .75000
              SI              .12000
    MIX5      COST            .15000   SUM            1.00000
              FE              .02000   CU              .06000
              MN              .02000   MG              .01000
              AL              .80000   SI              .02000
    ALUM      COST            .21000   SUM            1.00000
              FE              .01000   CU              .01000
              AL              .97000   SI              .01000
    SILC      COST            .38000   SUM            1.00000
              FE              .03000   SI              .97000
RHS
    RHS1      SUM         2000.00000   FE            60.00000
              CU           100.00000   MN            40.00000
              SI           300.00000
              MG            30.00000   AL          1500.00000
RANGES
    RNG1      SI            50.00000
BOUNDS
 UP BND1      MIX1         200.00000
 UP           MIX2        2500.00000
 LO           MIX3         400.00000
 UP           MIX3         800.00000
 LO           MIX4         100.00000
 UP           MIX4         700.00000
 UP           MIX5        1500.00000
ENDATA
@end example
@sp 1

@section MIP Features

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

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

Marker cards have the same format as data cards (see above).

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

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

The field 3 should contain the word @code{'MARKER'} (including
apostrophes).

The field 5 should contain either the word @code{'INTORG'} (including
apostrophes) for the marker, which begins a group of integer columns, or
the word @code{'INTEND'} (including apostrophes) for the marker, which
ends a group of integer columns.

The second way is less general but 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 in the BOUNDS section:

@table @samp
@item UI
@tex
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 an upper bound of the corresponding column should be specified in
the field 4 (like in case
of UP bound type);
@end tex
@item BV
@tex
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 being of integer kind can have only two values: zero and one).
In this case a number specified in the field 4 is ignored and may be
omitted.
@end tex
@end table

Let's consider the following example of MIP problem:

@sp 1
@example
   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 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)
@end example
@sp 1

The corresponding MPS file may look like the following:

@sp 1
@example
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
    X3        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
@end example
@sp 1

The same example may be coded without markers @code{'INTORG'} and
@code{'INTEND'} if we specify the bound type @samp{UI} for the variable
@code{x2} and the bound type @samp{BV} for the variable @code{x3}:

@sp 1
@example
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
    X3        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
@end example
@sp 1

@appendix Output Format

This appendix describes the output format which is used by the
@code{glp_print_sol} routine in order to report the basic solution (see
Section 1.1) found by the solver.

The typical output from the @code{glp_print_sol} routine looks like the
following (this output corresponds to the optimal solution of the
example problem from Appendix A):

@sp 1
@example
Problem:    PLAN
Rows:       8
Columns:    7
Non-zeros:  48
Objective:  COST = 296.217 (MINimization)
Status:     OPTIMAL

Number  Row name  St   Activity     Lower bound   Upper bound    Marginal
------ ---------- -- ------------- ------------- ------------- -------------
     1 COST       B        296.217
     2 SUM        NS          2000          2000             =    -0.0135957
     3 FE         NU            60                          60      -2.56823
     4 CU         B        83.9675                         100
     5 MN         NU            40                          40     -0.544404
     6 MG         B        19.9603                          30
     7 AL         NL          1500          1500                    0.251986
     8 SI         NL           250           250           300      0.485199

Number  Col name  St   Activity     Lower bound   Upper bound    Marginal
------ ---------- -- ------------- ------------- ------------- -------------
     1 MIX1       NL             0             0           200      0.253625
     2 MIX2       B        665.343             0          2500
     3 MIX3       B        490.253           400           800
     4 MIX4       B        424.188           100           700
     5 MIX5       NL             0             0          1500      0.014556
     6 ALUM       B        299.639             0
     7 SILC       B        120.578             0

End of output
@end example
@sp 1

The output starts from the header that includes the following lines.

@table @samp
@item Problem:
shows the problem name.
@item Rows:
shows total number of rows (auxiliary variables) in the problem.
@item Columns:
shows total number of columns (structural variables) in the problem.
@item Non-zeros:
shows total number of constraint coefficients (i.e. elements of the
constraint matrix) in the problem @footnote{"Non-zero" means
a constraint coefficient which has been explicitly introduced to the
problem. As a rule there is no need to introduce zero coefficients.
However, if the user explicitly introduced zero coefficients, all they
are considered as non-zeros.}.
@item Objective:
shows the name of the objective function, its value in the computed
solution, and the optimization sense (@samp{Minimization} or
@samp{Maximization}).
@item Status:
shows the status of the solution (for example, @samp{OPTIMAL} means that
the solution is optimal).
@end table

The header is followed by two tables. The first table reports rows, the
second table reports columns. Both tables have identical format. (In
order to obtain information included to these two tables the
@code{glp_print_sol} routine calls some GLPK API routines. The routine
doesn't access directly to the workspace.)

@table @samp
@item Number
is the sequential number of the row/column.
@item Row/Column name
shows the name of row/column.
@item St
shows the status of the corresponding row/column in the found basic
solution. This field may contain one of the following values:
@table @samp
@item B
basic variable. The asterisk @samp{*} which may follow this status means
that the value of row/column is out of its bounds. This may happen if
the computed solution is infeasible, or if the problem is degenerative
(in the latter case the value of row/column is close to its bound);
@item NL
non-basic variable placed on its lower bound;
@item NU
non-basic variable placed on its upper bound;
@item NF
non-basic free variable;
@item NS
non-basic fixed variable.
@end table
@item Activity
shows the computed value of row/column in the found basic solution.
@item Lower bound
shows the lower bound of row/column or its fixed value (in case of fixed
variable). If row/column has no lower bound, this field is empty.
@item Upper bound
shows the upper bound of row/column or contains @samp{=}, that means
that the upper bound is equal to the lower bound (in case of fixed
variable). If row/column has no upper bound, this field is empty.
@item Marginal
shows the computed marginal value of row/column. If the corresponding
variable is basic, this field is empty, because marginal values of basic
variables are always equal to zero. In case of non-basic variable this
field may contain @samp{< eps} which means that the marginal value is
close to zero.
@end table

@bye
