                    NEW GLPK API ROUTINES (DRAFT)

                           VERSION 3.0.8

                   Supplement to GLPK User's Guide

                              May 2002

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



TABLE OF CONTENTS
*****************



INTRODUCTION
LP problem
Brief example

PROBLEM CREATING AND MODIFYING ROUTINES
lpx_create_prob -- create problem object
lpx_add_rows -- add new rows to problem object
lpx_add_cols -- add new columns to problem object
lpx_check_name -- check correctness of symbolic name
lpx_set_prob_name -- assign (change) problem name
lpx_set_row_name -- assign (change) row name
lpx_set_col_name -- assign (change) column name
lpx_set_row_bnds -- set (change) row bounds
lpx_set_col_bnds -- set (change) column bounds
lpx_set_obj_dir -- set (change) optimization direction
lpx_set_obj_c0 -- set (change) constant term of the obj. function
lpx_set_row_coef -- set (change) row objective coefficient
lpx_set_col_coef -- set (change) column objective coefficient
lpx_set_row_stat -- set (change) row status
lpx_set_col_stat -- set (change) column status
lpx_load_mat -- load constraint matrix
lpx_set_mat_row -- set (replace) row of the constraint matrix
lpx_set_mat_col -- set (replace) column of the constraint matrix
lpx_unmark_all -- unmark all rows and columns
lpx_mark_row -- assign mark to row
lpx_mark_col -- assign mark to column
lpx_clear_mat -- clear rows and columns of the constraint matrix
lpx_del_items -- delete rows and columns from problem object
lpx_delete_prob -- delete problem object

PROBLEM QUERYING ROUTINES
lpx_get_num_rows -- determine number of rows
lpx_get_num_cols -- determine number of columns
lpx_get_num_nz -- determine number of constraint coefficients
lpx_get_prob_name -- obtain problem name
lpx_get_row_name -- obtain row name
lpx_get_col_name -- obtain column name
lpx_get_col_bnds -- obtain row bounds
lpx_get_col_bnds -- obtain column bounds
lpx_get_obj_dir -- determine optimization direction
lpx_get_obj_c0 -- obtain constant term of the obj. function
lpx_get_row_coef -- obtain row objective coefficient
lpx_get_col_coef -- obtain column objective coefficient
lpx_get_mat_row -- get row of the constraint matrix
lpx_get_mat_col -- get column of the constraint matrix
lpx_get_status -- query basic solution status
lpx_get_prim_stat -- query primal status of basic solution
lpx_get_dual_stat -- query dual status of basic solution
lpx_get_row_info -- obtain row solution information
lpx_get_col_info -- obtain column solution information
lpx_get_obj_val -- obtain value of the objective function
lpx_print_sol -- write problem solution in printable format

CONTROL PARAMETERS AND STATISTICS ROUTINES
lpx_reset_parms - reset control parameters to default values
lpx_set_int_parm - set (change) integer control parameter
lpx_get_int_parm - query integer control parameter
lpx_set_real_parm - set (change) real control parameter
lpx_get_real_parm - query real control parameter
List of control parameters

PROBLEM SCALING ROUTINES
lpx_scale_prob -- scale problem data
lpx_unscale_prob -- unscale problem data

BASIS CONSTRUCTING ROUTINES
lpx_std_basis -- construct standard initial basis
lpx_adv_basis -- construct advanced initial basis

SIMPLEX-BASED SOLVER ROUTINES
lpx_warm_up -- "warm up" the initial basis
lpx_simplex -- driver to the simplex method

SIMPLEX TABLE COMPUTING ROUTINES
lpx_eval_tab_row -- compute row of the simplex table
lpx_eval_tab_col -- compute column of the simplex table



INTRODUCTION
************



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



LP problem
----------

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

   minimize (or maximize)

      Z = c[1]*x[1] + c[2]*x[2] + ... + c[m+n]*x[m+n] + c[0]         (1)

   subject to linear equality constraints

      x[1] = a[1,1]*x[m+1] + a[1,2]*x[m+2] + ... + a[1,n]*x[m+n]
      x[2] = a[2,1]*x[m+1] + a[2,2]*x[m+2] + ... + a[2,n]*x[m+n]     (2)
            .  .  .  .  .  .
      x[m] = a[m,1]*x[m+1] + a[m,2]*x[m+2] + ... + a[m,n]*x[m+n]

   and bounds of variables

      l[1] <= x[1] <= u[1]
      l[2] <= x[2] <= u[2]                                           (3)
         .  .  .  .  .
      l[m+n] <= x[m+n] <= u[m+n]

where:

x[1], x[2], ..., x[m]       -- rows or auxiliary variables;

x[m+1], x[m+2], ..., x[m+n] -- columns or structural variables;

Z                           -- objective function;

c[1], c[2], ..., c[m+n]     -- coefficient of the objective function
                               at auxiliary and structural variables;

c0                          -- constant term of the objective function;

a[1,1], a[1,2], ..., a[m,n] -- coefficients of the equality constraints;

l[1], l[2], ..., l[m+n]     -- lower bounds of auxiliary and structural
                               variables;

u[1], u[2], ..., u[m+n]     -- upper bounds of auxiliary and structural
                               variables.

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

Bounds of auxiliary and structural variables can be finite as well as
infinite. Besides, lower bound and upper bounds can be the same. Thus,
the following types of variables are possible:

   Bounds of variable   Type of variable
   ----------------------------------------------
   -inf <  x <  +inf    Free (unbounded) variable
      l <= x <  +inf    Variable with lower bound
   -inf <  x <=  u      Variable with upper bound
      l <= x <=  u      Double-bounded variable
      l  = x  =  u      Fixed variable

To solve the LP problem (1)--(3) is to find such values of all auxiliary
and structural variables, which:

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

b) are within their bounds (3), and

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

