\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename simplex
@settitle GLPK 2.1 Implementation of the Revised Simplex Method
@setchapternewpage odd
@exampleindent 0
@c %**end of header
@syncodeindex fn cp
@syncodeindex tp cp
@syncodeindex vr cp

@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 2.1
@subtitle Implementation of the Revised Simplex Method
@subtitle February 2001
@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 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

@unnumbered Preface

This document describes GLPK @footnote{GLPK is acronym for
@tex
\underbar{G}NU \underbar{L}inear \underbar{P}rogramming \underbar{K}it.
@end tex
}
implementation of the revised simplex method for solving large-scale linear
programming and other related problems.

Although the first part of the document contains necessary theoretical
information, this document is not intended to be used as a tutorial. It is
assumed that the reader has basic knowledges in the linear programming
theory.

@chapter Theoretical Background

@section Fundamentals

@tex
The GLPK implementation of the revised simplex method assumes the following
formulation of the linear programming (LP) problem:
$$\eqalign{
Z &= \widehat{c}^T x_S + c_0 \rightarrow \min \ (\max) \cr
x_R &= \widehat{A} x_S \cr
l_R &\leq x_R \leq u_R \cr
l_S &\leq x_S \leq u_S \cr
} \eqno (1)
$$
\settabs
\+ where: & xxxxx & \cr
\+ where: & $x_S$ & --- vector of structural variables; \cr
\+        & $x_R$ & --- vector of auxiliary variables; \cr
\+        & $Z$   & --- objective function; \cr
\+ & $\widehat{c}$   & --- vector of coefficients of the objective function at
                        the structural variables; \cr
\+        & $c_0$ & --- constant term of the objective function; \cr
\+ & $\widehat{A}$ & --- matrix of coefficients of equaility constraints; \cr
\+        & $l_R, u_R$ & --- vectors of lower and upper bounds of auxiliary
                             variables; \cr
\+        & $l_S, u_S$ & --- vectors of lower and upper bounds of structural
                             variables; \cr

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

$$\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
}
$$

For the sake of simplicity we may do the following:

a) we may disregard the case of maximization, because replacing $Z$ by
$(-Z)$ we can reduce it to the case of minimization;

b) we may disregard the constant term $c_0$, because it doesn't affect on the
optimal solution;

c) from the point of view of the simplex method there is no difference between
auxiliary and structural variables. Thus, it is more convenient to introduce
the united vector of variables
$$x = (x_R, x_S) \eqno (2)$$

d) using (2) we may introduce the expanded matrix of constraint coefficients
$$A = (I | - \widehat{A}), \eqno (3)$$
where $I$ is the unity matrix that corresponds to the auxiliary variables,
$\widehat{A}$ is the original matrix of constraint coefficients from (1) that
corresponds to the structural variables;

e) using (2) we also may introduce the expanded vector of objective
coefficients
$$c = (0, \widehat{c}), \eqno (4)$$
where $0$ is zero subvector that corresponds to the auxiliary variables,
$\widehat{c}$ is the original vector of objective coefficients from (1) that
corresponds to the structural variables.

Summing up all notices above we can rewrite the LP problem (1) in the
following form:
$$\eqalignno{
Z &= c^T x & (5) \cr
Ax &= 0 & (6) \cr
l &\leq x \leq u & (7) \cr
}
$$

Let's assume that the LP problem has $m$ auxiliary variables and $n$
structural variables. Then the constraint matrix $A$ has $m$ rows and $m+n$
columns.

Since the matrix $A$ includes a non-singular submatrix of order $m$ (for
instance, the unity submatrix), it has full row rank, i.e. rank$(A) = m$.
Therefore it can be divided into two submatrix:
$$A = (B \ | \ N), \eqno (8)$$
where $B$ is a square non-singular $m \times m$ matrix called \it basis
matrix\rm; $N$ is a $m \times n$ matrix.

Using (8) the system of equality constraints (6) can be written in the form
$$B x_b + N x_N = 0, \eqno (9)$$
where $x_B$ is a vector of \it basic variables \rm corresponding to columns
of the matrix $B$, $x_N$ is a vector of \it non-basic variables \rm
corresponding to columns of the matrix $N$.

The matrix $B$ is non-singular, due to that the basic variables as well as
the objective function can be explicitly expressed through the non-basic
variables. So, from (9) we have
$$x_B = - B^{-1} N x_N. \eqno (10)$$

Substituting $x_B$ from (10) to (5) we also have
$$Z = c^T x = c_B^T x_B + c_N^T x_N =
c_B^T (- B^{-1} N x_N) + c_N^T x_N = (c_N^T - c_B^T B^{-1} N) x_N.
\eqno (11)$$

Thus, using the decomposition (8) and accounting (10) and (11) the LP problem
(5)---(7) can be rewritten in the form called \it the simplex table\rm:
$$\eqalignno{
Z &= d^T x_N & (12) \cr
x_B &= \widetilde{A} x_N & (13) \cr
l_B &\leq x_B \leq u_B & (14) \cr
l_N &\leq x_N \leq u_N & (15) \cr
}
$$
@end tex

The simplex table (12)---(15) includes the following two principal
components @footnote{Here and further
@tex
$B^{-T}$
@end tex
means
@tex
$(B^T)^{-1}$.
@end tex
}
@tex
$$\eqalignno{
d &= (d_j) = c_N - N^T B^{-T} c_B = c_N + \widetilde{A}^T c_B & (16) \cr
\widetilde{A} &= (\alpha_{ij}) = - B^{-1} N & (17) \cr
}
$$
where $d$ --- vector of \it reduced costs \rm (or \it marginal values\rm) of
non-basic variables ($d_j$ shows by what quantity the objective function
increases or decreases when the non-basic variable $(x_N)_j$ increases or
decreases by one);
$\widetilde{A}$ --- matrix of \it influence coefficients \rm ($\alpha_{ij}$
shows by what quantity the basic variable $(x_B)_i$ increases or decreases when
the non-basic variable $(x_N)_j$ increases or decreases by one).

\it Basic solution \rm of the LP problem (5)---(7) that corresponds to the
basis $B$ is a solution which satisfies to the equality constraints (6) and
where non-basic free variables are equal to zero and other non-basic variables
are on their bounds.

Let the set of non-basic variables $x_N$ is divided into four subsets:
$$x_N = x_F \cup x_L \cup x_U \cup x_S, \eqno (18)$$
\settabs
\+ where: & xxx & \cr
\+ where: & $x_F$ & --- subset of non-basic free variables; \cr
\+        & $x_L$ & --- subset of non-basic variables which are on lower
                        bounds; \cr
\+        & $x_U$ & --- subset of non-basic variables which are on upper
                        bounds; \cr
\+        & $x_S$ & --- subset of non-basic fixed variables. \cr

Then the basic solution can be written in the form:
$$x = (x_B, x_N), \eqno (19)$$
where values of non-basic variables $x_N$ are determined as
$$
(x_N)_j = \left \{ \matrix {
0,                 \hfill & if \  (x_N)_j \in x_F \hfill \cr
(l_N)_j,           \hfill & if \  (x_N)_j \in x_L \hfill \cr
(u_N)_j,           \hfill & if \  (x_N)_j \in x_U \hfill \cr
(l_N)_j = (u_N)_j, \hfill & if \  (x_N)_j \in x_S \hfill \cr
} \right . \eqno (20)
$$
and values of basic variables are determined by (13). Besides, the value of
the objective function $Z$ can be determined by direct substitution of values
of basic and non-basic variables into (5).

Basic solution is called \it primal feasible basic solution \rm if all
variables satisfy to the conditions (7).

Let the vector $\beta$ denote values of basic variables $x_B$ in some basic
solution. Non-basic variables satisfy to the conditions (7) by definition.
Therefore the basic solution is primal feasible if
$$(l_B)_i \leq \beta_i \leq (u_B)_i, \ i = 1, \dots, m. \eqno(21)$$

Basic solution is called \it dual feasible basic solution \rm if all reduced
costs (16) satisfy to the following conditions:
$$\eqalign{
if \ (x_N)_j \in x_F &\ then \ d_j = 0 \cr
if \ (x_N)_j \in x_L &\ then \ d_j \geq 0 \cr
if \ (x_N)_j \in x_U &\ then \ d_j \leq 0 \cr
if \ (x_N)_j \in x_S &\ then \ -\infty < d_j < +\infty
} \eqno (22)
$$
i.e. if there is no non-basic variable which changing in the feasible
direction can improve (decrease) the objective function.

Basic solution which is primal and dual feasible at the same time is
\it optimal solution \rm of the LP problem (5)---(7).

\it The primal simplex method \rm is an iterative numerical procedure which
starting from some primal feasible basic solution tries to make it dual
feasible. Analogously \it the dual simplex method \rm is a procedure which
starting from some dual feasible solution tries to make it primal feasible.

\it The revised (primal or dual) simplex method \rm is a variant of the
simplex method which doesn't keep the simplex table (12)---(15)
@end tex
explicitly. @footnote{A variant of the simplex method which uses explicit
representation of the simplex table is called @dfn{the classic simplex
method}. It doesn't allow exploiting advantages of sparse computations and
therefore it doesn't fit for large-scale LP problems due to its low
efficiency.}
@tex
Instead that it computes only necessary components of the simplex table.
@end tex

@section Primal simplex method

@tex
Let there is some initial primal basic solution defined by (8) and (18). The
primal revised simplex method for solving the LP problem (5)---(7) includes
the following principal steps.

\underbar{Step 1.} [Computing current values of variables.] Compute current
values of non-basic variables using the formula (20).

Compute current values of basic variables $\beta$ using the formula (10).
(Because the current basis solution is assumed to be primal feasible, the
primal feasibility conditions (21) should be satisfied.)

On this step the current value of the objective function $Z$ also can be
computed by direct substitution of the computed values of variables into the
formula (5).

\underbar{Step 2.} [Computing reduced costs.] Compute reduced costs $d$ of
non-basic variables using the formula (16).

\underbar{Step 3.} [Choosing non-basic variable.] Choose a non-basic variable
$(x_N)_q$ which doesn't satisfy to the dual feasibility conditions (22), i.e.
that variable for which:
$$\eqalign{
(x_N)_q \in x_F &\ and \ d_q \neq 0, \ or \cr
(x_N)_q \in x_L &\ and \ d_q < 0,    \ or \cr
(x_N)_q \in x_U &\ and \ d_q > 0. \cr
} \eqno (23)
$$
where $d_q$ is the reduced cost of the variable $(x_N)_q$. The conditions
(23) mean that the variable $(x_N)_q$ changing in feasible direction (i.e.
increasing if $(x_N)_q \in x_F \cup x_L$ or decreasing if $(x_N)_q \in
x_F \cup x_L$) can improve (decrease) the objective function. If there is
no such non-basic variable, STOP --- the current basis solution is optimal
because it is primal and dual feasible.

\underbar{Step 4.} [Computing influence coefficients.] Compute $q$-th column
of the matrix $\widetilde{A}$ (see (17)) which contains influence coefficients
for the chosen non-basic variable $(x_N)_q$.

\underbar{Step 5.} [Choosing basic variable.] Let the chosen non-basic
variable $(x_N)_q$ is changing in the feasible direction. On this step it is
necessary to detect one of the following three cases:

1) some basic variable reaches its lower bound first, or

2) some basic variable reaches its upper bound first, or

3) the non-basic variable $(x_N)_q$ reaches its opposite bound first.

In order to formalize this step let's consider $i$-th row of the simplex
table (13) that corresponds to $i$-th equality constraint:
$$(x_B)_i = \alpha_{i1}(x_N)_1 + \dots + \alpha_{iq} (x_N)_q + \dots +
\alpha_{in}(x_N)_n. \eqno (24)$$

Let $\theta_i \geq 0$ is absolute value of change of the non-basic variable
$(x_N)_q$ at which $(x_B)_i$ reaches its (lower or upper) bound:

a) if $(x_N)_q$ is increasing, i.e. if $d_q < 0$
$$
\theta_i = \left \{ \matrix {
\infty, \hfill & \hfill \alpha_{iq} = 0\cr
[(u_B)_i - \beta_i] / \alpha_{iq}, \hfill & \hfill \alpha_{iq} > 0\cr
[(l_B)_i - \beta_i] / \alpha_{iq}, \hfill & \hfill \alpha_{iq} < 0
} \right . \eqno (25)
$$

b) if $(x_N)_q$ is decreasing, i.e. if $d_q > 0$
$$
\theta_i = \left \{ \matrix {
\infty, \hfill & \hfill \alpha_{iq} = 0\cr
[\beta_i - (l_B)_i] / \alpha_{iq}, \hfill & \hfill \alpha_{iq} > 0\cr
[\beta_i - (u_B)_i] / \alpha_{iq}, \hfill & \hfill \alpha_{iq} < 0
} \right . \eqno (26)
$$

Obviously the basic variable reaching its bound before other basic variables
is determined by the minimal $\theta_i$. Therefore the choice is based on the
quantity
$$\theta = \min[\min_i \theta_i, (u_N)_q - (l_N)_q] \eqno (27)$$

If $\theta = \theta_p$, choose the basic variable $(x_B)_p$.

If $\theta = (u_N)_q - (l_N)_q < \theta_i$ for all $i = 1, \dots, m$, the
case (3) takes place.

If $\theta = \infty$, STOP --- the problem has unbounded solution (i.e.
it has no dual feasible solutions), because the objective function can
unlimitedly decrease.

\underbar{Step 6.} [Change the basis.] If on the step 5 the basic variable
$(x_B)_p$ was chosen, replace this variable in the set of basic variables
$x_B$ by the chosen non-basic variable $(x_N)_q$. From the point of view of
(8) such replacement means that in the matrix $B$ the column $B_p$ should
be replaced by the column $N_q$ and vice versa, in the matrix $N$ the column
$N_q$ should be replaced by the column $B_p$.

If on the step 5 the case (3) took place, just move the chosen non-basic
variable $(x_N)_q$ from its current bound to the opposite one. (In this case
the sets $x_B$ and $x_N$ and the matrices $B$ and $N$ are not changed.)

In both cases the adjacent basis solution remains primal feasible, besides
the non-basic variable $(x_N)_q$ increases or decreases by the quantity
$\theta$, and the objective function $Z$ decreases by the quantity
$|d_q| \theta$.

After changing the basis continue the search starting from the step 1.
@end tex

@section Dual simplex method

@tex
The dual simplex method is based on the dual equality constraints
$$A^T \pi + \lambda = c, \eqno (28)$$
where $\pi = (\pi_i)$ is the vector of Lagrange multipliers that correspond
to the primal equality constraints (6), $\lambda = (\lambda_j)$ is the vector
of Lagrange multipliers that correspond to the primal bound constraints (7),
$c$ is the vector of coefficients of the objective function. Variables $\pi_i$
and $\lambda_i$ are called \it dual variables \rm for the LP problem (5).

From the complementarity conditions it follows that in case of basis
solution the decomposition (19) defines the corresponding decomposition of
the dual variables
$$\lambda = (\lambda_B, \lambda_N), \eqno (29)$$
where Lagrange multipliers $\lambda_B$ that correspond to basic variables
should be equal to zero, and Lagrange multipliers $\lambda_N$ that correspond
to non-basic variables should satisfy to the dual feasibility conditions.

Using (8) and (29) the system (28) can be written in the decomposed form:
$$\eqalignno{
B^T \pi + \lambda_B &= c_B & (30) \cr
N^T \pi + \lambda_N &= c_N & (31) \cr
}
$$
therefore
$$\eqalignno{
\pi &= -B^{-T} \lambda_B + B^{-T} c_B & (32) \cr
\lambda_N &= -N^T \pi + c_N = N^T B^{-T} \lambda_B + (c_N - N^T B^{-T} c_B)
= \widetilde{A}^T \lambda_B + d & (33)
}
$$
where $\widetilde{A}$ is the matrix of influence coefficients (17), $d$ is
the vector of reduced costs of non-basic variables (16).

Let there is some initial dual feasible basic solution defined by (8) and (29).
The dual revised simplex method for solving LP problem (5)---(7) includes the
following principal steps.

\underbar{Step 1.} [Computing current values of variables.] Compute current
values of non-basic variables using the formula (20).

Compute current values of basic variables $\beta$ using the formula (10).

On this step the current value of the objective function $Z$ also can be
computed by direct substitution of the computed values of variables into the
formula (5).

\underbar{Step 2.} [Computing reduced costs.] Compute reduced costs $d$ of
non-basic variables using the formula (16). (Because the current basis
solution is assumed to be dual feasible, the dual feasibility conditions (22)
should be satisfied. Note that the reduced costs $d$ are current values of
Lagrange multipliers $\lambda_N$ for non-basic variables.)

\underbar{Step 3.} [Choosing basic variable.] Choose a basic variable
$(x_B)_p$ which doesn't satisfy to the primal feasibility conditions (14),
i.e. that variable for which:
$$\beta_p < (l_B)_p \ or \ \beta_p > (u_B)_p. \eqno (34)$$
If there is no such basic variable, STOP --- the current solution is optimal,
because it is primal and dual feasible.

\underbar{Step 4.} [Computing influence coefficients.] Compute $p$-th row of
the matrix $\widetilde{A}$ (see (17)) which contains influence coefficients
for the dual variable $(\lambda_B)_i$ that corresponds to the chosen basic
variable $(x_B)_i$. (Note that $p$-th row of the matrix $\widetilde{A}$ is
$p$-th column of the matrix $\widetilde{A}^T$; see (33).)

\underbar{Step 5.} [Choosing non-basic variable.] Let the dual variable
$(\lambda_B)_p$ that corresponds to the chosen basic variable $(x_B)_p$ is
changing in the feasible direction. On this step it is necessary to detect
one of the following two cases:

1) some dual variable $(\lambda_N)_j$ being non-negative reaches its lower
(zero) bound first, or

2) some dual variable $(\lambda_N)_j$ being non-positive reaches its upper
(zero) bound first.

In order to formalize this step let's consider $j$-th row of the transposed
(dual) simplex table (33):
$$(\lambda_N)_j = \alpha_{1j} (\lambda_B)_1 + \dots +
\alpha_{pj} (\lambda_B)_p + \dots + \alpha_{mj} (\lambda_B)_m + d_j.
\eqno (35)$$

Let $\theta_j$ is the absolute value of cahnge of the dual variable
$(\lambda_B)_p$ at which $(\lambda_N)_j$ reaches its (lower or upper) zero
bound:
$$
\theta_j = \left \{ \matrix {
|d_j / \alpha_{pj}|,
& if \ \beta_p < (l_B)_p, \alpha_{pj} > 0, (x_N)_j \in x_F \cup x_L \cr
& or \ \beta_p > (u_B)_p, \alpha_{pj} > 0, (x_N)_j \in x_F \cup x_U \cr
& or \ \beta_p < (l_B)_p, \alpha_{pj} < 0, (x_N)_j \in x_F \cup x_U \cr
& or \ \beta_p > (u_B)_p, \alpha_{pj} < 0, (x_N)_j \in x_F \cup x_L \cr
\infty \hfill & in \ other \ cases \hfill \cr
} \right . \eqno (36)
$$

Obviously the dual variable reaching its bound before other dual basic
variables is determined by the minimal $\theta_j$. Therefore the choice is
based on the quantity
$$\theta = \min_j \theta_j. \eqno(37)$$

If $\theta = \theta_q < \infty$, choose the non-basic variable $(x_N)_q$.
Otherwise, if $\theta = \infty$, STOP --- the problem has no primal feasible
solutions (i.e. the dual objective function can unlimitedly increase).

\underbar{Step 6.} [Change the basis.] Replace the chosen basic variable
$(x_B)_p$ in the set of basic variables $x_B$ by the chosen non-basic variable
$(x_N)_q$. From the point of view of (8) such replacement means that in the
matrix $B$ the column $B_p$ should be replaced by the column $N_q$ and vice
versa, in the matrix $N$ the column $N_q$ should be replaced by the column
$B_p$. (Note that the adjacent basis solution remains dual feasible.)

After changing the basis continue the search starting from the step 1.
@end tex

@section Computing components of the simplex table

@tex
It was said above that the revised simplex method doesn't keep the simplex
table (12)---(15) explicitly (as the classic simplex method does). Instead that
it uses only necessary components of the simplex table.

Analysis of the primal and dual variants of the revised simplex method shows
that all computations related to the simplex table can be implemented by
means of some representation of the basis matrix $B$, which provides the
following four basic operations:

1) building the representation for a given basis matrix $B$ (for example, for
the basis matrix that corresponds to an initial basic solution), i.e.
\it reinverting \rm the basis matrix;

2) performing so called \it forward transformation (FTRAN) \rm of a given
vector $u$, i.e. solving the system $B u' = u$;

3) performing so called \it backward transformation (BTRAN) \rm of a given
vector $u$, i.e. solving the system $B^T u' = u$;

4) updating the representation of the current basis matrix $B$ if one column
of $B$ has been replaced by other column.

Let's consider how these operations can be used for computing principal
components of the simplex table.

The primal simplex method needs $\beta$ (the current values of basic
variables), $d$ (reduced costs of non-basic variables), and $\widetilde{A}_q$
($q$-th column of the matrix $\widetilde{A}$ that corresponds to the chosen
non-basic variable $(x_N)_q$). The dual simplex method needs $\beta$, $d$,
and $\alpha_p$ ($p$-th row of the matrix $\widetilde{A}$ that corresponds to
the chosen basic variable $(x_B)_p$).

The formula (10) shows that the vector $\beta$ can be computed by means of
FTRAN:
$$\beta = B^{-1} (N x_N), \eqno (38)$$
where $N$ is the submatrix of $A$ built of columns of non-basic variables,
$x_N$ is the vector of the current values of non-basic variables defined by
(20).

Analogously, the vector $d$ can be computed by means of BTRAN as it follows
from the formulae (16) and (32):
$$\eqalignno{
\pi &= B^{-T} c_B & (39) \cr
d &= c_N - N^T \pi & (40) \cr
}
$$
where $\pi$ is the vector of the current values of \it simplex multipliers \rm
(i.e. Lagrange multipliers that correspond to the equality constraints),
$c_B$ and $c_N$ are the subvectors of coefficients of the objective function
at, respectively, basic and non-basic variables.

Let
$$e_i = (0, \dots, 0, 1, 0, \dots, 0)^T \eqno (41)$$
is the unity vector with all elements are zero except $i$-th element which is
one. Then from the formula (17) we have:
$$\eqalignno{
\widetilde{A}_q &= \widetilde{A} e_q = -B^{-1} N_q & (42) \cr
\alpha_p &= e_p^T \widetilde{A} = -e_p^T B^{-1} N =
-(B^{-T} e_p)^T N = - \zeta_p^T N & (43)
}
$$
where $N_q$ is $q$-th column of the matrix N (see (8)),
$\zeta_p = B^{-T}e_p$ is $p$-th column of the matrix $B^{-T}$ (or $p$-th
row of the matrix $B^{-1}$). Thus, the components $\widetilde{A}_q$ and
$\alpha_p$ also can be computed by means of FTRAN and BTRAN operations.

The current GLPK implementation of the revised simplex method allows using
one of two representations of the basis matrix: PFI (Product Form of the
Inverse) and RFI (Reid's Form of the Inverse) [1]. However, due to modular
structure of GLPK it is possible to use any other user-supplied representation
of the basis matrix.
@end tex

@section Explicit formulae for updating the simplex table

@tex
Although the revised simplex method never explicitly updates the simplex
table, sometimes it is convenient to know explicit formulae for updating the
simplex table (i.e. those formulae which could be used in the classic simplex
method).

In order to derive these formulae let's write the simplex table (13) in
the unwrapped form:
$$\eqalign{
(x_B)_1 &= \alpha_{11} (x_N)_1 + \dots + \alpha_{1q} (x_N)_q + \dots +
\alpha_{1n} (x_N)_n \cr
& \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \cr
(x_B)_p &= \alpha_{p1} (x_N)_1 + \dots + \alpha_{pq} (x_N)_q + \dots +
\alpha_{pn} (x_N)_n \cr
& \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \cr
(x_B)_m &= \alpha_{m1} (x_N)_1 + \dots + \alpha_{mq} (x_N)_q + \dots +
\alpha_{mn} (x_N)_n \cr
} \eqno (44)
$$

Let the basic variable $(x_B)_p$ has been chosen to leave the basis and the
non-basic variable $(x_N)_q$ has been chosen to enter the basis.

In order to express the new basic variable $(x_N)_q$ through the new set of
non-basic variables (which now includes the old basic variable $(x_B)_p)$ we
should transform $p$-th (pivot) row of the simplex table (44):
$$(x_B)_p = \alpha_{pq} (x_N)_q + \sum_{j \neq q} \alpha_{pj} (x_N)_j,$$
whence it follows
$$(x_N)_q = {1 \over \alpha_{pq}} (x_B)_p - \sum_{j \neq q}
{\alpha_{pj} \over \alpha_{pq}} (x_N)_j. \eqno (45)$$

Now we can use the expression (45) in order to eliminate the variable
$(x_N)_q$ from other rows of the simplex table. Substitution of $(x_N)_q$ into
$i$-th row of the simplex table $(i \neq p)$ gives
$$\eqalign{
(x_B)_i &= \alpha_{iq} (x_N)_q + \sum_{j \neq q} \alpha_{ij} (x_N)_j = \cr
&= \alpha_{iq} \left[ {1 \over \alpha_{pq}} (x_B)_p -
\sum_{j \neq q}{\alpha_{pj} \over \alpha_{pq}} (x_N)_j \right ] +
\sum_{j \neq q} \alpha_{ij} (x_N)_j = \cr
&= {\alpha_{iq} \over \alpha_{pq}} (x_B)_p -
\sum_{j \neq q}{\alpha_{iq} \alpha_{pj} \over \alpha_{pq}} (x_N)_j +
\sum_{j \neq q} \alpha_{ij} (x_N)_j = \cr
&= {\alpha_{iq} \over \alpha_{pq}} (x_B)_p +
\sum_{j \neq q} \left [ \alpha_{ij} -
{\alpha_{iq} \alpha_{pj} \over \alpha_{pq}} \right ] (x_N)_j, \cr
} \eqno (46)
$$

Using (45) and (46) and assuming that in the new simplex table (which
corresponds to the adjacent basis) its $p$-th row corresponds to the new
basic variable $(x_N)_q$ and its $q$-th column corresponds to the new
non-basic variable $(x_B)_p$ we can write the necessary formulae for updating
the simplex table (44):

a) for $p$-th (pivot) row
$$\eqalignno{
\overline \alpha_{pq} &= {1 \over \alpha_{pq}} & (47) \cr
\overline \alpha_{pj} &= - {\alpha_{pj} \over \alpha_{pq}} =
-\overline \alpha_{pq} \alpha_{pj}, \ j \neq q & (48) \cr
}
$$