For solving LP problems GLPK uses a well known procedure called the
simplex method. The simplex method performs iterations, where on every
iteration it transforms the original system of equality constraints (2)
resolving them through different sets of variables (the original system
is resolved through the auxiliary variables). Such a transformed system
is called the simplex table and has the following form:

       Z =      d[1]*xN[1] +      d[2]*xN[2] + ... +      d[n]*xN[n] (4)

   xB[1] = alfa[1,1]*xN[1] + alfa[1,2]*xN[2] + ... + alfa[1,n]*xN[n]
   xB[2] = alfa[2,1]*xN[1] + alfa[2,2]*xN[2] + ... + alfa[2,n]*xN[n] (5)
            .  .  .  .  .  .
   xB[m] = alfa[m,1]*xN[1] + alfa[m,2]*xN[2] + ... + alfa[m,n]*xN[n]

where:

xB[1], xB[2], ..., xB[m]             -- basic variables;

xN[1], xN[2], ..., xN[n]             -- non-basic variables;

d[1], d[2], ..., d[n]                -- reduced costs;

alfa[1,1], alfa[1,2], ..., alfa[m,n] -- coefficients of the simplex
                                        table.

From the linear programming theory it is well known that if an optimal
solution of the LP problem (1)--(3) exists, it can always be written in
the form of the simplex table (4)--(5), where the non-basic variables
are fixed on their bounds, and values of the objective function and
the basic variables are defined by the equalities (4) and (5).

A set of values of all basic and basic-variables determined by the
simplex table is called basic solution. If all basic variables are
within their bounds, the basic solution is called (primal) feasible;
otherwise the basic solution is called (primal) infeasible. A feasible
basic solution, which provides smallest (in case of minimization) or
largest (in case of maximization) value of the objective function is
called optimal. Therefore, for solving LP problem the simplex tries to
find its optimal basic solution.

Primal feasibility of some basic solution may be determined by simple
checking if all basic variables are within their bounds. Basic solution
is optimal if additionally the following optimality conditions are
satisfied for all non-basic variables:

   Status of xN[j]               Minimization   Maximization
   ---------------------------------------------------------
   xN[j] is free                   d[j]  = 0      d[j]  = 0          (6)
   xN[j] is on its lower bound     d[j] >= 0      d[j] <= 0
   xN[j] is on its upper bound     d[j] <= 0      d[j] >= 0

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

If all non-basic variables satisfy to the optimality conditions (6),
the basic solution is called dual feasible. Otherwise the basic solution
is called dual infeasible.

It may happen that some LP problem has no primal feasible solution due
to incorrect formulation -- this means that its constraints conflict
with each other. It also may happen that some LP problem has unbounded
solution again due to incorrect formulation -- this means that some
non-basic variable can improve the objective function, i.e. the
optimality conditions (6) are violated, and at the same time this
variable can infinitely change in the feasible direction meeting no
resistance from the basic variable. Should note that in the latter case
the LP problem has no dual feasible solution.



Brief example
-------------

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

   maximize

      Z = 10*x1 + 6*x2 + 4*x3

   subject to

         x1 +   x2 +   x3 <= 100
      10*x1 + 4*x2 + 5*x3 <= 600
       2*x1 + 2*x2 + 6*x3 <= 300

   and all variables are non-negative

      x1 >= 0, x2 >= 0, x3 >= 0

At first this LP problem should be transformed to the standard form
(1)--(3). It can be easily done introducing auxiliary variables, by one
for each original inequality constraint. Thus, the considered problem
can be reformulated as follows:

   maximize

      Z = 10*x1 + 6*x2 + 4*x3

   subject to

      p =    x1 +   x2 +   x3
      q = 10*x1 + 4*x2 + 5*x3
      r =  2*x1 + 2*x2 + 6*x3

   and bounds of variables

      -inf <  p  <= 100
      -inf <  q  <= 600
      -inf <  r  <= 300
         0 <= x1 < +inf
         0 <= x2 < +inf
         0 <= x3 < +inf

where p, q, r are auxiliary variables, and x1, x2, x3 are structural
variables.

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

/* newsamp.c */

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

int main(void)
{     LPX *lp;
      int ndx[1+3];
      double val[1+3];
      double Z, x1, x2, x3;

s1:   lp = lpx_create_prob();
s2:   lpx_set_prob_name(lp, "sample");

s3:   lpx_add_rows(lp, 3);

s4:   lpx_set_row_name(lp, 1, "p");
s5:   lpx_set_row_bnds(lp, 1, LPX_UP, 0.0, 100.0);
s6:   lpx_set_row_name(lp, 2, "q");
s7:   lpx_set_row_bnds(lp, 2, LPX_UP, 0.0, 600.0);
s8:   lpx_set_row_name(lp, 3, "r");
s9:   lpx_set_row_bnds(lp, 3, LPX_UP, 0.0, 300.0);

s10:  lpx_add_cols(lp, 3);

s11:  lpx_set_col_name(lp, 1, "x1");
s12:  lpx_set_col_bnds(lp, 1, LPX_LO, 0.0, 0.0);
s13:  lpx_set_col_name(lp, 2, "x2");
s14:  lpx_set_col_bnds(lp, 2, LPX_LO, 0.0, 0.0);
s15:  lpx_set_col_name(lp, 3, "x3");
s16:  lpx_set_col_bnds(lp, 3, LPX_LO, 0.0, 0.0);

s17:  ndx[1] = 1,   ndx[2] = 2,   ndx[3] = 3;
s18:  val[1] = 1.0, val[2] = 1.0, val[3] = 1.0;
s19:  lpx_set_mat_row(lp, 1, 3, ndx, val);
s20:  ndx[1] = 3,   ndx[2] = 2,   ndx[3] = 1;
s21:  val[1] = 5.0, val[2] = 4.0, val[3] = 10.0;
s22:  lpx_set_mat_row(lp, 2, 3, ndx, val);
s23:  ndx[1] = 1,   ndx[2] = 2,   ndx[3] = 3;
s24:  val[1] = 2.0, val[2] = 2.0, val[3] = 6.0;
s25:  lpx_set_mat_row(lp, 3, 3, ndx, val);

s26:  lpx_set_obj_dir(lp, LPX_MAX);

s27:  lpx_set_col_coef(lp, 1, 10.0);
s28:  lpx_set_col_coef(lp, 2, 6.0);
s29:  lpx_set_col_coef(lp, 3, 4.0);

s30:  lpx_simplex(lp);

s31:  Z = lpx_get_obj_val(lp);
s32:  lpx_get_col_info(lp, 1, NULL, &x1, NULL);
s33:  lpx_get_col_info(lp, 2, NULL, &x2, NULL);
s34:  lpx_get_col_info(lp, 3, NULL, &x3, NULL);

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

s36:  lpx_delete_prob(lp);

      return 0;
}