b) for other rows $(i \neq p)$
$$\eqalignno{
\overline \alpha_{iq} &= {\alpha_{iq} \over \alpha_{pq}} =
\overline \alpha_{pq} \alpha_{iq} & (49) \cr
\overline \alpha_{ij} &= \alpha_{ij} -
{\alpha_{iq} \alpha_{pj} \over \alpha_{pq}} =
\alpha_{ij} - \overline \alpha_{iq} \alpha_{pj} =
\alpha_{ij} + \alpha_{iq} \overline \alpha_{pj}, \ j \neq q & (50)
}
$$

(Note that the considered transformation of the simplex table is one step of
Gauss---Jordan elimination procedure which is used for inverting non-singular
matrices.)
@end tex

@section Steepest edge technique

@tex
The general scheme of the primal simplex method (see Section 1.2) doesn't
answer to the question: what non-basic variable $(x_N)_q$ should be chosen on
each iteration? In fact, the theory requires only that the chosen non-basic
variable should have reduced cost $d_q$ which satisfies to the conditions
(23).

The obvious way (called \it textbook technique\rm) is to choose that
variable which has the largest (in absolute value) reduced cost, because
changing $(x_N)_j$ by one in the feasible direction involves improving
(decreasing) the objective function by $|d_j|$. However, should note that
actual change of $(x_N)_j$ depends on bound constraints for basic variables
and therefore it is unknown until the basic variable has been chosen.

To-day it is well known that the textbook technique is not efficient, because
in most practical cases it involves very slow convergence. Geometrically this
technique means that we choose an edge of the convex polyhedron (defined by
constraints of the LP problem) which has sharpest angle with the antigradient
$(-\nabla Z)$ of the objective function in \it the space of non-basic
variables\rm. However, this space is changed on each iteration of the simplex
method. Transformation applied to this space is not orthogonal, therefore the
angle which is sharpest in the current space may be not sharpest in the space
that corresponds to the adjacent set of non-basic variables.

In order to get rid of the asymmetry inherent to the textbook technique,
D. Goldfarb and J. K. Reid proposed to choose the edge of the polyhedron which
has the sharpest angle with the antigradient of the objective function in
\it the space of all variables\rm, because this space doesn't depend on the
current basis. The corresponding heuristic is called \it steepest edge
technique \rm [2]. Numerous experiments show that the steepest edge technuqe
allows significantly improving the efficiency of the simplex
@end tex
method @footnote{The efficiency of the steepest edge technique is
conditioned by that it prevents spiral-like movement through vertices of the
polyhedron "stretching out" the trajectory along the antigradient of the
objective function.}.

@tex
Let $x^0 = (x_B, x_N) = [(x_B)_1, \dots, (x_B)_m; (x_N)_1, \dots, (x_N)_n]$
is a vertex of the polyhedron (in the space of all variables) which
corresponds to the current basis solution. Let also the non-basic variable
$(x_N)_j$ has increased by one, but all other non-basic variables have not
been changed. Then the displaced point is
$x^j = [(x_B)_1+\alpha_{1j}, \dots, (x_B)_m+\alpha_{mj}; (x_N)_1, \dots,
(x_N)_{j-1}, (x_N)_j+1, (x_N)_{j+1}, \dots, (x_N)_n]$, where $\alpha_{1j},
\dots, \alpha_{mj}$ are influence coefficients of $j$-th column of the matrix
$\widetilde{A}$ (see (17)).

It is understood that the vector
$$\Delta x^j = x^j - x^0 = (\alpha_{1j}, \dots, \alpha_{mj}; 0, \dots,
0, 1, 0, \dots, 0) \eqno (51)$$
defines the direction along the edge of the polyhedron which corresponds to
the non-basic variable $(x_N)_j$.

We are interested in the angle between the direction $\Delta x_j$ and the
gradient $\nabla Z$ which is
$$\cos(\Delta x_j \hat \nabla Z) = \cos \varphi^j =
{(\Delta x^j)^T \nabla Z \over ||\Delta x^j|| ||\nabla Z||}. \eqno (52)$$

We know that $Z = c^T x = (c_B)^T x_B + (c_N)^T x_N$ and
$\nabla Z = c = (c_B, c_N).$ Therefore
$$(\Delta x^j)^T = \sum_{i=1}^m \alpha_{ij}(c_B)_i + (c_N)_j =
\widetilde{A}_j^T c_B = (c_N)_j, \eqno (53)$$
where $\widetilde{A}_j = (\alpha_{1j}, \dots, \alpha_{mj})$ is $j$-th column
of the matrix $\widetilde{A}$. However, from (17) it follows that
$\widetilde{A}_j = - B^{-1} N$, hence
$$(\Delta x^j)^T \nabla Z = (c_N)_j - N_j^T B^{-T} c_B = d_j, \eqno (54)$$
where $d_j$ is the reduced cost of non-basic variable $(x_N)_j$
(cf. (16)).

Substituting (54) into (52) we finally have
$$\eqalignno{
\cos \varphi^j &= {d_j \over ||\Delta x^j|| ||\nabla Z||} & (55) \cr
d_j &= (c_N)_j - N_j^T B^{-T} c_B & (56) \cr
||\Delta x^j|| &= \left ( 1+ \sum_{i=1}^m \alpha_{ij}^2 \right )^{1/2} =
\left ( 1 + \widetilde{A}_j^T \widetilde{A}_j \right )^{1/2} & (57) \cr
||\nabla Z|| &= \left ( 1 + c^T c\right )^{1/2} & (58) \cr
}
$$

Thus, in the steepest edge technique it is proposed to choose the non-basic
variable $(x_N)_q$ with largest (in absolute value) $\cos \varphi^j$ (instead
$d^j$ as in case of the textbook technique), because the corresponding
movement direction has sharpest angle with the antigradient of the objective
function. Should note that in any case the sign of $d_j$ should satisfy to
the conditions (23).

On practice we may disregard the term $||\nabla Z||$ in (55), because it is
constant and doesn't affect on the choice of non-basic variable.

For the sake of convenience let's introduce the quantities
$$\gamma_j = ||\Delta x^j||^2 = 1 + \sum_i \alpha_{ij}^2 =
1 + \widetilde{A}_j^T \widetilde{A}_j, \ j = 1, \dots, n. \eqno (59)$$
Then in order to exploit the steepest edge technique on the step 3 of the
primal simplex method (see Section 1.2) we should choose non-basic variable
using \it scaled reduced costs \rm
$$d'_j = {1 \over \sqrt{\gamma_j}} d_j, \ j = 1, \dots, n. \eqno (60)$$

It is important to note that the matrix $\widetilde{A}$ is not available
explicitly in the case of the revised simplex method that hinders from
computing the quantities $\gamma_j$ directly using the formula (59). Although
theoretically it is possible to compute all columns $\widetilde{A}_j$,
practically it would be extermely inefficient, because computation of one
column requires one FTRAN. That's why D. Goldfarb and J. K. Reid proposed
efficient formulae for \it updating \rm the quantities $\gamma_j$ for the
adjacent basis assuming that they are known for the current basis. These
formulae can be easily derived using the explicit formulae for updating the
simplex table (see Section 1.5).

At first let's consider updating the quantity $\gamma_q$ for the pivot
column ($j = q$):
$$\eqalign{
\overline \gamma_q &= 1 + \sum_i \overline \alpha_{iq}^2 =
1 + \sum_{i \neq p} \overline \alpha_{iq}^2 + \overline \alpha_{pq}^2 =
1 + \sum_{i \neq p} {\alpha_{iq}^2 \over \alpha_{pq}^2} +
{1 \over \alpha_{pq}^2} = \cr
&= 1 + \left ( \sum_i {\alpha_{iq}^2 \over \alpha_{pq}^2 } -1 \right ) +
{1 \over \alpha_{pq}^2} =
{1 \over \alpha_{pq}^2} \left ( 1 + \sum_i \alpha_{iq}^2 \right ) =
{\gamma_q \over \alpha_{pq}^2}. \cr
}
$$

So we have:
$$ \overline \gamma_q = {\gamma_q \over \alpha_{pq}^2} =
{1 \over \alpha_{pq}^2} \left ( 1 + \sum_i \alpha_{iq}^2 \right ) =
{1 \over \alpha_{pq}^2} (1 + \widetilde{A}_q^T \widetilde{A}_q). \eqno (61)$$

Now let's consider updating the quantities $\gamma_j$ for other columns
($j \neq q$):
$$\eqalign{
\overline \gamma_j &= 1 + \sum_i \overline \alpha_{ij}^2 =
1 + \sum_{i \neq p} \overline \alpha_{ij}^2 + \overline \alpha_{pj}^2 =
1 + \sum_{i \neq p} \left ( \alpha_{ij} - {\alpha_{iq} \alpha_{pj} \over
\alpha_{pq}} \right )^2 + {\alpha_{pj}^2 \over \alpha_{pq}^2} = \cr
&= 1 + \left [ \sum_i \left ( \alpha_{ij} -
{\alpha_{iq} \alpha_{pj} \over \alpha_{pq}} \right )^2 -
\left ( \alpha_{pj} - {\alpha_{pq} \alpha_{pj} \over \alpha_{pq}} \right )^2
\right ] + {\alpha_{pj}^2 \over \alpha_{pq}^2} = \cr
&= 1 + \sum_i \left ( \alpha_{ij} -
{\alpha_{iq} \alpha_{pj} \over \alpha_{pq}} \right )^2 +
{\alpha_{pj}^2 \over \alpha_{pq}^2} =
1 + \sum_i \alpha_{ij}^2 -
2 \sum_i {\alpha_{ij} \alpha_{iq} \alpha_{pj} \over \alpha_{pq}} +
\sum_i {\alpha_{iq}^2 \alpha_{pj}^2 \over \alpha_{pq}^2} +
{\alpha_{pj}^2 \over \alpha_{pq}^2} = \cr
&= \gamma_j + {\alpha_{pj}^2 \over \alpha_{pq}^2}
\left( 1 + \sum_i \alpha_{iq}^2 \right )
-2 {\alpha_{pj} \over \alpha_{pq}} \sum_i \alpha_{ij} \alpha_{iq} =
\gamma_j + \alpha_{pj}^2 \overline \gamma_q -
2 {\alpha_{pj} \over \alpha_{pq}} \sum_i \alpha_{ij} \alpha_{iq}. \cr
}
$$

Since $\sum_i \alpha_{ij} \alpha_{iq} = \widetilde{A}_j^T \widetilde{A}_q$ and
$\widetilde{A}_j = - B^{-1} N_j$, we have:
$$\overline \gamma_j = \gamma_j + \alpha_{pj}^2 \overline \gamma_q +
2 {\alpha_{pj} \over \alpha_{pq}} N_j^T B^{-T} \widetilde{A}_q, \ j \neq q.
\eqno (62)$$

It is seen that the updating formula (62) requires two additional BTRANs: the
first is needed for computing elements $\alpha_{pj}$ of $p$-th (pivot) row of
the matrix $\widetilde{A}$, and the second is needed for computing the vector
$B^{-T} \widetilde{A}_q$.

The steepest edge technique can be aslo applied to the dual simplex method.

First of all we may note that the choice of basic variable in the dual simplex
method is based on \it residuals \rm
$$ r_i = \left \{ \matrix {
(l_B)_i - \beta_i, \hfill & if \ \beta_i < (l_B)_i \hfill \cr
\beta_i - (u_B)_i, \hfill & if \ \beta_i > (u_B)_i \hfill \cr
} \right . \eqno (63)
$$
where $\beta_i$ is the current value of basic variable $(x_B)_i$,
$(l_B)_i$ and $(u_B)_i$ are, respectively, lower and upper bounds of $(x_B)_i$.

From the linear programming theory it is known that in the dual simplex method
the residuals $r_i$ play the same role as the reduced costs $d_j$ in the primal
simplex method. And so far as the dual simplex method uses the transposed
simplex table (33), we may expect that for choosing basic variable the
following \it scaled residuals \rm
$$r'_i = {1 \over \sqrt{\delta_i}} r_i \eqno (64)$$
should be used instead the original residuals (63), where quantities
$$\delta_i = 1 + \sum_j \alpha_{ij}^2, \ i = 1, \dots, m \eqno (65)$$
are similar to $\gamma_j$ (cf. (59)).

Again the formulae for updating the quantities $\delta_i$ can be derived from
the explicit formulae for updating the simplex table (see Section 1.5).

So for the pivot row ($i = p$) we have
$$\eqalign{
\overline \delta_p &= 1 + \sum_j \overline \alpha_{pj}^2 =
1 + \sum_{j \neq q} \overline \alpha_{pj}^2 + \overline \alpha_{pq}^2 =
1 + \sum_{j \neq q} {\alpha_{pj}^2 \over \alpha_{pq}^2} +
{1 \over \alpha_{pq}^2} = \cr
&= 1 + \left ( \sum_j {\alpha_{pj}^2 \over \alpha_{pq}^2 } -1 \right ) +
{1 \over \alpha_{pq}^2} =
{1 \over \alpha_{pq}^2} \left ( 1 + \sum_j \alpha_{pj}^2 \right ) =
{\delta_p \over \alpha_{pq}^2}. \cr
}
$$

Therefore
$$ \overline \delta_p = {\delta_p \over \alpha_{pq}^2} =
{1 \over \alpha_{pq}^2} \left ( 1 + \sum_j \alpha_{pj}^2 \right ) =
{1 \over \alpha_{pq}^2} (1 + \alpha_p^T \alpha_p). \eqno (66)$$
where $\alpha_p$ is $p$-th row of the matrix $\widetilde{A}$.

Now let's consider updating quantities $\delta_i$ for other rows ($i \neq p$):
$$\eqalign{
\overline \delta_i &= 1 + \sum_j \overline \alpha_{ij}^2 =
1 + \sum_{j \neq q} \overline \alpha_{ij}^2 + \overline \alpha_{iq}^2 =
1 + \sum_{j \neq q} \left ( \alpha_{ij} - {\alpha_{iq} \alpha_{pj} \over
\alpha_{pq}} \right )^2 + {\alpha_{iq}^2 \over \alpha_{pq}^2} = \cr
&= 1 + \left [ \sum_j \left ( \alpha_{ij} -
{\alpha_{iq} \alpha_{pj} \over \alpha_{pq}} \right )^2 -
\left ( \alpha_{iq} - {\alpha_{iq} \alpha_{pq} \over \alpha_{pq}} \right )^2
\right ] + {\alpha_{iq}^2 \over \alpha_{pq}^2} = \cr
&= 1 + \sum_j \left ( \alpha_{ij} -
{\alpha_{iq} \alpha_{pj} \over \alpha_{pq}} \right )^2 +
{\alpha_{iq}^2 \over \alpha_{pq}^2} =
1 + \sum_j \alpha_{ij}^2 -
2 \sum_j {\alpha_{ij} \alpha_{iq} \alpha_{pj} \over \alpha_{pq}} +
\sum_j {\alpha_{iq}^2 \alpha_{pj}^2 \over \alpha_{pq}^2} +
{\alpha_{iq}^2 \over \alpha_{pq}^2} = \cr
&= \delta_i + {\alpha_{iq}^2 \over \alpha_{pq}^2}
\left( 1 + \sum_j \alpha_{pj}^2 \right )
-2 {\alpha_{iq} \over \alpha_{pq}} \sum_j \alpha_{ij} \alpha_{pj} =
\delta_i + \alpha_{iq}^2 \overline \delta_p -
2 {\alpha_{iq} \over \alpha_{pq}} \sum_j \alpha_{ij} \alpha_{pj}. \cr
}
$$

Since $\sum_j \alpha_{ij} \alpha_{pj} = \alpha_i \alpha_p^T$, where
$\alpha_i$ and $\alpha_p$ are, respectively, $i$-th and $p$-th (pivot) rows of
the matrix $\widetilde{A}$, and $\alpha_i = e_i^T \widetilde{A} = - e_i^T
B^{-1} N$, where $e_i$ is the unity vector (see (41)), therefore $\alpha_i
\alpha_p^T = -e_i^T (B^{-1} N \alpha_p^T) = - (B^{-1} N \alpha_p^T)_i$. Thus,
finally we have:
$$\overline \delta_i = \delta_i + \alpha_{iq}^2 \overline \delta_p +
2 {\alpha_{iq} \over \alpha_{pq}} (B^{-1} N \alpha_p^T)_i. \eqno (67)$$

It is seen that the updating formula (67) requires two additional FTRANs: the
first is needed for computing elements $\alpha_{iq}$ of $q$-th (pivot) column
of the matrix $\widetilde{A}$, and the second is needed for computing the
vector $B^{-1} N \alpha_p^T$.
@end tex

@section Advanced ratio test based on Harris technique

@tex
Considering the step 5 of the primal simplex method (see Section 1.2) we may
note that if \it several \rm basic variables reach their bounds \it at the
same time\rm, the choice of basic variable becomes ambiguous. This phenomenon
happens mainly in the case of \it degenerative \rm basis solution, i.e. when
current values of some basic variables are equal to their bounds. This
ambiguity could be used in order to choose that non-basic variable $(x_B)_p$
which has more appropriate coefficient $\alpha_{pq}$ at the chosen non-basic
variable $(x_N)_q$, because as it seen from the explicit formulae for updating
the simplex table (see Section 1.5) this coefficient is used further as the
pivot and therefore it affects on numerical stability. However, on practice
in the case of degenerative basis solution current values of basic variables
may slightly differ from thir bounds due to round-off errors. This may cause
choosing basic variable which has unacceptably small (in absolute value)
coefficint $\alpha_{pq}$. For example, let there are two basic variables with
lower bounds:
$$\eqalign{
(x_B)_1 &\geq 2 \cr
(x_B)_2 &\geq 3 \cr
}
$$
whose current values (computed with finite precision) are
$$\eqalign{
\beta_1 &= 2.00000 \cr
\beta_2 &= 3.00001 \cr
}
$$
and the fragment of the current simplex table that corresponds to the chosen
non-basic variable is the following:
$$\eqalign{
(x_B)_1 &= \dots - 0.00001 (x_N)_q + \dots \cr
(x_B)_2 &= \dots - 5.00000 (x_N)_q + \dots \cr
}
$$
Let $(x_N)_q$ is increasing. Following the textbook ratio test we should
choose the basic variable $(x_B)_1$. On the other hand it is seen that the
basic variable $(x_B)_2$ is also on its lower bound, where small error is
caused by possible round-off errors. Therefore if we would consider $\beta_1$
and $\beta_2$ as approximate quantities, but not an exact ones, we could
choose the basic variable $(x_B)_2$ that is more desirable from the point of
view of numerical stability.

P. Harris noted in her paper [3] that since all computed quantities are
approximate and therefore in the case of degenerative basis solution current
values of basic variables can slightly violate their bounds, we would exploit
this in order to make more acceptable choice of basic variable. In order to
achieve this purpose she proposed to choose basic variable using two-pass
technique in the following way.

On the first pass we relax bounds of basic variables by small tolerance
$\varepsilon > 0$ and determinte the following quantity (cf. the step 5 of the
primal simplex method):
$$\widetilde{\theta} = \min[\min_i \widetilde{\theta}_i,
(u_N)_q - (l_N)_q], \eqno (68)$$
where $\widetilde{\theta}_i$ are computed using relaxed bounds:

a) if $(x_N)_q$ is increasing, i.e. if $d_q < 0$
$$
\widetilde{\theta}_i = \left \{ \matrix {
\infty, \hfill & \hfill \alpha_{iq} = 0\cr
\{[(u_B)_i + \varepsilon] - \beta_i\} / \alpha_{iq}, \hfill
& \hfill \alpha_{iq} > 0\cr
\{[(l_B)_i - \varepsilon] - \beta_i\} / \alpha_{iq}, \hfill
& \hfill \alpha_{iq} < 0
} \right . \eqno (69)
$$

b) if $(x_N)_q$ is decreasing, i.e. if $d_q > 0$
$$
\widetilde{\theta}_i = \left \{ \matrix {
\infty, \hfill & \hfill \alpha_{iq} = 0\cr
\{\beta_i - [(l_B)_i - \varepsilon]\} / \alpha_{iq}, \hfill
& \hfill \alpha_{iq} > 0\cr
\{\beta_i - [(u_B)_i + \varepsilon]\} / \alpha_{iq}, \hfill
& \hfill \alpha_{iq} < 0
} \right . \eqno (70)
$$

It is clear that the quantity $\widetilde{\theta}$ is the largest change of the
non-basic variable $(x_N)_q$ on which all basic variables still remain within
their relaxed bounds.

On the second pass we compute quantities $\theta_i$ using the formulae (25) and
(26) for the original (not relaxed) bounds of basic variables and choose the
basic variable $(x_B)_p$ for which
$$\eqalignno{
\theta_p &\leq \widetilde{\theta} & (71) \cr
|\alpha_{pq}| &= \max_i |\alpha_{iq}| & (72) \cr
}
$$
The condition (71) guarantees that all basic variables remain within their
relaxed bounds and the condition (72) allows providing better numerical
stability.

So if we apply this two-pass technique to the example considered above with,
say, $\varepsilon = 10^{-4}$, we choose more acceptable basic variable
$(x_B)_2$, and in the adjacent basis the value of other basic variable
$(x_B)_1$ is equal to $2.00000 - 0.00001 / 5.00000 = 1.999998$. Although the
basic variable $(x_B)_1$ violates its lower bound, this violation is so small
that it vanishes after rounding the computed value to 6 decimal places.

It is understood that Harris two-pass technique can be also applied to the
dual simplex method in the same way for choosing non-basic variable which has
to enter the basis (see the step 5 in Section 1.3).

In her paper P. Harris points out that if her two-pass ratio test chooses a
basic variable that differs from that one which would be chosen using the
textbook ratio test, it provides larger value of $\theta_p$ (that involves
faster convergence and sometimes helps to prevent cycling in cases of
degenerative problems) and better value of the pivot coefficient $\alpha_{pq}$
(that involves better numerical stability).
@end tex

@section Scaling LP problem

@tex
In the linear programming scaling means that we replace the original LP
problem (1) by some equivalent \it scaled \rm LP problem.

For scaling LP problem it is necessary to find some scaling matrices $R$ and
$S$ (which are diagonal matrices with positive elements) in order that the
scaled matrix of constraint coefficients
$$\widehat{A}' = R \widehat{A} S \eqno (73)$$
would have better numerical properties than the original matrix $\widehat{A}$.

Let we already have some appropriate scaling matrices $R$ and $S$. Using (73)
we can transform the original LP problem (1) to the following equivalent
scaled LP problem:
$$\eqalign{
Z &= (S \widehat{c})^T (S^{-1} x_S) + c_0 \rightarrow \min \ (\max) \cr
(R x_R) &= (R \widehat{A} S) (S^{-1} x_S) \cr
(R l_R) &\leq (R x_R) \leq (R u_R) \cr
(S^{-1} l_S) &\leq (S^{-1} x_S) \leq (S^{-1} u_S) \cr
} \eqno (74)
$$
Introducing \it scaled \rm components we can express the scaled LP problem
(74) in the same formulation as the original non-scaled problem (1):
$$\eqalign{
Z &= (\widehat{c}')^T x_S' + c_0 \rightarrow \min (\max) \cr
x_R' &= \widehat{A}' x_S' \cr
l_R' &\leq x_R' \leq u_R' \cr
l_S' &\leq x_S' \leq u_S' \cr
} \eqno (75)
$$
where
$$\eqalign{
\widehat{A}' &= R \widehat{A} S \cr
\widehat{c}' &= S \widehat{c} \cr
x_R' &= R x_R, \ l_R' = R l_R, \ u_R' = R u_R \cr
x_S' &= S^{-1} x_S, \ l_S' = S^{-1} l_S, \ u_S' = S^{-1} u_S \cr
} \eqno (76)
$$

Then we can express the scaled LP problem (75) in the practical form (5)---(7)
and solve it using the simplex method. After the scaled solution has been
obtained we can recover the original non-scaled solution using the formulae
(76).
@end tex

@chapter Simplex Method Routines

@section Structure of common block

Most of GLPK routines implementing components of the revised simplex method
use some common information which is organized in the form of the following
structure:

@tpindex{RSM}
@example
      typedef struct RSM RSM;
      struct RSM
      @{     int m;
            int n;
            int type[1+m+n];
            double lb[1+m+n];
            double ub[1+m+n];
            MAT A[m:m+n];
            int posx[1+m+n];
            int indb[1+m];
            int indn[1+n];
            int tagn[1+n];
            PFI *pfi;
            RFI *rfi;
            int iter;
      @};
@end example

@noindent
where:

@table @code
@item m
number of auxiliary variables = number of basic variables = number of rows in
the simplex table (except row of the objective function);
@item n
number of structural variables = number of non-basic variables = number of
columns in the simplex table;
@item type
array of types of variables. Location @code{type[0]} is not used. Location
@code{type[k]} specifies the type of variable
@tex
$x_k, 1 \leq k \leq m+n$:
@end tex
@table @code
@item 'F'
@tex
free (unbounded) variable ($-\infty < x_k < +\infty$);
@end tex
@item 'L'
@tex
variable with lower bound ($l_k \leq x_k < +\infty$);
@end tex
@item 'U'
@tex
variable with upper bound ($-\infty < x_k \leq u_k$);
@end tex
@item 'D'
@tex
double-bounded variable ($l_k \leq x_k \leq u_k$);
@end tex
@item 'S'
@tex
fixed variable ($l_k = x_k = u_k$);
@end tex
@end table
@item lb
array of lower bounds of variables. Location @code{lb[0]} is not used.
Location @code{lb[k]} specifies the lower bound (or the fixed value) of
variable
@tex
$x_k, 1 \leq k \leq m+n$. If the variable $x_k$
@end tex
has no lower bound, @code{lb[k]} is equal to zero;
@item ub
array of upper bounds of variables. Location @code{ub[0]} is not used.
Location @code{ub[k]} specifies the upper bound of variable
@tex
$x_k, 1 \leq k \leq m+n$. If the variable $x_k$
@end tex
has no upper bound, @code{ub[k]} is equal to zero. If the variable
@tex
$x_k$
@end tex
is of fixed type, @code{ub[k]} is equal to @code{lb[k]}.
@item A
@tex
expanded matrix of constraint coefficients (3). This matrix has $m$ rows and
$m+n$ columns. The first $m$ columns correspond to auxiliary variables $x_R$
and form the unity matrix. The last $n$ columns correspond to structural
variables $x_S$ and form the original matrix of constraint coefficients
$\widehat{A}$ with opposite sign;
@end tex
@item posx
array of positions of variables in the current basis solution. Location
@code{posx[0]} is not used. If @code{posx[k]}
@tex
$= +i > 0$, the variable $x_k$ ($1 \leq k \leq m+n$) is basic variable
$(x_B)_i$.
@end tex
If @code{posx[k]}
@tex
$= -j < 0$, the variable $x_k$ is non-basic variable $(x_N)_j$.
@end tex
@item indb
array of original positions of basic variables. Location @code{indb[0]} is not
used. The case @code{indb[i]}
@tex
$= k$ means that the basic variable $(x_B)_i$ ($1 \leq i \leq m$) is the
original variable $x_k$, i.e.
@end tex
@code{posx[k]}
@tex
$= +i$;
@end tex
@item indn
array of original positions of non-basic variables. Location @code{indn[0]} is
not used. The case @code{indn[j]}
@tex
$= k$ means that the non-basic variable $(x_N)_j$ ($1 \leq j \leq n$) is the
original variable $x_k$, i.e.
@end tex
@code{posx[k]}
@tex
$= -j$;
@end tex
@item tagn
array of tags of non-basic variables. Location @code{tagn[0]} is not used.
Location @code{tagn[j]} specifies which subset (18)
@tex
the non-basic variable $(x_N)_j$ ($1 \leq j \leq n$) belongs to:
@end tex
@table @code
@item 'L'
@tex
non-basic variable on its lower bound, $(x_N)_j \in x_L$;
@end tex
@item 'U'
@tex
non-basic variable on its upper bound, $(x_N)_j \in x_U$;
@end tex
@item 'F'
@tex
non-basic free variable, $(x_N)_j \in x_F$;
@end tex
@item 'S'
@tex
non-basic fixed variable, $(x_N)_j \in x_S$;
@end tex
@end table
@item pfi
if PFI (Product Form of the Inverse) is used to represent the current
basis matrix @i{B}, @code{pfi} points to PFI (see [1]). Otherwise the
@code{pfi} field contains @code{NULL};
@item rfi
if RFI (Reid's Form of the Inverse) is used to represent the current basis
matrix @i{B}, @code{rfi} points to RFI (see[1]). Otherwise the @code{rfi}
field contains @code{NULL};
@item iter
iteration count. This value is increased by one each time when the current
basis is replaced by the adjacent one.
@end table

@i{Remarks.}

@enumerate
@item
It is implicitly assumed that the united vector (2) contains variables of the
LP problem (1) in the following order
@tex
$x = [(x_R)_1, \dots (x_R)_m, (x_S)_1, \dots, (x_S)_n]$, where $(x_R)_i$ are
auxiliary variables (that correspond to the equality constraints) and
$(x_S)_j$ are structural variables. The same ordering is assumed for columns
of the expanded matrix $A$.
@end tex
@item
It is implicitly assumed that the order of columns in the current basis
@tex
matrix $B$ is determined by the order of variables in the vector $x_B$, i.e.
@end tex
by the array @code{indb}.
@item
It is implicitly assumed that all other arrays used by GLPK routines and
which contain additional information related to basic or non-basic variables
have the same order of elements as defined by the array @code{posx},
@code{indb}, and @code{indn}.
@end enumerate

@section Operations on basis matrix

This section describes routines which are intended for performing operations
on the basis matrix (see also Sections 1.1 and 1.4).

These routines are an interface to partucular routines which actually
perform the corresponding operations (see chapters GLPPFI and GLPRFI in [1]).

@subsection @code{invert_b} --- rebuild representation of the basis matrix
@fnindex{invert_b}

@subsubheading Synopsis

@example
#include "glprsm.h"
int invert_b(RSM *rsm);
@end example

@subsubheading Description

The @code{invert_b} routine reinverts the basis matrix @i{B}, i.e. it rebuilds
anew some representation of the basis matrix.

This operation can be used in the following three cases:

a) if it is necessary to rebuild the representation for some initial basis
matrix;

b) if the representation of the current basis matrix has become too large or
inaccurate;

c) if the basis matrix has been completely changed.