/* eof */

The statement s1 creates a linear programming problem object using the
routine lpx_create_prob. The statement s2 assigns a symbolic name to the
problem object.

The statement s3 adds 3 rows to the problem object.

The statement s4 assigns the symbolic name "p" to the first row, and the
statement s5 sets type and bounds of the first row, where LPX_UP means
that the row has an upper bound. The statements s6, s7, s8, s9 are used
in the same way in order to assign the symbolic names "q" and "r" to,
respectively, the second and the third rows and also set their types and
bounds.

The statement s10 adds 3 columns to the problem object.

The statement s11 assigns the symbolic name "x1" to the first column,
and the statement s12 sets type and bounds of the first column, where
LPX_LO means that the column has an lower bound. The statements s13,
s14, s15, s16 are used in the same way in order to assign the symbolic
names "x2" and "x3" to, respectively, the second and the third columns
and also set their types and bounds.

The statements s17--s25 saturate the constraint matrix, which currently
has 3 rows and 3 columns, by constraint coefficients in the row-wise
manner. The array ndx is used to pass column indices of non-zero
constranit coefficients, and the array val keeps numerical values of the
corresponding coefficients (note that locations ndx[0] and val[0] are
not used). So, the statements s17--s19 store constraint coefficients
for the first row, the statements s20--s22 does that for the second row,
and the statements s23--s25 does the same for the last, third row.

The statement s26 calls the routine lpx_set_obj_dir in order to sets
optimization direction, where LPX_MAX means maximization.

The statement s27 sets coefficient of the objective function at the
first column (structural variable). The statements s28 and s29 do the
same for the second and the third columns.

Now all data have been entered into the problem object, and therefore
the statement s30 calls the routine lpx_simplex, which is a driver to
the simplex method, in order to solve the LP problem. This routine finds
an optimal solution and stores all relevant information into the problem
object.

The statement s31 obtains a computed value of the objective function,
and the statements s32--s34 obtain computed values of structural
variables (columns), which correspond to the optimal basic solution
found by the solver.

The statement s35 prints the found optimal solution to the standard
output. The printout may look like follows:

   Z = 733.333; x1 = 33.3333; x2 = 66.6667; x3 = 0

Finally the statement s36 calls the routine lpx_delete_prob, which frees
all the memory allocated to the problem object.



PROBLEM CREATING AND MODIFYING ROUTINES
***************************************



lpx_create_prob -- create problem object
----------------------------------------

*Synopsis*

#include "glpk.h"
LPX *lpx_create_prob(void);

*Description*

The routine lpx_create_prob creates a new problem object, which is
"empty", i.e. has no rows and no columns.

*Returns*

The routine returns a pointer to the created object, which should be
used in any subsequent operations on this object.



lpx_add_rows -- add new rows to problem object
----------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_add_rows(LPX *lp, int nrs);

*Description*

The routine lpx_add_rows adds nrs rows (constraints) to the specified
problem object. New rows are always added to the end of the row list,
so ordinal numbers of existing rows are not changed.

Being added each new row is free (unbounded) and has no constraint
coefficients.



lpx_add_cols -- add new columns to problem object
-------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_add_cols(LPX *lp, int ncs);

*Description*

The routine lpx_add_cols adds ncs columns (structural variables) to the
specified problem object. New columns are always added to the end of the
column list, so ordinal numbers of existing columns are not changed.

Being added each new column is fixed at zero and has no constraint
coefficients.



lpx_check_name -- check correctness of symbolic name
----------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_check_name(char *name);

*Description*

The routine lpx_check_name checks the specified symbolic name for
correctness.

A symbolic name is considered as correct, if it consists of 1 up to 255
graphic characters (for which the standard C function isgraph reports
true).

This routine may be used before subsequent calls to the routines
lpx_set_prob_name, lpx_set_row_name, and lpx_set_col_name in order to
prevent abnormal termination in case of incorrect names.

*Returns*

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



lpx_set_prob_name -- assign (change) problem name
-------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_prob_name(LPX *lp, char *name);

*Description*

The routine lpx_set_prob_name assigns a given symbolic name to the
problem object. If the parameter name is NULL, the routine erases an
existing symbolic name assigned to the problem object.



lpx_set_row_name -- assign (change) row name
--------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_row_name(LPX *lp, int i, char *name);

*Description*

The routine lpx_set_row_name assigns a given symbolic name to the i-th
row of the problem object. If the parameter name is NULL, the routine
erases an existing symbolic name assigned to the row.

Note that the routine doesn't check for duplicate row names.



lpx_set_col_name -- assign (change) column name
-----------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_col_name(LPX *lp, int j, char *name);

*Description*

The routine lpx_set_col_name assigns a given symbolic name to the j-th
column of the problem object. If the parameter name is NULL, the routine
erases an existing symbolic name assigned to the column.

Note that the routine doesn't check for duplicate column names.



lpx_set_row_bnds -- set (change) row bounds
-------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_row_bnds(LPX *lp, int i, int typx, double lb, double ub);

*Description*

The routine lpx_set_row_bnds sets (changes) type and bounds of the i-th
row (auxiliary variable).

Parameters typx, lb, and ub specify respectively the type, the lower
bound, and the upper bound, which should be set for the i-th row:

    Type          Bounds            Note
   -------------------------------------------
   LPX_FR   -inf <  x <  +inf   free variable
   LPX_LO     lb <= x <  +inf   lower bound
   LPX_UP   -inf <  x <=  ub    upper bound
   LPX_DB     lb <= x <=  ub    double bound
   LPX_FX        x  =  lb       fixed variable