The @code{invert_b} routine assumes that the array @code{rsm.indb} specifies
what columns of the expanded matrix @i{A} belong to the basis matrix @i{B}.

@subsubheading Returns

If the operation was successful, the @code{invert_b} routine returns zero.
Otherwise the routine returns non-zero. The latter case means that the basis
matrix is numerically singular or ill-conditioned. For further information
see descriptions of particular routines that perform this operation [1].

@subsection @code{ftran} --- perform forward transformation
@fnindex{ftran}

@subsubheading Synopsis

@example
#include "glprsm.h"
void ftran(RSM *rsm, double u[], int save);
@end example

@subsubheading Description

The @code{ftran} routine performs forward transformation (FTRAN) of the
vector @i{u} using some representation of the current basis matrix.

@tex
This operation means solving the system $B u' = u$, where $B$ is the current
basis matrix, $u$ is the given vector which should be transformed, $u'$ is
the resultant vector.
@end tex

On entry the array @code{u} should contain elements of the vector @i{u} in
locations @code{u[1]}, @dots{}, @code{u[m]}, where @i{m} is order of the matrix
@i{B}. On exit this array contains elements of the vector
@tex
$u'$
@end tex
in the same locations.

The parameter @code{save} is a flag. If this flag is set, it means that the
@tex
vector $u$ is the column of non-basic variable $(x_N)_q$ which has been
chosen to enter the basis (i.e. $u = N_q$; see the step 6 of primal and dual
simplex methods in Sections 1.2 and 1.3).
@end tex
In this case @code{ftran} routine saves some internal information which will
be used further by the @code{update_b} routine (see Subsection 2.2.4) in
order to update the representation of the basis matrix for the adjacent
basis. It is assumed that the calling program should perform at least one call
to the @code{ftran} routine with the @code{save} flag set before subsequent
call to the @code{update_b} routine.

@subsection @code{btran} --- perform backward transformation
@fnindex{btran}

@subsubheading Synopsis

@example
#include "glprsm.h"
void btran(RSM *rsm, double u[]);
@end example

@subsubheading Description

The @code{btran} routine performs backward transformation (BTRAN) of the
vector @i{u} using some representation of the current basis matrix.

@tex
This operation means solving the system $B^T u' = u$, where $B$ is the current
basis matrix, $u$ is the given vector which should be transformed, $u'$ is
the resultant vector.
@end tex

On entry the array @code{u} should contain elements of the vector @i{u} in
locations @code{u[1]}, @dots{}, @code{u[m]}, where @i{m} is order of the matrix
@i{B}. On exit this array contains elements of the vector
@tex
$u'$
@end tex
in the same locations.

@subsection @code{update_b} --- update representation of the basis matrix
@fnindex{update_b}

@subsubheading Synopsis

@example
#include "glprsm.h"
int update_b(RSM *rsm, int p);
@end example

@subsubheading Description

@tex
Let $p$-th column of the current basis matrix $B$ has been replaced by some
other column that gives the new (adjacent) basis matrix $\overline B$ (see
the step 6 of primal and dual simplex methods in Sections 1.2 and 1.3).
@end tex
The @code{update_b} routine updates some representation of the basis matrix
@tex
$B$ in order that the updated representation corresponds to the matrix
$\overline B$.
@end tex

The new @i{p}-th column of the basis matrix is passed implcitly to the
@code{update_b} routine. It is assumed that this column has been saved before
by the @code{ftran} routine (see Subsection 2.2.2).

@subsubheading Returns

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

@table @asis
@item 0
The representation has been successfully updated;
@item 1
The representation has become inaccurate;
@item 2
The representation has become too large.
@end table

If the returned code is non-zero, the calling program should rebuild the
representation anewby means of the @code{invert_b} routine (see Subsection
2.2.1).

@section Operations on simplex table

This section describes routines which are intended for performing operations
on the simplex table (see also Sections 1.1 and 1.4).

Implicit representation of the simplex table is used.

@subsection @code{check_rsm} --- check common block for correctness
@fnindex{check_rsm}

@subsubheading Synopsis

@example
#include "glprsm.h"
void check_rsm(RSM *rsm)
@end example

@subsubheading Description

The @code{check_rsm} routine checks the revised simplex method common block,
which @code{rsm} points to, for correctness. In case of error the routine
displays an appropriate error message and abnormally terminates the program.

Note that the @code{check_rsm} routine doesn't check the expanded constraint
matrix @i{A}, because the corresponding operation is extremely inefficient.
This matrix can be checked additionally by means of the @code{check_mat}
routine (see [1]).

The @code{check_rsm} routine is intended for debugging purposes.

@subsection @code{eval_xn} --- determine value of non-basic variable
@fnindex{eval_xn}

@subsubheading Synopsis

@example
#include "glprsm.h"
double eval_xn(RSM *rsm, int j);
@end example

@subsubheading Returns

The @code{eval_xn} routine returns the value of non-basic variable
@tex
$(x_N)_j$, $1 \leq j \leq n$,
@end tex
that corresponds to the current basis solution.

The returned value is determined by the formula (20) (see Section 1.1).

@subsection @code{eval_bbar} --- compute values of basic variables
@fnindex{eval_bbar}

@subsubheading Synopsis

@example
#include "glprsm.h"
void eval_bbar(RSM *rsm, double bbar[]);
@end example

@subsubheading Description

The @code{eval_bbar} routine computes values of basic variables
@tex
$x_B = \beta = (\beta_1, \dots, \beta_m)$ that correspond to the current basis
solution and stores $\beta_1, \dots, \beta_m$
@end tex
into locations @code{bbar[1]}, @dots{}, @code{bbar[m]} respectively.

@tex
The vector $\beta$ is computed using the formula (38) (see Section 1.4).
@end tex

@subsection @code{eval_pi} --- compute simplex multipliers
@fnindex{eval_pi}

@subsubheading Synopsis

@example
#include "glprsm.h"
void eval_pi(RSM *rsm, double c[], double pi[]);
@end example

@subsubheading Description

The @code{eval_pi} routine computes simplex multipliers
@tex
$\pi = (\pi_1, \dots, \pi_m)$, i.e. Lagrange multipliers for the equality
constraints (6), that correspond to the current basis and stores $\pi_1, \dots,
\pi_m$ into
@end tex
locations @code{pi[1]}, @dots{}, @code{pi[m]} respectively.

On entry the array @code{c} should contain the expanded vector of coefficients
of the objective function @i{c} (see (4)) in locations @code{c[1]}, @dots{},
@code{c[m+n]}. The array @code{c} is not changed on exit.

@tex
The vector $\pi$ is computed using the formula (39) (see Section 1.4).
@end tex

@subsection @code{eval_cbar} --- compute reduced costs of non-basic variables
@fnindex{eval_cbar}

@subsubheading Synopsis

@example
#include "glprsm.h"
void eval_cbar(RSM *rsm, double c[], double pi[], double cbar[]);
@end example

@subsubheading Description

The @code{eval_cbar} routine computes reduced costs
@tex
$d = (d_1, \dots, d_n)$ of non-basic variables that correspond to the current
basis solution and stores $d_1, \dots, d_n$ into
@end tex
locations @code{cbar[1]}, @dots{}, @code{cbar[n]} respectively.