where x is the corresponding auxiliary variable.

If the row has no lower bound, the parameter lb is ignored. If the row
has no upper bound, the parameter ub is ignored. If the row is of fixed
type, the parameter lb is used, and the parameter ub is ignored.



lpx_set_col_bnds -- set (change) column bounds
----------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_col_bnds(LPX *lp, int j, int typx, double lb, double ub);

*Description*

The routine lpx_set_col_bnds sets (changes) type and bounds of the j-th
column (structural variable).

Parameters typx, lb, and ub specify respectively the type, the lower
bound, and the upper bound, which should be set for the i-th row:

    Type          Bounds            Note
   -------------------------------------------
   LPX_FR   -inf <  x <  +inf   free variable
   LPX_LO     lb <= x <  +inf   lower bound
   LPX_UP   -inf <  x <=  ub    upper bound
   LPX_DB     lb <= x <=  ub    double bound
   LPX_FX        x  =  lb       fixed variable

where x is the corresponding structural variable.

If the column has no lower bound, the parameter lb is ignored. If the
column has no upper bound, the parameter ub is ignored. If the column
is of fixed type, the parameter lb is used, and the parameter ub is
ignored.



lpx_set_obj_dir -- set (change) optimization direction
------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_obj_dir(LPX *lp, int dir);

*Description*

The routine lpx_set_obj_dir sets (changes) optimization direction
(i.e. the sense of the objective function) for the problem object as
specified by the parameter dir:

LPX_MIN -- the objective function should be minimized;

LPX_MAX -- the objective function should be maximized.



lpx_set_obj_c0 -- set (change) constant term of the obj. function
-----------------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_obj_c0(LPX *lp, double c0);

*Description*

The routine lpx_set_obj_c0 sets (changes) a constant term of the
objective function. The constant term is specified by the parameter c0.



lpx_set_row_coef -- set (change) row objective coefficient
----------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_row_coef(LPX *lp, int i, double coef);

*Description*

The routine lpx_set_row_coef sets (changes) a coefficient of the
objective function at the i-th auxiliary variable (row). The coefficient
is specified by the parameter coef.



lpx_set_col_coef -- set (change) column objective coefficient
-------------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_col_coef(LPX *lp, int j, double coef);

*Description*

The routine lpx_set_col_coef sets (changes) a coefficient of the
objective function at the j-th structural variable (column). The
coefficient is specified by the parameter col.



lpx_set_row_stat -- set (change) row status
-------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_row_stat(LPX *lp, int i, int stat);

*Description*

The routine lpx_set_row_stat sets (changes) the status of the i-th row
(auxiliary variable) as specified by the parameter stat:

LPX_BS -- make the row basic (make the constraint inactive);

LPX_NL -- make the row non-basic (make the constraint active);

LPX_NU -- make the row non-basic and set it to its upper bound;
          if the row is not double-bounded, this status is equivalent
          to LPX_NL (only in case of this routine);

LPX_NF -- same as LPX_NL (only in case of this routine);

LPX_NS -- same as LPX_NL (only in case of this routine).



lpx_set_col_stat -- set (change) column status
----------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_col_stat(LPX *lp, int j, int stat);

*Description*

The routine lpx_set_col_stat sets (changes) the status of the j-th
column (structural variable) as specified by the parameter stat:

LPX_BS -- make the column basic;

LPX_NL -- make the column non-basic;

LPX_NU -- make the column non-basic and set it to its upper bound;
          if the column is not double-bounded, this status is equivalent
          to LPX_NL (only in case of this routine);

LPX_NF -- same as LPX_NL (only in case of this routine);

LPX_NS -- same as LPX_NL (only in case of this routine).



lpx_load_mat -- load constraint matrix
--------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_load_mat(LPX *lp,
   void *info, double (*mat)(void *info, int *i, int *j));

*Description*

The routine lpx_load_mat loads non-zero elements of the constraint
matrix (i.e. constraint coefficients) from a file specified by the
formal routine mat. All existing contents of the constraint matrix is
destroyed.

The parameter info is a transit pointer passed to the formal routine
mat (see below).

The formal routine mat specifies a set of non-zero elements, which
should be loaded into the matrix. The routine lpx_load_mat calls the
routine mat in order to obtain a next non-zero element a[i,j]. In
response the routine mat should store row and column indices of this
next element to the locations *i and *j and return a numerical value of
the element. Elements may be enumerated in arbirary order. Note that
zero elements and multiplets (i.e. elements with identical row and
column indices) are not allowed. If there is no next element, the
routine mat should store zero to both locations *i and *j and then
"rewind" the file in order to begin enumerating again from the first
element.

The routine lpx_load_mat provides a most efficient way for initial
loading the constraint matrix. Nevertheless for the same purpose the
routines lpx_set_mat_row or/and lpx_set_mat_col may be used. However,
the latter case is less efficient.



lpx_set_mat_row -- set (replace) row of the constraint matrix
-------------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_mat_row(LPX *lp, int i, int len, int ndx[], double val[]);

*Description*

The routine lpx_set_mat_row sets (replaces) the i-th row of the
constraint matrix. The existing contents of this row is destroyed.

Column indices and numerical values of new non-zero coefficients of the
i-th row should be placed in the locations ndx[1], ..., ndx[len] and
val[1], ..., val[len] respectively, where 0 <= len <= n is the new
length of the i-th row, n is number of columns.

Note that zero coefficients and multiplets (i.e. coefficients with
identical column indices) are not allowed.



lpx_set_mat_col -- set (replace) column of the constraint matrix
----------------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_mat_col(LPX *lp, int j, int len, int ndx[], double val[]);

*Description*

The routine lpx_set_mat_col sets (replaces) the j-th column of the
constraint matrix. The existing contents of this column is destroyed.

Row indices and numerical values of new non-zero coefficients of the
j-th column should be placed in the locations ndx[1], ..., ndx[len] and
val[1], ..., val[len] respectively, where 0 <= len <= m is the new
length of the j-th column, m is number of rows.

Note that zero coefficients and multiplets (i.e. coefficients with
identical row indices) are not allowed.



lpx_unmark_all -- unmark all rows and columns
---------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_unmark_all(LPX *lp);

*Description*

The routine lpx_unmark_all resets marks of all rows and columns of the
problem object to zero.



lpx_mark_row -- assign mark to row
----------------------------------

*Synopsis*

#include "glpk.h"
void lpx_mark_row(LPX *lp, int i, int mark);

*Description*

The routine lpx_mark_row assigns a mark specified by the parameter mark
to the i-th row of the problem object.



lpx_mark_col -- assign mark to column
-------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_mark_col(LPX *lp, int j, int mark);

*Description*

The routine lpx_mark_col assigns a mark specified by the parameter mark
to the j-th column of the problem object.



lpx_clear_mat -- clear rows and columns of the constraint matrix
----------------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_clear_mat(LPX *lp);

*Description*

The routine lpx_clear_mat clears (nullifies) marked rows and columns
of the constraint matrix. All other (unmarked) rows and columns of the
constraint matrix remain unchanged.

Note that a row/column is considered as marked, if its mark assigned
by using the routine lpx_mark_row/lpx_mark_col is non-zero.



lpx_del_items -- delete rows and columns from problem object
------------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_del_items(LPX *lp);

*Description*

The routine lpx_del_items physically deletes marked rows and columns
from the problem object.

Note that a row/column is considered as marked, if its mark assigned
by using the routine lpx_mark_row/lpx_mark_col is non-zero.

Deleting rows and columns involves changing oridinal numbers of other
rows and columns, which are remaining in the problem object. Let, for
example, before deletion there were 5 rows a, b, c, d, e with ordinal
numbers 1, 2, 3, 4, 5, and 6 columns p, q, r, s, t, u with ordinal
numbers 1, 2, 3, 4, 5, 6. Let rows b, d and columns p, r, t, u were
deleted. Then after deletion the remaining rows a, c, e will have
new oridinal numbers 1, 2, 3, and the remaining columns q, s will have
new ordinal numbers 1, 2. In other words, new ordinal numbers can be
determined assuming that the order of the remaining rows and columns is
not changed.



lpx_delete_prob -- delete problem object
----------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_delete_prob(LPX *lp);

*Description*

The routine lpx_delete_prob deletes the problem object, which the
parameter lp points to, and frees all the memory allocated to this
object. After this operation the pointer lp gets invalid and should not
be used.



PROBLEM QUERYING ROUTINES
*************************



lpx_get_num_rows -- determine number of rows
--------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_num_rows(LPX *lp);

*Returns*

The routine lpx_get_num_rows returns current number of rows in the
problem object.



lpx_get_num_cols -- determine number of columns
-----------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_num_cols(LPX *lp);

*Returns*

The routine lpx_get_num_cols returns current number of columns in the
problem object.



lpx_get_num_nz -- determine number of constraint coefficients
-------------------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_num_nz(LPX *lp);

*Returns*

The routine lpx_get_num_nz returns current number of non-zero elements
in the constraint matrix of the problem object.



lpx_get_prob_name -- obtain problem name
----------------------------------------

*Synopsis*

#include "glpk.h"
char *lpx_get_prob_name(LPX *lp);

*Returns*

The routine lpx_get_prob_name returns a pointer to a character string,
which contains a symbolic name assigned to the problem object. If no
symbolic name was assigned to the problem, the routine returns NULL.



lpx_get_row_name -- obtain row name
-----------------------------------

*Synopsis*

#include "glpk.h"
char *lpx_get_row_name(LPX *lp, int i);

*Returns*

The routine lpx_get_row_name returns a pointer to a character string,
which contains a symbolic name assigned to the i-th row of the problem
object. If no symbolic name was assigned to the row, the routine returns
NULL.



lpx_get_col_name -- obtain column name
--------------------------------------

*Synopsis*

#include "glpk.h"
char *lpx_get_col_name(LPX *lp, int j);

*Returns*

The routine lpx_get_col_name returns a pointer to a character string,
which contains a symbolic name assigned to the j-th column of the
problem object. If no sybolic name was assigned to the column, the
routine returns NULL.



lpx_get_col_bnds -- obtain row bounds
-------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_get_row_bnds(LPX *lp, int i, int *typx, double *lb, double *ub)

*Description*

The routine lpx_get_row_bnds stores the type, lower bound and upper
bound of the i-th row to locations, which the parameters typx, lb, and
ub point to, respectively.

If some of the parameters typx, lb, or ub is NULL, the corresponding
value is not stored.

Types and bounds have the following meaning:

    Type          Bounds            Note
   -------------------------------------------
   LPX_FR   -inf <  x <  +inf   free variable
   LPX_LO     lb <= x <  +inf   lower bound
   LPX_UP   -inf <  x <=  ub    upper bound
   LPX_DB     lb <= x <=  ub    double bound
   LPX_FX        x  =  lb       fixed variable

where x is the corresponding auxiliary variable.

If the row has no lower bound, *lb is set to zero. If the row has no
upper bound, *ub is set to zero. If the row is of fixed type, *lb and
*ub are set to the same value.



lpx_get_col_bnds -- obtain column bounds
----------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_get_col_bnds(LPX *lp, int j, int *typx, double *lb, double *ub)

*Description*


The routine lpx_get_col_bnds stores the type, lower bound and upper
bound of the j-th column to locations, which the parameters typx, lb,
and ub point to, respectively.

If some of the parameters typx, lb, or ub is NULL, the corresponding
value is not stored.

Types and bounds have the following meaning:

    Type          Bounds            Note
   -------------------------------------------
   LPX_FR   -inf <  x <  +inf   free variable
   LPX_LO     lb <= x <  +inf   lower bound
   LPX_UP   -inf <  x <=  ub    upper bound
   LPX_DB     lb <= x <=  ub    double bound
   LPX_FX        x  =  lb       fixed variable