On entry the array @code{c} should contain the expanded vector of coefficients
of the objective function @i{c} (see (4)) in locations @code{c[1]}, @dots{},
@code{c[m+n]}. The array @code{c} is not changed on exit.

On entry the array @code{pi} should contain the vector of simplex multipliers
@tex
$\pi$
@end tex
computed by means of the @code{eval_pi} routine (see Subsection 2.3.4) for the
same vector @i{c}. The array @code{pi} is not changed on exit.

The vector @i{d} is computed using the formula (40) (see Section 1.4).

@subsection @code{check_rr} --- check relative residual
@fnindex{check_rr}

@subsubheading Synopsis

@example
#include "glprsm.h"
int check_rr(double x, double x0, double tol);
@end example

@subsubheading Description

The @code{check_rr} routine checks relative residual between
@tex
the computed quantity $x$ and the given quantity $x_0$ using the relative
tolerance $tol > 0$.
@end tex

@subsubheading Returns

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

@table @asis
@item --2
@tex
if $x < x_0 - \varepsilon$;
@end tex
@item --1
@tex
if $x_0 - \varepsilon \leq x < x0$;
@end tex
@item 0
@tex
if $x = x_0$;
@end tex
@item +1
@tex
if $x_0 < x \leq x_0 + \varepsilon$;
@end tex
@item +2
@tex
if $x > x_0 + \varepsilon$;
@end tex
@end table

where
@tex
$\varepsilon = tol \cdot \max(1, |x_0|)$.
@end tex

@subsection @code{check_bbar} --- check basis solution for primal feasibility
@fnindex{check_bbar}

@subsubheading Synopsis

@example
#include "glprsm.h"
int check_bbar(RSM *rsm, double bbar[], double tol);
@end example

@subsubheading Description

The @code{check_bbar} routine checks the given basis solution for primal
feasibility.

The array @code{bbar} should contain the given values of basic variables
@tex
$\beta = (\beta_1, \dots, \beta_m)$
@end tex
in locations @code{bbar[1]}, @dots{}, @code{bbar[m]} respectively.

The parameter @i{tol} > 0 is a relative tolerance.