where x is the corresponding structural variable.

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



lpx_get_obj_dir -- determine optimization direction
---------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_obj_dir(LPX *lp);

*Returns*

The routine lpx_get_obj_dir returns a flag, which defines current
optimization direction (i.e. sense of the objective function):

LPX_MIN -- the objective function should be minimized;

LPX_MAX -- the objective function should be maximized.



lpx_get_obj_c0 -- obtain constant term of the obj. function
-----------------------------------------------------------

*Synopsis*

#include "glpk.h"
double lpx_get_obj_c0(LPX *lp);

*Returns*

The routine lpx_get_obj_c0 returns a current numerical value of the
constant term of the objective function.



lpx_get_row_coef -- obtain row objective coefficient
----------------------------------------------------

*Synopsis*

#include "glpk.h"
double lpx_get_row_coef(LPX *lp, int i);

*Returns*

The routine lpx_get_row_coef returns a current numerical value of the
coefficient of the objective function at the i-th auxiliary variable.



lpx_get_col_coef -- obtain column objective coefficient
-------------------------------------------------------

*Synopsis*

#include "glpk.h"
double lpx_get_col_coef(LPX *lp, int j);

*Returns*

The routine lpx_get_col_coef returns a current numerical value of the
coefficient of the objective function at the j-th structural variable.



lpx_get_mat_row -- get row of the constraint matrix
---------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_mat_row(LPX *lp, int i, int ndx[], double val[]);

*Description*

The routine lpx_get_mat_row scans (non-zero) elements of the i-th row
of the constraint matrix and stores their column indices and values to
locations ndx[1], ..., ndx[len] and val[1], ..., val[len] respectively,
where 0 <= len <= n is number of elements in the i-th row, n is number
of columns. It is allowed to specify val as NULL, in which case only
column indices are stored.

*Returns*

The routine returns len, which is number of stored elements (length of
the i-th row).



lpx_get_mat_col -- get column of the constraint matrix
------------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_mat_col(LPX *lp, int j, int ndx[], double val[]);

*Description*

The routine lpx_get_mat_col scans (non-zero) elements of the j-th
column of the constraint matrix and stores their row indices and values
to locations ndx[1], ..., ndx[len] and val[1], ..., val[len]
respectively, where 0 <= len <= m is number of elements in the j-th
column, m is number of rows. It is allowed to specify val as NULL, in
which case only row indices are stored.

*Returns*

The routine returns len, which is number of stored elements (length of
the j-th column).



lpx_get_status -- query basic solution status
---------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_status(LPX *lp);

*Returns*

The routine lpx_get_status reports the status of the current basic
solution obtained for the specified problem object:

LPX_OPT    -- solution is optimal;

LPX_FEAS   -- solution is primal feasible;

LPX_INFEAS -- solution is primal infeasible;

LPX_NOFEAS -- problem has no primal feasible solution;

LPX_UNBND  -- problem has unbounded primal solution;

LPX_UNDEF  -- solution is undefined (either the problem has not been
              solved yet or it has been changed since the last solve or
              the solver failed to obtain solution).

More detailed information about the solution status can be obtained
using the routines lpx_get_prim_stat and lpx_get_dual_stat.



lpx_get_prim_stat -- query primal status of basic solution
----------------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_prim_stat(LPX *lp);

*Returns*

The routine lpx_get_prim_stat reports the primal status of the most
recent basic solution obtained for the specified problem object:

LPX_P_UNDEF  -- the primal status is undefined;

LPX_P_FEAS   -- the solution is primal feasible;

LPX_P_INFEAS -- the solution is primal infeasible;

LPX_P_NOFEAS -- no primal feasible solution exists.



lpx_get_dual_stat -- query dual status of basic solution
--------------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_dual_stat(LPX *lp);

*Returns*

The routine lpx_get_dual_stat reports the dual status of the most recent
basic solution obtained for the specified problem object:

LPX_D_UNDEF  -- the dual status is undefined;

LPX_D_FEAS   -- the solution is dual feasible;

LPX_D_INFEAS -- the solution is dual infeasible;

LPX_D_NOFEAS -- no dual feasible solution exists.



lpx_get_row_info -- obtain row solution information
---------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_get_row_info(LPX *lp, int i, int *tagx, double *valx,
   double *dx);

*Description*

The routine lpx_get_row_info stores status, primal value and dual value
of the i-th auxiliary variable (row) to locations, which the parameters
tagx, valx, and dx point to, respectively.

The status code has the following meaning:

LPX_BS -- basic variable;

LPX_NL -- non-basic variable on its lower bound;

LPX_NU -- non-basic variable on its upper bound;

LPX_NF -- non-basic free (unbounded) variable;

LPX_NS -- non-basic fixed variable.

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



lpx_get_col_info -- obtain column solution information
------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_get_col_info(LPX *lp, int j, int *tagx, double *valx,
   double *dx);

*Description*

The routine lpx_get_col_info stores status, primal value and dual
value of the j-th structural variable (column) to locations, which the
parameters tagx, valx, and dx point to, respectively.

The status code has the following meaning:

LPX_BS -- basic variable;

LPX_NL -- non-basic variable on its lower bound;

LPX_NU -- non-basic variable on its upper bound;

LPX_NF -- non-basic free (unbounded) variable;

LPX_NS -- non-basic fixed variable.

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



lpx_get_obj_val -- obtain value of the objective function
---------------------------------------------------------

*Synopsis*

#include "glpk.h"
double lpx_get_obj_val(LPX *lp);

*Returns*

The routine returns a numerical value of the objective function for the
most recent basic solution obtained for the specified problem object.



lpx_print_sol -- write problem solution in printable format
-----------------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_print_sol(LPX *lp, char *fname);

*Description*

The routine lpx_print_sol writes the most recent current basic solution
obtained for the specified problem object to a text file, whose name is
the character string fname, in printable format.

Information reported by the routine lpx_print_sol is intended mainly
for visual analysis.

*Returns*

If the operation was successful, the routine returns zero. Otherwise
the routine prints an error message and returns non-zero.



CONTROL PARAMETERS AND STATISTICS ROUTINES
******************************************



lpx_reset_parms -- reset control parameters to default values
-------------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_reset_parms(LPX *lp);

*Description*

The routine lpx_reset_parms resets all control parameters associated
with an LP problem object, which the parameter lp points to, to their
default values.



lpx_set_int_parm -- set (change) integer control parameter
----------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_int_parm(LPX *lp, int parm, int val);

*Description*

The routine lpx_set_int_parm sets (changes) the current value of an
integer control parameter parm. The parameter val specifies a new value
of the control parameter.



lpx_get_int_parm -- query integer control parameter
---------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_get_int_parm(LPX *lp, int parm);

*Returns*

The routine lpx_get_int_parm returns the current value of an integer
control parameter parm.



lpx_set_real_parm -- set (change) real control parameter
--------------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_set_real_parm(LPX *lp, int parm, double val);

*Description*

The routine lpx_set_real_parm sets (changes) the current value of a real
(floating point) control parameter parm. The parameter val specifies a
new value of the control parameter.



lpx_get_real_parm -- query real control parameter
-------------------------------------------------

*Synopsis*

#include "glpk.h"
double lpx_get_real_parm(LPX *lp, int parm);

*Returns*

The routine lpx_get_real_parm returns the current value of a real
(floating point) control parameter parm. */



List of control parameters
--------------------------

LPX_K_MSGLEV   type: integer     default value: 3
   Level of messages output by solver routines:
   0 -- no output;
   1 -- error messages only;
   2 -- normal output;
   3 -- full output (includes informational messages).

LPX_K_SCALE    type: integer     default value: 3
   Scaling option:
   0 -- no scaling;
   1 -- equilibration scaling;
   2 -- geometric mean scaling;
   3 -- geometric mean scaling, then equilibration scaling.

LPX_K_DUAL     type: integer     default value: 0
   Dual simplex option:
   0 -- do not use the dual simplex;
   1 -- if the initial basic solution is primal infeasible, but dual
        feasible, use the dual simplex.

LPX_K_PRICE    type: integer     default value: 1
   Pricing option (for both primal and dual simplex):
   0 -- textbook pricing;
   1 -- steepest edge pricing.

LPX_K_RELAX    type: real        default value: 0.07
   Relaxation parameter used in the ratio test; if it is zero, the
   textbook ratio test is used; if it is non-zero (should be positive),
   Harris' two-pass ratio test is used; in the latter case on the first
   pass basic variables (in the case of primal simplex) or reduced costs
   of non-basic variables (in the case of dual simplex) are allowed to
   slightly violate their bounds, but not more than (RELAX * TOLBND) or
   (RELAX * TOLDJ) (thus, relax is a percentage of TOLBND or TOLDJ).

LPX_K_ROUND    type: integer     default value: 0
   Solution rounding option:
   0 -- report all computed values and reduced costs "as is";
   1 -- round computed values of basic variables and reduced costs of
        non-basic variables toward their bounds or toward zero, if it is
        allowed by the tolerances TOLBND and TOLDJ.

LPX_K_OBJLL    type: real        default value: -DBL_MAX
   Lower limit of the objective function. If on the phase II the
   objective function reaches this limit and continues decreasing, the
   solver stops the search.

LPX_K_OBJUL    type: real        default value: +DBL_MAX
   Upper limit of the objective function; if on the phase II the
   objective function reaches this limit and continues increasing, the
   solver stops the search.

LPX_K_ITLIM    type: integer     default value: -1
   Simplex iterations limit; if this value is positive, it is decreased
   by one each time when one simplex iteration has been performed, and
   reaching zero value signals the solver to stop the search; negative
   value means no iterations limit.

LPX_K_ITCNT    type: integer     initial value: 0
   Simplex iterations count; this count is increased by one each time
   when one simplex iteration has been performed.

LPX_K_TMLIM    type: real        default value: -1.0
   Searching time limit, in seconds; if this value is positive, it is
   decreased each time when one simplex iteration has been performed by
   the amount of time spent for the iteration, and reaching zero value
   signals the solver to stop the search; negative value means no time
   limit.

LPX_K_OUTFRQ   type: integer     default value: 100
   Output frequency, in iterations; this parameter specifies how
   frequently the solver sends information about the solution to the
   standard output.

LPX_K_OUTDLY   type: real        default value: 0.0
   Output delay, in seconds; this parameter specifies how long the
   solver should delay sending information about the solution to the
   standard output; non-positive value means no delay.



PROBLEM SCALING ROUTINES
************************



lpx_scale_prob -- scale problem data
------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_scale_prob(LPX *lp);

*Description*

The routine lpx_scale_prob performs scaling problem data for the
specified problem object.

The purpose of scaling is to replace the original constraint matrix A
by the scaled matrix A" = R*A*S, where R and S are diagonal scaling
matrices, in the hope that A" has better numerical properties than A.

On API level the scaling effect is almost invisible, since all data
entered into the problem object (say, constraint coefficients or bounds
of variables) are automatically scaled by API routines using the scaling
matrices R and S, and vice versa, all data obtained from the problem
object (say, values of variables or reduced costs) are automatically
unscaled. However, round-off errors may involve small distortions (of
order DBL_EPSILON) of the original problem data.



lpx_unscale_prob -- unscale problem data
----------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_unscale_prob(LPX *lp);

*Description*

The routine lpx_unscale_prob performs unscaling problem data for the
specified problem object.

"Unscaling" means replacing the current scaling matrices R and S by
unity matrices that cancels the scaling effect.



INITIAL BASIS CONSTRUCTING ROUTINES
***********************************



lpx_std_basis -- construct standard initial basis
-------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_std_basis(LPX *lp);

*Description*

The routine lpx_std_basis constructs the "standard" (trivial) initial
basis for the specified problem object.