@tex
In order to see if the given basis solution is primal feasible, the routine
checks the primal feasibility conditions (21) (see Section 1.1) which using
the relative tolerance are the following:
$$(l_B)_i - \varepsilon \leq \beta_i \leq (u_B)_i + \varepsilon,
\ i = 1, \dots, m,$$
where
$$
\varepsilon = \left \{
\matrix{
tol \cdot \max (1, |(l_B)_i|) & in\ case\ of\ lower\ bound \cr
tol \cdot \max (1, |(u_B)_i|) & in\ case\ of\ upper\ bound \cr
}
\right .
$$
@end tex

@subsubheading Returns

If the given basis solution is primal feasible (i.e. it satisfies to the
conditions above), the @code{check_bbar} routine returns zero. Otherwise the
routine returns non-zero.

@subsection @code{check_cbar} --- check basis solution for dual feasibility
@fnindex{check_cbar}

@subsubheading Synopsis

@example
#include "glprsm.h"
int check_cbar(RSM *rsm, double c[], double cbar[], double tol);
@end example

@subsubheading Description

The @code{check_cbar} routine checks the given basis solution for dual
feasibility.

The array @code{c} should contain the expanded vector @i{c} of coefficients of
the objective function (4) in locations @code{c[1]}, @dots{}, @code{c[m+n]}.

The array @code{cbar} should contain the given reduced costs
@tex
$d = (d_1, \dots, d_n)$ of non-basic variables
@end tex
in locations @code{cbar[1]}, @dots{}, @code{cbar[n]} respectively. It is
assumed that the reduced costs are computed using the vector @i{c} passed to
this routine.

@tex
The parameter $tol > 0$ is a relative tolerance.
@end tex

In order to see if the given basis solution is dual feasible, the routine
checks the dual feasibility conditions (22) (see Section 1.1) which using
the relative tolerance are the following:
@tex
$$\eqalign{
if \ (x_N)_j \in x_F &\ then \ -\varepsilon \leq d_j \leq +\varepsilon \cr
if \ (x_N)_j \in x_L &\ then \ d_j \geq -\varepsilon \cr
if \ (x_N)_j \in x_U &\ then \ d_j \leq +\varepsilon \cr
if \ (x_N)_j \in x_S &\ then \ -\infty < d_j < +\infty
}
$$
where
$$\varepsilon = tol \cdot \max(1, |(c_N)_j|)$$
(the absolute tolerance $\varepsilon$ reflects that the reduced cost of
non-basic variable $(x_N)_j$ is the difference $d_j = (c_N)_j - N_j^T \pi$ as
it follows from the formula (40) in Section 1.4).
@end tex

@subsubheading Returns

If the given basis solution is dual feasible (i.e. it satisfies to the
conditions above), the @code{check_cbar} routine returns zero. Otherwise the
routine returns non-zero.

@subsection @code{eval_col} --- compute column of the simplex table
@fnindex{eval_col}

@subsubheading Synopsis

@example
#include "glprsm.h"
void eval_col(RSM *rsm, double j, double aj[], int save);
@end example

@subsubheading Description

The @code{eval_col} routine computes @i{j}-th column of the simplex table
@tex
$\widetilde{A}_j = (\alpha_{1j}, \dots, \alpha_{mj})$, i.e. $j$-th column of
the matrix $\widetilde{A}$ (see (17), Section 1.1)
@end tex
and stores its elements into locations @code{aj[1]}, @dots{}, @code{aj[m]}
respectively.

The parameter @code{save} is a flag. If this flag is set, it means that the
@tex
column $\widetilde{A}_j$ is the column of non-basic variable $(x_N)_q$ which
has been chosen to enter the basis (i.e. $j = q$). This flag is passed to the
@end tex
@code{ftran} routine (see Section 2.2.2) which is called by the @code{eval_col}
routine in order to perform forward transformation.

@tex
The column $\widetilde{A}_j$ is computed using the formula (42) (see Section
1.4).
@end tex

@subsection @code{eval_zeta} --- compute row of the inverse
@fnindex{eval_zeta}

@subsubheading Synopsis

@example
#include "glprsm.h"
void eval_zeta(RSM *rsm, int i, double zeta[]);
@end example

@subsubheading Description

The @code{eval_zeta} routine computes
@tex
$i$-th row of the inverse $\zeta_i = (\zeta_{i1}, \dots, \zeta_{im})$, i.e.
$i$-th row of the matrix $B^{-1}$, where $B$ is the current basis matrix, and
@end tex
stores its elements into locations @code{zeta[1]}, @dots{}, @code{zeta[m]}.

@tex
The vector $\zeta_i$ is computed using the formula:
$$\zeta_i = B^{-T} e_i,$$
where $e_i$ is the unity vector (41).
@end tex

@subsection @code{eval_row} --- compute row of the simplex table
@fnindex{eval_row}

@subsubheading Synopsis

@example
#include "glprsm.h"
void eval_row(RSM *rsm, double zeta[], double ai[]);
@end example

@subsubheading Description

The @code{eval_row} routine computes
@tex
$i$-th row of the simplex table $\alpha_i = (\alpha_i1, \dots, \alpha_in)$,
i.e. $i$-th row of the matrix $\widetilde{A}$ (see (17), Section 1.1), and
@end tex
stores its elements into locations @code{ai[1]}, @dots{}, @code{ai[n]}
respectively.

The array @code{zeta} should contain
@tex
$i$-th row of the inverse $\zeta_i = (\zeta_{i1}, \dots, \zeta_{im})$, i.e.
$i$-th row of the matrix $B^{-1}$, where $B$ is the current basis matrix,
@end tex
computed by means of the @code{eval_zeta} routine (Subsection 2.3.11). This
array is not changed on exit.

@tex
The row $\alpha_i$ is computed using the formula (43) (see Section 1.4).
@end tex

@subsection @code{change_b} --- change basis
@fnindex{change_b}

@subsubheading Synopsis

@example
#include "glprsm.h"
int change_b(RSM *rsm, int p, int tagp, int q);
@end example

@subsubheading Description

The @code{change_b} routine changes the current basis replacing it by the
@tex
adjacent one. The routine takes the basic variable $(x_B)_p$
($1 \leq p \leq m$) out the set of basic variables $x_B$ and brings instead
it the non-basic variable $(x_N)_q$ ($1 \leq q \leq n$) into $x_B$.
Correspondingly, the basic variable $(x_B)_p$ replaces the non-basic variable
$(x_N)_q$ in the set of non-basic variables $x_N$.
@end tex

The parameter @code{tagp} specifies to what subset
@tex
$x_F$, $x_L$, $x_U$, or $x_S$ (see (18), Section 1.1) the basic variable
$(x_B)_p$ should be attributed after it has left the basis. The value of
@end tex
@code{tagp} has the same meaning as the field @code{rsm.tagn} (see Section
2.1) and should be compatible with the type of variable
@tex
$(x_B)_p$.

The special case $p < 0$ means that the current basis is not changed, but the
non-basic variable $(x_N)_q$ (which should be double-bounded variable) just
goes from its current bound to the opposite one.
@end tex
The parameter @code{tagp} is ignored in this special case.

The @code{change_b} routine also replaces
@tex
$p$-th column of the basis matrix $B$ by $q$-th column of the matrix $N$ and
updates the representation of $B$ by means of
@end tex
@code{update_b} routine (Section 2.2.4).
@tex
Note that new $p$-th column of $B$ is passed implcitly; it is assumed that this
column was saved before by
@end tex
the @code{eval_col} routine (Section 2.3.9). If the representation becomes too
long or inaccurate, the @code{change_b} routine automatically rebuilds it by
means of the @code{invert_b} routine (Section 2.2.1).

One call to the @code{change_b} routine is considered as one iteration of the
simplex method.

@subsubheading Returns

If the representation of new basis matrix was not rebuilt or if it was rebuilt
successfully, the @code{change_b} routine returns zero. Otherwise the routine
returns non-zero. In the latter case the calling program should not use the
representation until the basis will be corrected and the representation will
be rebuilt anew.

@section Primal steepest edge routines

This section describes routines which implement primal steepest edge
technique (see Section 1.6) and which are intended for using in conjunction
with primal simplex method routines (see Section 2.6).

@subsection @code{init_gvec} --- initialize the vector @math{@gamma{}}
@fnindex{init_gvec}

@subsubheading Synopsis

@example
#include "glprsm.h"
void init_gvec(RSM *rsm, double gvec[]);
@end example

@subsubheading Description

The @code{init_gvec} routine computes the vector @math{@gamma{}} (see (59),
Section 1.6) for the initial basis and stores its elements into locations
@code{gvec[1]}, @dots{}, @code{gvec[n]}.

@tex
Initial basis is a basis, where all auxiliary variables are basic and all
structural variables are non-basic. In this special case $B = I$ and
$N = \widehat{A}$, therefore $\alpha_{ij} = \widehat{a}_{ij}$, where
$\widehat{a}_{ij}$ are elements of the original constraint matrix
$\widehat{A}$, that allows using the formula (59) directly for computing the
initial vector $\gamma$.
@end tex

@subsection @code{update_gvec} --- update the vector @math{@gamma{}}
@fnindex{update_gvec}

@subsubheading Synopsis

@example
#include "glprsm.h"
void update_gvec(RSM *rsm, double gvec[], int p, int q, double ap[],
                 double aq[], double w[]);
@end example

@subsubheading Description

The @code{update_gvec} routine replaces the vector @math{@gamma{}} (see (59),
Section 1.6) which corresponds to the current basis by the updated vector
@tex
$\overline \gamma$ which corresponds to the adjacent basis.
@end tex

On entry the array @code{gvec} should contain elements of the vector
@tex
$\gamma = (\gamma_1, \dots, \gamma_n)$ for the current basis
@end tex
in locations @code{gvec[1]}, @dots{}, @code{gvec[n]} respectively. On exit
this array will contain elements of the vector
@tex
$\overline \gamma = (\overline \gamma_1, \dots, \overline \gamma_n)$
@end tex
for the adjacent basis in the same locations.

The parameter @code{p} specifies basic variable
@tex
$(x_B)_p$ which has been chosen to leave the basis.
@end tex

The parameter @code{q} specifies non-basic variable
@tex
$(x_N)_q$ which has been chosen to enter the basis.
@end tex

On entry the array @code{ap} should contain elements
@tex
of $p$-th row of the current simplex table $\alpha_p$ that corresponds to
basic variable $(x_B)_p$ in locations
@end tex
@code{ap[1]}, @dots{}, @code{ap[n]}. This array can be computed by means of
the @code{eval_row} routine (Section 2.3.11). It is not changed on exit.

On entry the array @code{aq} should contain elements
@tex
of $q$-th column of the current simplex table $\widetilde{A}_q$ that
corresponds to non-basic variable $(x_N)_q$ in locations
@end tex
@code{aq[1]}, @dots{}, @code{aq[m]}. This array can be computed by means of
the @code{eval_col} routine (Section 2.3.9). It is not changed on exit.

The working array @code{w} should have at least @math{1+m} locations, where
@math{m} is order of the basis matrix @math{B}.

The @code{update_gvec} routine assumes that the representation of the basis
matrix corresponds to the current basis, not to the adjacent one. Therefore
this routine should be called before changing the basis.

For updating the vector @math{@gamma{}} the @code{update_gvec} routine uses
the following formulae which can be easily derived from the formulae (61) and
(62) given in Section 1.6 (dashed symbols denote quantities related to the
adjacent basis):
@tex
$$
\eqalignno{
\gamma_q &= 1 + \sum_{i=1}^m \alpha_{iq}^2 & (a) \cr
w &= B^{-T} \widetilde{A}_q & (b) \cr
\overline \alpha_{pj} &= - {\alpha_{pj} \over \alpha_{pq}} & (c) \cr
t_j &= N_j^T w & (d) \cr
\overline \gamma_j &= \max(\gamma_j + \overline \alpha_{pj}^2 -
2 \overline \alpha_{pj} t_j, 1 + \overline \alpha_{pj}^2 ) & (e) \cr
\overline \gamma_q &= {1 \over \alpha_{pq}^2} \gamma_q & (f) \cr
}
$$

The formula (a) is used directly to compute exact value of $\gamma_q$, because
$q$-th (pivot) column of the simplex table is available in the case of primal
simplex method.

The formula (b) is used once for computing auxiliary vector $w$.

Formulae (c), (d), and (e) are used for computing all $\overline \gamma_j$
(except $\overline \gamma_q$). If due to round-off errors the computed value of
$\overline \gamma_j$ becomes too small, it is replaced by
$1 + \overline \alpha_{pj}^2$, because from the definition (59) it is seen that
$\overline \gamma_j \geq 1 + \overline \alpha_{pj}^2$.

Finally, the formula (g) is used to compute exact value of
$\overline \gamma_q$.
@end tex

@subsection @code{exact_gvec} --- compute exact value of @math{@gamma{}}
@fnindex{exact_gvec}

@subsubheading Synopsis

@example
#include "glprsm.h"
double exact_gvec(RSM *rsm, int j);
@end example

@subsubheading Description

The @code{exact_gvec} routine computes exact value of
@tex
$\gamma_j$
@end tex
using the formula (59) directly.

This operation is extremely inefficient and may be used only for debugging
purposes.

@subsubheading Returns

The @code{exact_gvec} routine returns the computed value of
@tex
$\gamma_j$.
@end tex

@subsection @code{check_gvec} --- check accuracy of the vector @math{@gamma{}}
@fnindex{check_gvec}

@subsubheading Synopsis

@example
#include "glprsm.h"
double check_gvec(RSM *rsm, double gvec[]);
@end example

@subsubheading Description

The @code{check_gvec} routine is intended for checking accuracy of the vector
@tex
$\gamma$. It computes the absolute error
$$e = \max_j |\gamma_j^* - \gamma_j|,$$
where $\gamma^*$ is exact vector computed by means of the
@end tex
@code{exact_gvec} routine (Section 2.4.3), @math{@gamma{}} is approximate
vector given in the array @code{gvec}.

This operation is extremely inefficient and may be used only for debugging
purposes.

@subsubheading Returns

The @code{check_gvec} routine returns the absolute error @math{e} (see above).

@section Dual steepest edge routines

This section describes routines which implement dual steepest edge technique
(see Section 1.6) in the same way as primal steepest edge routines (see
Section 2.4) and which are intended for using in conjunction with dual simplex
method routines (see Section 2.7).

@subsection @code{init_dvec} --- initialize the vector @math{@delta{}}
@fnindex{init_dvec}

@subsubheading Synopsis

@example
#include "glprsm.h"
void init_dvec(RSM *rsm, double dvec[]);
@end example

@subsubheading Description

The @code{init_dvec} routine computes the vector @math{@delta{}} (see (65),
Section 1.6) for the initial basis and stores its elements into locations
@code{dvec[1]}, @dots{}, @code{dvec[m]}.

@tex
Initial basis is a basis, where all auxiliary variables are basic and all
structural variables are non-basic. In this special case $B = I$ and
$N = \widehat{A}$, therefore $\alpha_{ij} = \widehat{a}_{ij}$, where
$\widehat{a}_{ij}$ are elements of the original constraint matrix
$\widehat{A}$, that allows using the formula (65) directly for computing the
initial vector $\delta$.
@end tex

@subsection @code{update_dvec} --- update the vector @math{@delta{}}
@fnindex{update_dvec}

@subsubheading Synopsis

@example
#include "glprsm.h"
void update_dvec(RSM *rsm, double dvec[], int p, int q, double ap[],
                 double aq[], double w[]);
@end example

@subsubheading Description

The @code{update_dvec} routine replaces the vector @math{@delta{}} (see (65),
Section 1.6) which corresponds to the current basis by the updated vector
@tex
$\overline \delta$ which corresponds to the adjacent basis.
@end tex

On entry the array @code{dvec} should contain elements of the vector
@tex
$\delta = (\delta_1, \dots, \delta_m)$ for the current basis
@end tex
in locations @code{dvec[1]}, @dots{}, @code{dvec[m]} respectively. On exit
this array will contain elements of the vector
@tex
$\overline \delta = (\overline \delta_1, \dots, \overline \delta_m)$
@end tex
for the adjacent basis in the same locations.

The parameter @code{p} specifies basic variable
@tex
$(x_B)_p$ which has been chosen to leave the basis.
@end tex

The parameter @code{q} specifies non-basic variable
@tex
$(x_N)_q$ which has been chosen to enter the basis.
@end tex

On entry the array @code{ap} should contain elements
@tex
of $p$-th row of the current simplex table $\alpha_p$ that corresponds to
basic variable $(x_B)_p$ in locations
@end tex
@code{ap[1]}, @dots{}, @code{ap[n]}. This array can be computed by means of
the @code{eval_row} routine (Section 2.3.11). It is not changed on exit.

On entry the array @code{aq} should contain elements
@tex
of $q$-th column of the current simplex table $\widetilde{A}_q$ that
corresponds to non-basic variable $(x_N)_q$ in locations
@end tex
@code{aq[1]}, @dots{}, @code{aq[m]}. This array can be computed by means of
the @code{eval_col} routine (Section 2.3.9). It is not changed on exit.

The working array @code{w} should have at least @math{1+m} locations, where
@math{m} is order of the basis matrix @math{B}.

The @code{update_dvec} routine assumes that the representation of the basis
matrix corresponds to the current basis, not to the adjacent one. Therefore
this routine should be called before changing the basis.

For updating the vector @math{@delta{}} the @code{update_dvec} routine uses
the following formulae which can be easily derived from the formulae (66) and
(67) given in Section 1.6 (dashed symbols denote quantities related to the
adjacent basis):
@tex
$$
\eqalignno{
\delta_p &= 1 + \sum_{j=1}^n \alpha_{pj}^2 & (a) \cr
w &= B^{-1} N \alpha_p^T & (b) \cr
\overline \alpha_{iq} &= + {\alpha_{iq} \over \alpha_{pq}} & (c) \cr
\overline \delta_i &= \max(\delta_i + \overline \alpha_{iq}^2 \delta_p +
2 \overline \alpha_{iq} w_j, 1 + \overline \alpha_{iq}^2 ) & (d) \cr
\overline \delta_p &= {1 \over \alpha_{pq}^2} \delta_p & (e) \cr
}
$$

The formula (a) is used directly to compute exact value of $\delta_p$, because
$p$-th (pivot) row of the simplex table is available in the case of dual
simplex method.

The formula (b) is used once for computing auxiliary vector $w$.

Formulae (c) and (d) are used for computing all $\overline \delta_i$ (except
$\overline \delta_p$). If due to round-off errors the computed value of
$\overline \delta_i$ becomes too small, it is replaced by
$1 + \overline \alpha_{iq}^2$, because from the definition (65) it is seen that
$\overline \delta_i \geq 1 + \overline \alpha_{iq}^2$.

Finally, the formula (e) is used to compute exact value of
$\overline \delta_p$.
@end tex

@subsection @code{exact_dvec} --- compute exact value of @math{@delta{}}
@fnindex{exact_dvec}

@subsubheading Synopsis

@example
#include "glprsm.h"
double exact_dvec(RSM *rsm, int i);
@end example

@subsubheading Description

The @code{exact_dvec} routine computes exact value of
@tex
$\delta_i$
@end tex
using the formula (65) directly.

This operation is extremely inefficient and may be used only for debugging
purposes.

@subsubheading Returns

The @code{exact_dvec} routine returns the computed value of
@tex
$\delta_i$.
@end tex

@subsection @code{check_dvec} --- check accuracy of the vector @math{@delta{}}
@fnindex{check_dvec}

@subsubheading Synopsis

@example
#include "glprsm.h"
double check_dvec(RSM *rsm, double dvec[]);
@end example

@subsubheading Description

The @code{check_dvec} routine is intended for checking accuracy of the vector
@tex
$\delta$. It computes the absolute error
$$e = \max_i |\delta_i^* - \delta_i|,$$
where $\delta^*$ is exact vector computed by means of the
@end tex
@code{exact_dvec} routine (Section 2.5.3), @math{@delta{}} is approximate
vector given in the array @code{dvec}.

This operation is extremely inefficient and may be used only for debugging
purposes.

@subsubheading Returns

The @code{check_dvec} routine returns the absolute error @math{e} (see above).

@section Primal simplex method routines

@subsection @code{pivot_col} --- choose non-basic variable (primal)
@fnindex{pivot_col}

@subsubheading Synopsis

@example
#include "glprsm.h"
int pivot_col(RSM *rsm, double c[], double cbar[], double gvec[],
              double tol);
@end example

@subsubheading Description

The @code{pivot_col} routine chooses
@tex
non-basic variable $(x_N)_q$ (i.e. pivot column of the simplex table) which
should enter the basis on the next iteration of the primal simplex method.
Note that the routine assumes that the objective function should be
@end tex
@emph{minimized}.

The array @code{c} should contain
@tex
the expanded vector $c = (c_1, \dots, c_{m+n})$ of coefficients of the
@end tex
objective function in locations @code{c[1]}, @dots{}, @code{c[m+n]}. This
array is not changed on exit.

The array @code{cbar} should contain
@tex
reduced costs $d = (d_1, \dots, d_n)$ of non-basic variables in locations
@end tex
@code{cbar[1]}, @dots{}, @code{cbar[n]}. This array is not changed on exit.

The array @code{gvec} should contain
@tex
the vector $\gamma = (\gamma_1, \dots, \gamma_n)$ (see (59), Section 1.6) in
@end tex
locations @code{gvec[1]}, @dots{}, @code{gvec[n]}. This array is not changed
on exit. It is allowed to specify @code{NULL} instead the array @code{gvec};
in this case the routine assumes that all elements of the vector
@math{@gamma{}} are equal to one.

The parameter @code{tol} is a relative tolerance (see below).

The @code{pivot_col} routine considers only those non-basic variables which
@tex
changing in feasible direction can improve (decrease) the objective function,
i.e. for which
$$\eqalign{
(x_N)_j \in x_F &\ and \ |d_j| > \varepsilon, \ or \cr
(x_N)_j \in x_L &\ and \ d_j < -\varepsilon, \ or \cr
(x_N)_j \in x_U &\ and \ d_j > +\varepsilon
}
$$
where
$$\varepsilon = tol \cdot \max(1, |(c_N)_j|)$$
(the absolute tolerance $\varepsilon$ reflects that the reduced cost of
non-basic variable $(x_N)_j$ is the difference
$d_j = (c_N)_j - N_j^T \pi$ as it follows from (40) in Section 1.4).

The routine chooses the non-basic variable $(x_N)_q$ which has the largest
(in absolute value) scaled reduced cost (60). Thus, if the vector $\gamma$ is
not used, the choice made by the routine corresponds to the textbook
technique. Otherwise the choice corresponds to the steepest edge technique.
@end tex

@subsubheading Returns

If the choice has been made, the @code{pivot_col} routine returns
@tex
$q$ which is a number of the chosen non-basic variable $(x_N)_q,
1 \leq q \leq n$. Otherwise, if the current basis solution is dual feasible
and the choice is impossible, the routine returns zero.
@end tex

@subsection @code{pivot_row} --- choose basic variable (primal, standard technique)
@fnindex{pivot_row}

@subsubheading Synopsis

@example
#include "glprsm.h"
int pivot_row(RSM *rsm, int q, int dir, double aq[], double bbar[],
              int *tagp, double tol);
@end example

@subsubheading Description

The @code{pivot_row} routine chooses basic variable
@tex
$(x_B)_p$ (i.e. pivot row of the simplex table) which should leave the basis
on the next iteration of the primal simplex method. The routine is based on
the standard (textbook) ratio test.
@end tex

The parameter @code{q} specifies a number of the non-basic variable
@tex
$(x_N)_q$ which has been chosen to enter the basis, $1 \leq q \leq n$.
@end tex

The parameter @code{dir} specifies in what direction the non-basic variable
@tex
$(x_N)_q$ is changing:

0, if $(x_N)_q$ is increasing;

1, if $(x_N)_q$ is decreasing.
@end tex

The array @code{aq} should contain
@tex
$q$-th (pivot) column $\widetilde{A}_q = (\alpha_{1q}, \dots, \alpha_{mq})$ of
the simplex table, i.e. $q$-th column of the matrix $\widetilde{A}$ (see (17),
Section 1.1), in locations
@end tex
@code{aq[1]}, @dots{}, @code{aq[m]}. This array is not changed on exit.

The array @code{bbar} should contain current values
@tex
$\beta = (\beta_1, \dots, \beta_m)$ of basic variables $x_B$ in locations
@end tex
@code{bbar[1]}, @dots{}, @code{bbar[m]}. This array is not changed on exit.

@tex
If the routine chooses some basic variable $(x_B)_p$, it stores into
@end tex
location @code{tagp} a tag that specifies to what subset
@tex
$x_L$, $x_U$, or $x_S$ (see (18), Section 1.1) the basic variable should be
attributed after it has left the basis. This tag has the same meaning as the
@end tex
field @code{rsm.tagn} (see Section 2.1).

The parameter @code{tol} is a relative tolerance (see below).

The @code{pivot_row} routine implements the standard (textbook) ratio test for
choosing basic variable as described in Section 1.2 (see step 5). i.e. the
@tex
routine determines that basic variable which reaches its (lower or upper)
bound first when the non-basic variable $(x_N)_q$ is changing in the feasible
direction. Besides, the following additional rules are used:

if $|\alpha_{iq}| < tol \cdot \max_i |\alpha_{iq}|$, i.e. if the influence
coefficient $\alpha_{iq}$ is relatively close to zero, it is assumed that the
corresponding basic variable $(x_B)_i$ doesn't depend on the non-basic
variable $(x_N)_q$ and therefore such basic variable is not considered to be
chosen;

if current value $\beta_i$ of some basic variable $(x_B)_i$ violates its
bound, it is assumed that this happens due to round-off errors and actually
the basic variable is exactly on its bound (because the current basis solution
should be primal feasible);

if several basic variables reach their bounds first at the same time, the
routine prefers that variable which has the largest (in absolute value)
influence coefficient.
@end tex

@subsubheading Returns

If the choice has been made, the @code{pivot_row} routine returns
@tex
$p$ which is a number of the chosen basic variable $(x_B)_p, 1 \leq p \leq m$.
In the special case, if the non-basic variable $(x_N)_q$ being double-bounded
variable reaches its opposite bound before any basic variable, the routine
returns a negative value. Otherwise, if the chosen non-basic variable $(x_N)_q$
can unlimitedly change in the feasible direction and therefore the choice is
impossible, the routine returns zero.
@end tex

@subsection @code{harris_row} --- choose basic variable (primal, Harris technique)
@fnindex{harris_row}

@subsubheading Synopsis

@example
#include "glprsm.h"
int harris_row(RSM *rsm, int q, int dir, double aq[], double bbar[],
              int *tagp, double tol, double tol1);
@end example

@subsubheading Description

The @code{harris_row} routine chooses basic variable
@tex
$(x_B)_p$ (i.e. pivot row of the simplex table) which should leave the basis
on the next iteration of the primal simplex method. The routine is based on
the two-pass ratio test proposed by P. Harris.
@end tex

The @code{harris_row} routine has the same program specification as the
@code{pivot_row} routine (see Subsection 2.6.2).

The only difference is the additional parameter @code{tol1} which is a relative
tolerance used for relaxing bounds of basic variables on the first pass. The
routine replaces original bounds of basic variables by their relaxed bounds:
@tex
$$(l_B)_i - \varepsilon \leq (x_B)_i \leq (u_B)_i + \varepsilon,$$
where
$$
\varepsilon = \left \{
\matrix{
tol1 \cdot \max (1, |(l_B)_i|) & in\ case\ of\ lower\ bound \cr
tol1 \cdot \max (1, |(u_B)_i|) & in\ case\ of\ upper\ bound \cr
}
\right .
$$
@end tex

For futher details see Section 1.7.

@section Dual simplex method routines

@subsection @code{dual_row} --- choose basic variable (dual)
@fnindex{dual_row}

@subsubheading Synopsis

@example
#include "glprsm.h"
int dual_row(RSM *rsm, double bbar[], double dvec[], int *tagp,
             double tol);
@end example

@subsubheading Description

The @code{dual_row} routine chooses basic variable
@tex
$(x_B)_p$ (i.e. pivot row of the simplex table) which should leave the basis
on the next iteration of the dual simplex method.
@end tex

The array @code{bbar} should contain current values
@tex
$\beta = (\beta_1, \dots, \beta_m)$ of basic variables $x_B$ in locations
@end tex
@code{bbar[1]}, @dots{}, @code{bbar[m]}. This array is not changed on exit.

The array @code{dvec} should contain the vector
@tex
$\delta = (\delta_1, \dots, \delta_m)$ (see (65), Section 1.6) in locations
@end tex
@code{dvec[1]}, @dots{}, @code{dvec[m]}. This array is not changed on exit.
It is allowed to specify @code{NULL} instead the array @code{dvec}; in this
case the routine assumes that all elements of the vector @math{@delta{}} are
equal to one.

If the routine chooses some basic variable
@tex
$(x_B)_p$, it stores into location
@end tex
@code{tagp} a tag that specifies to what subset
@tex
$x_L$ or $x_U$ (see (18), Section 1.1) the basic variable should be
attributed after it has left the basis. This tag has the same meaning as the
@end tex
field @code{rsm.tagn} (see Section 2.1).
@tex
Thus, the subset $x_L$ means that the basic variable $(x_B)_p$ violates its
lower bound and therefore it should be set on its lower bound. Analogously,
the subset $x_U$ means that the basic variable $(x_B)_p$ violates its upper
bound and therefore it should be set on its upper bound. Note that if the basic
variable $(x_B)_p$ is of fixed type, it is considered as double-bounded
variable (with lower bound equal to upper bound), therefore its tag should be
corrected before changing the basis by means of the
@end tex
@code{change_b} routine (see Subsection 2.3.12). This exception is used in
@tex
order to let other routines know what to do with such fixed basic variable:
increase (in case of $x_L$) or decrease (in case of $x_U$).
@end tex

The parameter @code{tol} is a relative tolerance (see below).

The @code{dual_row} routine considers only those basic variables which
violates their bounds:
@tex
$$\eqalign{
\beta_i &< (l_B)_i - \varepsilon \ \ or \cr
\beta_i &> (u_B)_i + \varepsilon \cr
}
$$
where
$$
\varepsilon = \left \{
\matrix{
tol \cdot \max (1, |(l_B)_i|) & in\ case\ of\ lower\ bound \cr
tol \cdot \max (1, |(u_B)_i|) & in\ case\ of\ upper\ bound \cr
}
\right .
$$

The routine chooses the basic variable $(x_B)_p$ which has the largest (in
absolute value) scaled residual (64). Thus, if the vector $\delta$ is not
used, the choice made by the routine corresponds to the textbook technique.
Otherwise the choice corresponds to the steepest edge technique.
@end tex

@subsubheading Returns

If the choice has been made, the @code{dual_row} routine returns
@tex
$p$ which is a number of the chosen basic variable $(x_B)_p, 1 \leq p \leq m$.
Otherwise, if the current basis solution is primal feasible and the choice is
impossible, the routine returns zero.
@end tex

@subsection @code{dual_col} --- choose non-basic variable (dual, standard technique)
@fnindex{dual_col}

@subsubheading Synopsis

@example
#include "glprsm.h"
int dual_col(RSM *rsm, int tagp, double ap[], double cbar[], double tol);
@end example

@subsubheading Description

The @code{dual_col} routine chooses non-basic variable
@tex
$(x_N)_q$ (i.e. pivot column of the simplex table) which should enter the
basis on the next iteration of the dual simplex method. The routine is based
on the standard (textbook) ratio test.
@end tex

The parameter @code{tagp} is a tag that specifies to what subset
@tex
$x_L$ or $x_U$ (see (18), Section 1.1) the chosen basic variable $(x_B)_p$
should be attributed after it has left the basis. This tag is set by the
@end tex
@code{dual_row} routine (see Subsection 2.7.1).

The array @code{ap} should contain
@tex
$p$-th (pivot) row $\alpha_p = (\alpha_1, \dots, \alpha_n)$ of the simplex
table, i.e. $p$-th row of the matrix $\widetilde{A}$ (see (17), Section 1.1)
@end tex
in locations @code{ap[1]}, @dots{}, @code{ap[n]}. This array is not changed
on exit.

The array @code{cbar} should contain
@tex
reduced costs $d = (d_1, \dots, d_n)$ of non-basic variables in locations
@end tex
@code{cbar[1]}, @dots{}, @code{cbar[n]}. This array is not changed on exit.

The parameter @code{tol} is a relative tolerance (see below).

The @code{dual_col} routine implements the standard (textbook) ratio test for
choosing non-basic variable as described in Section 1.3 (see step 5), i.e. the
routine determines that non-basoc variable whose dual variable reaches its
@tex
(lower or upper) zero bound first when the dual variable $(\lambda_B)_p$ that
corresponds to the chosen basic variable $(x_B)_p$ is changing in feasible
direction (increasing if $(x_B)_p$ goes on its lower bound or decreasing if
$(x_B)_p$ goes on its upper bound). Besides, the following additional rules
are used:

if $|\alpha_{pj}| < tol \cdot \max_j |\alpha_{pj}|$, i.e. if the influence
coefficient $\alpha_{pj}$ is relatively close to zero, it is assumed that the
corresponding non-basic variable $(x_N)_j$ doesn't affect on the basic
variable $(x_B)_p$ and therefore such non-basic variable is not considered to
be chosen;

if the reduced cost $d_j$ of some non-basic variable $(x_N)_j$ violates its
(zero) bound, it is assumed that this happens due to round-off errors and
actually the reduced cost is exactly zero (because the current basis solution
should be dual feasible);

if several dual variables that correspond to non-basic primal variables reach
their (zero) bounds first at the same time, the routine prefers that variable
which has the largest (in absolute value) influence coefficient.
@end tex

@subsubheading Returns

If the choice has been made, the @code{dual_col} routine returns
@tex
$q$ which is a number of the chosen non-basic variable $(x_N)_q,
1 \leq q \leq n$. Otherwise, if the dual variable $(\lambda_B)_p$ that
corresponds to the chosen basic variable $(x_B)_p$ can unlimitedly change in
the feasible direction and therefore the choice is impossible, the routine
returns zero.
@end tex

@subsection @code{harris_col} --- choose non-basic variable (dual, Harris technique)
@fnindex{harris_col}

@subsubheading Synopsis

@example
#include "glprsm.h"
int harris_col(RSM *rsm, int tagp, double ap[], double c[], double cbar[],
               double tol, double tol1);
@end example

@subsubheading Description

The @code{harris_col} routine chooses non-basic variable
@tex
$(x_N)_q$ (i.e. pivot column of the simplex table) which should enter the
basis on the next iteration of the dual simplex method. The routine is based
on the two-pass ratio test proposed by P. Harris.
@end tex

The @code{harris_col} routine has analogous program specification as the
@code{dual_col} routine (see Subsection 2.7.2).

The first additional parameter is the array @code{c} which should contain
the expanded vector @math{c} of coefficients of the objective function (4)
in locations @code{c[1]}, @dots{}, @code{c[m+n]}. It is assumed that the
reduced costs are computed using the vector @math{c} passed to this routine.

The second additional parameter is @code{tol1} which is a relative tolerance
used for relaxing zero bounds of dual variables
@tex
$\lambda_N$ (that correspond to primal non-basic variables $x_N$) on the
first pass. The routine replaces original zero bounds of dual variables by
their relaxed bounds:
$$(\lambda_N)_j \geq -\varepsilon \ or \ (\lambda_N)_j \leq +\varepsilon$$
where
$$\varepsilon = tol1 \cdot \max(1, |(c_N)_j|)$$
(the absolute tolerance $\varepsilon$ reflects that the reduced cost of
non-basic variable $(x_N)_j$ is the difference $d_j = (c_N)_j - N_j^T \pi$ as
it follows from the formula (40) in Section 1.4).
@end tex

For futher details see Section 1.7.

@unnumbered References

@enumerate 1
@item
GLPK Library Reference.
@item
@i{D. Goldfarb, J. K. Reid.} A practicable steepest-edge simplex algorithm.
Mathematical Programming, 12, 1977, 361---71.
@item
@i{P. M. J. Harris.} Pivot selection methods of the Devex LP code. Mathematical
Programming, 5, 1973, 1---28.
@end enumerate

@unnumbered Index
@printindex cp

@bye