In the "standard" basis all auxiliary variables are basic, and all
structural variables are non-basic.



lpx_adv_basis -- construct advanced initial basis
-------------------------------------------------

*Synopsis*

#include "glpk.h"
void lpx_adv_basis(LPX *lp);

*Description*

The routine lpx_adv_basis constructs an advanced initial basis for the
specified problem object.

In order to build the initial basis the routine does the following:

1) includes in the basis all non-fixed auxiliary variables;

2) includes in the basis as many as possible non-fixed structural
   variables preserving triangular form of the basis matrix;

3) includes in the basis appropriate (fixed) auxiliary variables
   in order to complete the basis.

As a result the initial basis has as few as possible of fixed variables
and the corresponding basis matrix is triangular.



SIMPLEX-BASED SOLVER ROUTINES
*****************************



lpx_warm_up -- "warm up" the initial basis
------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_warm_up(LPX *lp);

*Description*

The routine lpx_warm_up "warms up" the initial basis of the specified
problem object. "Warming up" includes (if necessary) reinverting
(factorizing) the initial basis matrix, computing the initial basic
solution components (values of basic variables, simplex multipliers,
reduced costs of non-basic variables), and determining primal and dual
statuses of the initial basic solution.

*Returns*

The routine lpx_warm_up returns one of the following exit codes:

LPX_E_OK       the initial basis has been successfully "warmed up".

LPX_E_EMPTY    the problem has no rows and/or no columns.

LPX_E_BADB     the initial basis is invalid, because number of basic
               variables and number of rows are different.

LPX_E_SING     the initial basis matrix is numerically singular or
               ill-conditioned.

Note that additional exit codes may appear in the future versions of
this routine.



lpx_simplex -- driver to the simplex method
-------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_simplex(LPX *lp);

*Description*

The routine lpx_simplex is intended to find optimal solution of the
specified LP problem.

Currently this routine implements an easy variant of the two-phase
primal simplex method, where on the phase I the routine searches for
a primal feasible solution, and on the phase II for an optimal one.
(However, if the initial basic solution is primal infeasible, but dual
feasible, the dual simplex method may be used; see the control parameter
LPX_K_DUAL.)

*Returns*

LPX_E_OK       the LP problem has been successfully solved.

LPX_E_FAULT    either the LP problem has no rows and/or columns, or
               the initial basis is invalid, or the basis matrix is
               singular or ill-conditioned.

LPX_E_OBJLL    the objective function has reached its lower limit and
               continues decreasing.

LPX_E_OBJUL    the objective function has reached its upper limit and
               continues increasing.

LPX_E_ITLIM    iterations limit exceeded.

LPX_E_TMLIM    time limit exceeded.

LPX_E_SING     the basis matrix got singular or ill-conditioned due
               to improper simplex iteration.

Note that additional exit codes may appear in the future versions of
this routine.



SIMPLEX TABLE COMPUTING ROUTINES
********************************



lpx_eval_tab_row -- compute row of the simplex table
----------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_eval_tab_row(LPX *lp, int k, int ndx[], double val[]);

*Description*

The routine lpx_eval_tab_row computes a row of the current simplex
table for the basic variable, which is specified by the number k:
if 1 <= k <= m, x[k] is k-th auxiliary variable; if m+1 <= k <= m+n,
x[k] is (k-m)-th structural variable, where m is number of rows, and n
is number of columns. The current basis must be valid.

The routine stores column indices and numerical values of non-zero
elements of the computed row using sparse format to the locations
ndx[1], ..., ndx[len] and val[1], ..., val[len] respectively, where
0 <= len <= n is number of non-zeros returned on exit.

Element indices strored in the array ndx have the same sense as the
index k, i.e. indices 1 to m denote auxiliary variables and indices
m+1 to m+n denote structural ones (all these variables are obviously
non-basic by the definition).

The computed row shows how the specified basic variable x[k] = xB[i]
depends on non-basic variables:

   xB[i] = alfa[i,1]*xN[1] + alfa[i,2]*xN[2] + ... + alfa[i,n]*xN[n],

where alfa[i,j] are elements of the simplex table row, xN[j] are
non-basic (auxiliary and structural) variables.

Even if the problem is (internally) scaled, the routine returns the
specified simplex table row as if the problem were unscaled.

*Returns*

The routine returns number of non-zero elements in the simplex table
row stored in the arrays ndx and val.



lpx_eval_tab_col -- compute column of the simplex table
-------------------------------------------------------

*Synopsis*

#include "glpk.h"
int lpx_eval_tab_col(LPX *lp, int k, int ndx[], double val[]);

*Description*

The routine lpx_eval_tab_col computes a column of the current simplex
table for the non-basic variable, which is specified by the number k:
if 1 <= k <= m, x[k] is k-th auxiliary variable; if m+1 <= k <= m+n,
x[k] is (k-m)-th structural variable, where m is number of rows, and
n is number of columns. The current basis must be valid.

Note that the current basis should be valid.

The routine stores row indices and numerical values of non-zero
elements of the computed column using sparse format to the locations
ndx[1], ..., ndx[len] and val[1], ..., val[len] respectively, where
0 <= len <= m is number of non-zeros returned on exit.

Element indices strored in the array ndx have the same sense as the
index k, i.e. indices 1 to m denote auxiliary variables and indices
m+1 to m+n denote structural ones (all these variables are obviously
basic by the definition).

The computed column shows how basic variables depend on the specified
non-basic variable x[k] = xN[j]:

   xB[1] = ... + alfa[1,j]*xN[j] + ...
   xB[2] = ... + alfa[2,j]*xN[j] + ...
            . . . . . .
   xB[m] = ... + alfa[m,j]*xN[j] + ...

where alfa[i,j] are elements of the simplex table column, xB[i] are
basic (auxiliary and structural) variables.

Even if the problem is (internally) scaled, the routine returns the
specified simplex table column as if the problem were unscaled.

*Returns*

The routine returns number of non-zero elements in the simplex table
column stored in the arrays ndx and val.



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

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

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

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

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

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

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