alpar@9: %* glpk04.tex *% alpar@9: alpar@9: \chapter{Advanced API Routines} alpar@9: alpar@9: \section{Background} alpar@9: \label{basbgd} alpar@9: alpar@9: Using vector and matrix notations LP problem (1.1)---(1.3) (see Section alpar@9: \ref{seclp}, page \pageref{seclp}) can be stated as follows: alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent alpar@9: \hspace{.5in} minimize (or maximize) alpar@9: $$z=c^Tx_S+c_0\eqno(3.1)$$ alpar@9: \hspace{.5in} subject to linear constraints alpar@9: $$x_R=Ax_S\eqno(3.2)$$ alpar@9: \hspace{.5in} and bounds of variables alpar@9: $$ alpar@9: \begin{array}{l@{\ }c@{\ }l@{\ }c@{\ }l} alpar@9: l_R&\leq&x_R&\leq&u_R\\ alpar@9: l_S&\leq&x_S&\leq&u_S\\ alpar@9: \end{array}\eqno(3.3) alpar@9: $$ alpar@9: where: alpar@9: alpar@9: \noindent alpar@9: $x_R=(x_1,\dots,x_m)$ is the vector of auxiliary variables; alpar@9: alpar@9: \noindent alpar@9: $x_S=(x_{m+1},\dots,x_{m+n})$ is the vector of structural alpar@9: variables; alpar@9: alpar@9: \noindent alpar@9: $z$ is the objective function; alpar@9: alpar@9: \noindent alpar@9: $c=(c_1,\dots,c_n)$ is the vector of objective coefficients; alpar@9: alpar@9: \noindent alpar@9: $c_0$ is the constant term (``shift'') of the objective function; alpar@9: alpar@9: \noindent alpar@9: $A=(a_{11},\dots,a_{mn})$ is the constraint matrix; alpar@9: alpar@9: \noindent alpar@9: $l_R=(l_1,\dots,l_m)$ is the vector of lower bounds of auxiliary alpar@9: variables; alpar@9: alpar@9: \noindent alpar@9: $u_R=(u_1,\dots,u_m)$ is the vector of upper bounds of auxiliary alpar@9: variables; alpar@9: alpar@9: \noindent alpar@9: $l_S=(l_{m+1},\dots,l_{m+n})$ is the vector of lower bounds of alpar@9: structural variables; alpar@9: alpar@9: \noindent alpar@9: $u_S=(u_{m+1},\dots,u_{m+n})$ is the vector of upper bounds of alpar@9: structural variables. alpar@9: alpar@9: \medskip alpar@9: alpar@9: From the simplex method's standpoint there is no difference between alpar@9: auxiliary and structural variables. This allows combining all these alpar@9: variables into one vector that leads to the following problem statement: alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent alpar@9: \hspace{.5in} minimize (or maximize) alpar@9: $$z=(0\ |\ c)^Tx+c_0\eqno(3.4)$$ alpar@9: \hspace{.5in} subject to linear constraints alpar@9: $$(I\ |-\!A)x=0\eqno(3.5)$$ alpar@9: \hspace{.5in} and bounds of variables alpar@9: $$l\leq x\leq u\eqno(3.6)$$ alpar@9: where: alpar@9: alpar@9: \noindent alpar@9: $x=(x_R\ |\ x_S)$ is the $(m+n)$-vector of (all) variables; alpar@9: alpar@9: \noindent alpar@9: $(0\ |\ c)$ is the $(m+n)$-vector of objective alpar@9: coefficients;\footnote{Subvector 0 corresponds to objective coefficients alpar@9: at auxiliary variables.} alpar@9: alpar@9: \noindent alpar@9: $(I\ |-\!A)$ is the {\it augmented} constraint alpar@9: $m\times(m+n)$-matrix;\footnote{Note that due to auxiliary variables alpar@9: matrix $(I\ |-\!A)$ contains the unity submatrix and therefore has full alpar@9: rank. This means, in particular, that the system (3.5) has no linearly alpar@9: dependent constraints.} alpar@9: alpar@9: \noindent alpar@9: $l=(l_R\ |\ l_S)$ is the $(m+n)$-vector of lower bounds of (all) alpar@9: variables; alpar@9: alpar@9: \noindent alpar@9: $u=(u_R\ |\ u_S)$ is the $(m+n)$-vector of upper bounds of (all) alpar@9: variables. alpar@9: alpar@9: \medskip alpar@9: alpar@9: By definition an {\it LP basic solution} geometrically is a point in alpar@9: the space of all variables, which is the intersection of planes alpar@9: corresponding to active constraints\footnote{A constraint is called alpar@9: {\it active} if in a given point it is satisfied as equality, otherwise alpar@9: it is called {\it inactive}.}. The space of all variables has the alpar@9: dimension $m+n$, therefore, to define some basic solution we have to alpar@9: define $m+n$ active constraints. Note that $m$ constraints (3.5) being alpar@9: linearly independent equalities are always active, so remaining $n$ alpar@9: active constraints can be chosen only from bound constraints (3.6). alpar@9: alpar@9: A variable is called {\it non-basic}, if its (lower or upper) bound is alpar@9: active, otherwise it is called {\it basic}. Since, as was said above, alpar@9: exactly $n$ bound constraints must be active, in any basic solution alpar@9: there are always $n$ non-basic variables and $m$ basic variables. alpar@9: (Note that a free variable also can be non-basic. Although such alpar@9: variable has no bounds, we can think it as the difference between two alpar@9: non-negative variables, which both are non-basic in this case.) alpar@9: alpar@9: Now consider how to determine numeric values of all variables for a alpar@9: given basic solution. alpar@9: alpar@9: Let $\Pi$ be an appropriate permutation matrix of the order $(m+n)$. alpar@9: Then we can write: alpar@9: $$\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)= alpar@9: \Pi\left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)=\Pi x, alpar@9: \eqno(3.7)$$ alpar@9: where $x_B$ is the vector of basic variables, $x_N$ is the vector of alpar@9: non-basic variables, $x=(x_R\ |\ x_S)$ is the vector of all variables alpar@9: in the original order. In this case the system of linear constraints alpar@9: (3.5) can be rewritten as follows: alpar@9: $$(I\ |-\!A)\Pi^T\Pi x=0\ \ \ \Rightarrow\ \ \ (B\ |\ N) alpar@9: \left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=0,\eqno(3.8)$$ alpar@9: where alpar@9: $$(B\ |\ N)=(I\ |-\!A)\Pi^T.\eqno(3.9)$$ alpar@9: Matrix $B$ is a square non-singular $m\times m$-matrix, which is alpar@9: composed from columns of the augmented constraint matrix corresponding alpar@9: to basic variables. It is called the {\it basis matrix} or simply the alpar@9: {\it basis}. Matrix $N$ is a rectangular $m\times n$-matrix, which is alpar@9: composed from columns of the augmented constraint matrix corresponding alpar@9: to non-basic variables. alpar@9: alpar@9: From (3.8) it follows that: alpar@9: $$Bx_B+Nx_N=0,\eqno(3.10)$$ alpar@9: therefore, alpar@9: $$x_B=-B^{-1}Nx_N.\eqno(3.11)$$ alpar@9: Thus, the formula (3.11) shows how to determine numeric values of basic alpar@9: variables $x_B$ assuming that non-basic variables $x_N$ are fixed on alpar@9: their active bounds. alpar@9: alpar@9: The $m\times n$-matrix alpar@9: $$\Xi=-B^{-1}N,\eqno(3.12)$$ alpar@9: which appears in (3.11), is called the {\it simplex alpar@9: tableau}.\footnote{This definition corresponds to the GLPK alpar@9: implementation.} It shows how basic variables depend on non-basic alpar@9: variables: alpar@9: $$x_B=\Xi x_N.\eqno(3.13)$$ alpar@9: alpar@9: The system (3.13) is equivalent to the system (3.5) in the sense that alpar@9: they both define the same set of points in the space of (primal) alpar@9: variables, which satisfy to these systems. If, moreover, values of all alpar@9: basic variables satisfy to their bound constraints (3.3), the alpar@9: corresponding basic solution is called {\it (primal) feasible}, alpar@9: otherwise {\it (primal) infeasible}. It is understood that any (primal) alpar@9: feasible basic solution satisfy to all constraints (3.2) and (3.3). alpar@9: alpar@9: The LP theory says that if LP has optimal solution, it has (at least alpar@9: one) basic feasible solution, which corresponds to the optimum. And the alpar@9: most natural way to determine whether a given basic solution is optimal alpar@9: or not is to use the Karush---Kuhn---Tucker optimality conditions. alpar@9: alpar@9: \def\arraystretch{1.5} alpar@9: alpar@9: For the problem statement (3.4)---(3.6) the optimality conditions are alpar@9: the following:\footnote{These conditions can be appiled to any solution, alpar@9: not only to a basic solution.} alpar@9: $$(I\ |-\!A)x=0\eqno(3.14)$$ alpar@9: $$(I\ |-\!A)^T\pi+\lambda_l+\lambda_u=\nabla z=(0\ |\ c)^T\eqno(3.15)$$ alpar@9: $$l\leq x\leq u\eqno(3.16)$$ alpar@9: $$\lambda_l\geq 0,\ \ \lambda_u\leq 0\ \ \mbox{(minimization)} alpar@9: \eqno(3.17)$$ alpar@9: $$\lambda_l\leq 0,\ \ \lambda_u\geq 0\ \ \mbox{(maximization)} alpar@9: \eqno(3.18)$$ alpar@9: $$(\lambda_l)_k(x_k-l_k)=0,\ \ (\lambda_u)_k(x_k-u_k)=0,\ \ k=1,2,\dots, alpar@9: m+n\eqno(3.19)$$ alpar@9: where: alpar@9: $\pi=(\pi_1,\pi_2,\dots,\pi_m)$ is a $m$-vector of Lagrange alpar@9: multipliers for equality constraints (3.5); alpar@9: $\lambda_l=[(\lambda_l)_1,(\lambda_l)_2,\dots,(\lambda_l)_n]$ is a alpar@9: $n$-vector of Lagrange multipliers for lower bound constraints (3.6); alpar@9: $\lambda_u=[(\lambda_u)_1,(\lambda_u)_2,\dots,(\lambda_u)_n]$ is a alpar@9: $n$-vector of Lagrange multipliers for upper bound constraints (3.6). alpar@9: alpar@9: Condition (3.14) is the {\it primal} (original) system of equality alpar@9: constraints (3.5). alpar@9: alpar@9: Condition (3.15) is the {\it dual} system of equality constraints. alpar@9: It requires the gradient of the objective function to be a linear alpar@9: combination of normals to the planes defined by constraints of the alpar@9: original problem. alpar@9: alpar@9: Condition (3.16) is the primal (original) system of bound constraints alpar@9: (3.6). alpar@9: alpar@9: Condition (3.17) (or (3.18) in case of maximization) is the dual system alpar@9: of bound constraints. alpar@9: alpar@9: Condition (3.19) is the {\it complementary slackness condition}. It alpar@9: requires, for each original (auxiliary or structural) variable $x_k$, alpar@9: that either its (lower or upper) bound must be active, or zero bound of alpar@9: the corresponding Lagrange multiplier ($(\lambda_l)_k$ or alpar@9: $(\lambda_u)_k$) must be active. alpar@9: alpar@9: In GLPK two multipliers $(\lambda_l)_k$ and $(\lambda_u)_k$ for each alpar@9: primal (original) variable $x_k$, $k=1,2,\dots,m+n$, are combined into alpar@9: one multiplier: alpar@9: $$\lambda_k=(\lambda_l)_k+(\lambda_u)_k,\eqno(3.20)$$ alpar@9: which is called a {\it dual variable} for $x_k$. This {\it cannot} lead alpar@9: to the ambiguity, because both lower and upper bounds of $x_k$ cannot be alpar@9: active at the same time,\footnote{If $x_k$ is a fixed variable, we can alpar@9: think it as double-bounded variable $l_k\leq x_k\leq u_k$, where alpar@9: $l_k=u_k.$} so at least one of $(\lambda_l)_k$ and $(\lambda_u)_k$ must alpar@9: be equal to zero, and because these multipliers have different signs, alpar@9: the combined multiplier, which is their sum, uniquely defines each of alpar@9: them. alpar@9: alpar@9: \def\arraystretch{1} alpar@9: alpar@9: Using dual variables $\lambda_k$ the dual system of bound constraints alpar@9: (3.17) and (3.18) can be written in the form of so called {\it ``rule of alpar@9: signs''} as follows: alpar@9: alpar@9: \begin{center} alpar@9: \begin{tabular}{|@{\,}c@{$\,$}|@{$\,$}c@{$\,$}|@{$\,$}c@{$\,$}| alpar@9: @{$\,$}c|c@{$\,$}|@{$\,$}c@{$\,$}|@{$\,$}c@{$\,$}|} alpar@9: \hline alpar@9: Original bound&\multicolumn{3}{c|}{Minimization}&\multicolumn{3}{c|} alpar@9: {Maximization}\\ alpar@9: \cline{2-7} alpar@9: constraint&$(\lambda_l)_k$&$(\lambda_u)_k$&$(\lambda_l)_k+ alpar@9: (\lambda_u)_k$&$(\lambda_l)_k$&$(\lambda_u)_k$&$(\lambda_l)_k+ alpar@9: (\lambda_u)_k$\\ alpar@9: \hline alpar@9: $-\infty= {\tt piv\_tol}\cdot\max|u_{i*}|$, i.e. if it is not very alpar@9: small in the magnitude among other elements in the same row. Decreasing alpar@9: this parameter may lead to better sparsity at the expense of numerical alpar@9: accuracy, and vice versa.\\ alpar@9: \end{tabular} alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}} alpar@9: \multicolumn{2}{@{}l}{{\tt int piv\_lim} (default: {\tt 4})} \\ alpar@9: &This parameter is used on computing $LU$-factorization of the basis alpar@9: matrix and specifies how many pivot candidates needs to be considered alpar@9: on choosing a pivot element, \verb|piv_lim| $\geq$ 1. If \verb|piv_lim| alpar@9: candidates have been considered, the pivoting routine prematurely alpar@9: terminates the search with the best candidate found.\\ alpar@9: \end{tabular} alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}} alpar@9: \multicolumn{2}{@{}l}{{\tt int suhl} (default: {\tt GLP\_ON})} \\ alpar@9: &This parameter is used on computing $LU$-factorization of the basis alpar@9: matrix. Being set to {\tt GLP\_ON} it enables applying the following alpar@9: heuristic proposed by Uwe Suhl: if a column of the active submatrix has alpar@9: no eligible pivot candidates, it is no more considered until it becomes alpar@9: a column singleton. In many cases this allows reducing the time needed alpar@9: for pivot searching. To disable this heuristic the parameter \verb|suhl| alpar@9: should be set to {\tt GLP\_OFF}.\\ alpar@9: \end{tabular} alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}} alpar@9: \multicolumn{2}{@{}l}{{\tt double eps\_tol} (default: {\tt 1e-15})} \\ alpar@9: &Epsilon tolerance, \verb|eps_tol| $\geq$ 0, used on computing alpar@9: $LU$-factorization of the basis matrix. If an element of the active alpar@9: submatrix of factor $U$ is less than \verb|eps_tol| in the magnitude, alpar@9: it is replaced by exact zero.\\ alpar@9: \end{tabular} alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}} alpar@9: \multicolumn{2}{@{}l}{{\tt double max\_gro} (default: {\tt 1e+10})} \\ alpar@9: &Maximal growth of elements of factor $U$, \verb|max_gro| $\geq$ 1, alpar@9: allowable on computing $LU$-factorization of the basis matrix. If on alpar@9: some elimination step the ratio $u_{big}/b_{max}$ (where $u_{big}$ is alpar@9: the largest magnitude of elements of factor $U$ appeared in its active alpar@9: submatrix during all the factorization process, $b_{max}$ is the largest alpar@9: magnitude of elements of the basis matrix to be factorized), the basis alpar@9: matrix is considered as ill-conditioned.\\ alpar@9: \end{tabular} alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}} alpar@9: \multicolumn{2}{@{}l}{{\tt int nfs\_max} (default: {\tt 100})} \\ alpar@9: &Maximal number of additional row-like factors (entries of the eta alpar@9: file), \verb|nfs_max| $\geq$ 1, which can be added to $LU$-factorization alpar@9: of the basis matrix on updating it with the Forrest--Tomlin technique. alpar@9: This parameter is used only once, before $LU$-factorization is computed alpar@9: for the first time, to allocate working arrays. As a rule, each update alpar@9: adds one new factor (however, some updates may need no addition), so alpar@9: this parameter limits the number of updates between refactorizations.\\ alpar@9: \end{tabular} alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}} alpar@9: \multicolumn{2}{@{}l}{{\tt double upd\_tol} (default: {\tt 1e-6})} \\ alpar@9: &Update tolerance, 0 $<$ \verb|upd_tol| $<$ 1, used on updating alpar@9: $LU$-factorization of the basis matrix with the Forrest--Tomlin alpar@9: technique. If after updating the magnitude of some diagonal element alpar@9: $u_{kk}$ of factor $U$ becomes less than alpar@9: ${\tt upd\_tol}\cdot\max(|u_{k*}|, |u_{*k}|)$, the factorization is alpar@9: considered as inaccurate.\\ alpar@9: \end{tabular} alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}} alpar@9: \multicolumn{2}{@{}l}{{\tt int nrs\_max} (default: {\tt 100})} \\ alpar@9: &Maximal number of additional rows and columns, \verb|nrs_max| $\geq$ 1, alpar@9: which can be added to $LU$-factorization of the basis matrix on updating alpar@9: it with the Schur complement technique. This parameter is used only alpar@9: once, before $LU$-factorization is computed for the first time, to alpar@9: allocate working arrays. As a rule, each update adds one new row and alpar@9: column (however, some updates may need no addition), so this parameter alpar@9: limits the number of updates between refactorizations.\\ alpar@9: \end{tabular} alpar@9: alpar@9: \medskip alpar@9: alpar@9: \noindent\begin{tabular}{@{}p{17pt}@{}p{120.5mm}@{}} alpar@9: \multicolumn{2}{@{}l}{{\tt int rs\_size} (default: {\tt 0})} \\ alpar@9: &The initial size of the Sparse Vector Area, in non-zeros, used to alpar@9: store non-zero elements of additional rows and columns introduced on alpar@9: updating $LU$-factorization of the basis matrix with the Schur alpar@9: complement technique. If this parameter is set to 0, the initial SVA alpar@9: size is determined automatically.\\ alpar@9: \end{tabular} alpar@9: alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% alpar@9: alpar@9: \newpage alpar@9: alpar@9: \subsection{glp\_get\_bhead---retrieve the basis header information} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_get_bhead(glp_prob *lp, int k); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_get_bhead| returns the basis header information alpar@9: for the current basis associated with the specified problem object. alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: If basic variable $(x_B)_k$, $1\leq k\leq m$, is $i$-th auxiliary alpar@9: variable ($1\leq i\leq m$), the routine returns $i$. Otherwise, if alpar@9: $(x_B)_k$ is $j$-th structural variable ($1\leq j\leq n$), the routine alpar@9: returns $m+j$. Here $m$ is the number of rows and $n$ is the number of alpar@9: columns in the problem object. alpar@9: alpar@9: \subsubsection*{Comments} alpar@9: alpar@9: Sometimes the application program may need to know which original alpar@9: (auxiliary and structural) variable correspond to a given basic alpar@9: variable, or, that is the same, which column of the augmented constraint alpar@9: matrix $(I\ |-\!A)$ correspond to a given column of the basis matrix alpar@9: $B$. alpar@9: alpar@9: \def\arraystretch{1} alpar@9: alpar@9: The correspondence is defined as follows:\footnote{For more details see alpar@9: Subsection \ref{basbgd}, page \pageref{basbgd}.} alpar@9: $$\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)= alpar@9: \Pi\left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right) alpar@9: \ \ \Leftrightarrow alpar@9: \ \ \left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)= alpar@9: \Pi^T\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right),$$ alpar@9: where $x_B$ is the vector of basic variables, $x_N$ is the vector of alpar@9: non-basic variables, $x_R$ is the vector of auxiliary variables alpar@9: following in their original order,\footnote{The original order of alpar@9: auxiliary and structural variables is defined by the ordinal numbers alpar@9: of corresponding rows and columns in the problem object.} $x_S$ is the alpar@9: vector of structural variables following in their original order, $\Pi$ alpar@9: is a permutation matrix (which is a component of the basis alpar@9: factorization). alpar@9: alpar@9: Thus, if $(x_B)_k=(x_R)_i$ is $i$-th auxiliary variable, the routine alpar@9: returns $i$, and if $(x_B)_k=(x_S)_j$ is $j$-th structural variable, alpar@9: the routine returns $m+j$, where $m$ is the number of rows in the alpar@9: problem object. alpar@9: alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% alpar@9: alpar@9: \newpage alpar@9: alpar@9: \subsection{glp\_get\_row\_bind---retrieve row index in the basis\\ alpar@9: header} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_get_row_bind(glp_prob *lp, int i); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: The routine \verb|glp_get_row_bind| returns the index $k$ of basic alpar@9: variable $(x_B)_k$, $1\leq k\leq m$, which is $i$-th auxiliary variable alpar@9: (that is, the auxiliary variable corresponding to $i$-th row), alpar@9: $1\leq i\leq m$, in the current basis associated with the specified alpar@9: problem object, where $m$ is the number of rows. However, if $i$-th alpar@9: auxiliary variable is non-basic, the routine returns zero. alpar@9: alpar@9: \subsubsection*{Comments} alpar@9: alpar@9: The routine \verb|glp_get_row_bind| is an inverse to the routine alpar@9: \verb|glp_get_bhead|: if \verb|glp_get_bhead|$(lp,k)$ returns $i$, alpar@9: \verb|glp_get_row_bind|$(lp,i)$ returns $k$, and vice versa. alpar@9: alpar@9: \subsection{glp\_get\_col\_bind---retrieve column index in the basis alpar@9: header} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_get_col_bind(glp_prob *lp, int j); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: The routine \verb|glp_get_col_bind| returns the index $k$ of basic alpar@9: variable $(x_B)_k$, $1\leq k\leq m$, which is $j$-th structural alpar@9: variable (that is, the structural variable corresponding to $j$-th alpar@9: column), $1\leq j\leq n$, in the current basis associated with the alpar@9: specified problem object, where $m$ is the number of rows, $n$ is the alpar@9: number of columns. However, if $j$-th structural variable is non-basic, alpar@9: the routine returns zero. alpar@9: alpar@9: \subsubsection*{Comments} alpar@9: alpar@9: The routine \verb|glp_get_col_bind| is an inverse to the routine alpar@9: \verb|glp_get_bhead|: if \verb|glp_get_bhead|$(lp,k)$ returns $m+j$, alpar@9: \verb|glp_get_col_bind|$(lp,j)$ returns $k$, and vice versa. alpar@9: alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% alpar@9: alpar@9: \newpage alpar@9: alpar@9: \subsection{glp\_ftran---perform forward transformation} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: void glp_ftran(glp_prob *lp, double x[]); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_ftran| performs forward transformation (FTRAN), alpar@9: i.e. it solves the system $Bx=b$, where $B$ is the basis matrix alpar@9: associated with the specified problem object, $x$ is the vector of alpar@9: unknowns to be computed, $b$ is the vector of right-hand sides. alpar@9: alpar@9: On entry to the routine elements of the vector $b$ should be stored in alpar@9: locations \verb|x[1]|, \dots, \verb|x[m]|, where $m$ is the number of alpar@9: rows. On exit the routine stores elements of the vector $x$ in the same alpar@9: locations. alpar@9: alpar@9: \subsection{glp\_btran---perform backward transformation} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: void glp_btran(glp_prob *lp, double x[]); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_btran| performs backward transformation (BTRAN), alpar@9: i.e. it solves the system $B^Tx=b$, where $B^T$ is a matrix transposed alpar@9: to the basis matrix $B$ associated with the specified problem object, alpar@9: $x$ is the vector of unknowns to be computed, $b$ is the vector of alpar@9: right-hand sides. alpar@9: alpar@9: On entry to the routine elements of the vector $b$ should be stored in alpar@9: locations \verb|x[1]|, \dots, \verb|x[m]|, where $m$ is the number of alpar@9: rows. On exit the routine stores elements of the vector $x$ in the same alpar@9: locations. alpar@9: alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% alpar@9: alpar@9: \newpage alpar@9: alpar@9: \subsection{glp\_warm\_up---``warm up'' LP basis} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_warm_up(glp_prob *P); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_warm_up| ``warms up'' the LP basis for the alpar@9: specified problem object using current statuses assigned to rows and alpar@9: columns (that is, to auxiliary and structural variables). alpar@9: alpar@9: This operation includes computing factorization of the basis matrix alpar@9: (if it does not exist), computing primal and dual components of basic alpar@9: solution, and determining the solution status. alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: \begin{tabular}{@{}p{25mm}p{97.3mm}@{}} alpar@9: 0 & The operation has been successfully performed.\\ alpar@9: \verb|GLP_EBADB| & The basis matrix is invalid, because the number of alpar@9: basic (auxiliary and structural) variables is not the same as the number alpar@9: of rows in the problem object.\\ alpar@9: \verb|GLP_ESING| & The basis matrix is singular within the working alpar@9: precision.\\ alpar@9: \verb|GLP_ECOND| & The basis matrix is ill-conditioned, i.e. its alpar@9: condition number is too large.\\ alpar@9: \end{tabular} alpar@9: alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% alpar@9: alpar@9: \newpage alpar@9: alpar@9: \section{Simplex tableau routines} alpar@9: alpar@9: \subsection{glp\_eval\_tab\_row---compute row of the tableau} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_eval_tab_row(glp_prob *lp, int k, int ind[], alpar@9: double val[]); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_eval_tab_row| computes a row of the current alpar@9: simplex tableau (see Subsection 3.1.1, formula (3.12)), which (row) alpar@9: corresponds to some basic variable specified by the parameter $k$ as alpar@9: follows: if $1\leq k\leq m$, the basic variable is $k$-th auxiliary alpar@9: variable, and if $m+1\leq k\leq m+n$, the basic variable is $(k-m)$-th alpar@9: structural variable, where $m$ is the number of rows and $n$ is the alpar@9: number of columns in the specified problem object. The basis alpar@9: factorization must exist. alpar@9: alpar@9: The computed row shows how the specified basic variable depends on alpar@9: non-basic variables: alpar@9: $$x_k=(x_B)_i=\xi_{i1}(x_N)_1+\xi_{i2}(x_N)_2+\dots+\xi_{in}(x_N)_n,$$ alpar@9: where $\xi_{i1}$, $\xi_{i2}$, \dots, $\xi_{in}$ are elements of the alpar@9: simplex table row, $(x_N)_1$, $(x_N)_2$, \dots, $(x_N)_n$ are non-basic alpar@9: (auxiliary and structural) variables. alpar@9: alpar@9: The routine stores column indices and corresponding numeric values of alpar@9: non-zero elements of the computed row in unordered sparse format in alpar@9: locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|, alpar@9: \dots, \verb|val[len]|, respectively, where $0\leq{\tt len}\leq n$ is alpar@9: the number of non-zero elements in the row returned on exit. alpar@9: alpar@9: Element indices stored in the array \verb|ind| have the same sense as alpar@9: index $k$, i.e. indices 1 to $m$ denote auxiliary variables while alpar@9: indices $m+1$ to $m+n$ denote structural variables (all these variables alpar@9: are obviously non-basic by definition). alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: The routine \verb|glp_eval_tab_row| returns \verb|len|, which is the alpar@9: number of non-zero elements in the simplex table row stored in the alpar@9: arrays \verb|ind| and \verb|val|. alpar@9: alpar@9: \subsubsection*{Comments} alpar@9: alpar@9: A row of the simplex table is computed as follows. At first, the alpar@9: routine checks that the specified variable $x_k$ is basic and uses the alpar@9: permutation matrix $\Pi$ (3.7) to determine index $i$ of basic variable alpar@9: $(x_B)_i$, which corresponds to $x_k$. alpar@9: alpar@9: The row to be computed is $i$-th row of the matrix $\Xi$ (3.12), alpar@9: therefore: alpar@9: $$\xi_i=e_i^T\Xi=-e_i^TB^{-1}N=-(B^{-T}e_i)^TN,$$ alpar@9: where $e_i$ is $i$-th unity vector. So the routine performs BTRAN to alpar@9: obtain $i$-th row of the inverse $B^{-1}$: alpar@9: $$\varrho_i=B^{-T}e_i,$$ alpar@9: and then computes elements of the simplex table row as inner products: alpar@9: $$\xi_{ij}=-\varrho_i^TN_j,\ \ j=1,2,\dots,n,$$ alpar@9: where $N_j$ is $j$-th column of matrix $N$ (3.9), which (column) alpar@9: corresponds to non-basic variable $(x_N)_j$. The permutation matrix alpar@9: $\Pi$ is used again to convert indices $j$ of non-basic columns to alpar@9: original ordinal numbers of auxiliary and structural variables. alpar@9: alpar@9: \subsection{glp\_eval\_tab\_col---compute column of the tableau} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_eval_tab_col(glp_prob *lp, int k, int ind[], alpar@9: double val[]); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_eval_tab_col| computes a column of the current alpar@9: simplex tableau (see Subsection 3.1.1, formula (3.12)), which (column) alpar@9: corresponds to some non-basic variable specified by the parameter $k$: alpar@9: if $1\leq k\leq m$, the non-basic variable is $k$-th auxiliary variable, alpar@9: and if $m+1\leq k\leq m+n$, the non-basic variable is $(k-m)$-th alpar@9: structural variable, where $m$ is the number of rows and $n$ is the alpar@9: number of columns in the specified problem object. The basis alpar@9: factorization must exist. alpar@9: alpar@9: The computed column shows how basic variables depends on the specified alpar@9: non-basic variable $x_k=(x_N)_j$: alpar@9: $$ alpar@9: \begin{array}{r@{\ }c@{\ }l@{\ }l} alpar@9: (x_B)_1&=&\dots+\xi_{1j}(x_N)_j&+\dots\\ alpar@9: (x_B)_2&=&\dots+\xi_{2j}(x_N)_j&+\dots\\ alpar@9: .\ \ .&.&.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\\ alpar@9: (x_B)_m&=&\dots+\xi_{mj}(x_N)_j&+\dots\\ alpar@9: \end{array} alpar@9: $$ alpar@9: where $\xi_{1j}$, $\xi_{2j}$, \dots, $\xi_{mj}$ are elements of the alpar@9: simplex table column, $(x_B)_1$, $(x_B)_2$, \dots, $(x_B)_m$ are basic alpar@9: (auxiliary and structural) variables. alpar@9: alpar@9: The routine stores row indices and corresponding numeric values of alpar@9: non-zero elements of the computed column in unordered sparse format in alpar@9: locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|, alpar@9: \dots, \verb|val[len]|, respectively, where $0\leq{\tt len}\leq m$ is alpar@9: the number of non-zero elements in the column returned on exit. alpar@9: alpar@9: Element indices stored in the array \verb|ind| have the same sense as alpar@9: index $k$, i.e. indices 1 to $m$ denote auxiliary variables while alpar@9: indices $m+1$ to $m+n$ denote structural variables (all these variables alpar@9: are obviously basic by definition). alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: The routine \verb|glp_eval_tab_col| returns \verb|len|, which is the alpar@9: number of non-zero elements in the simplex table column stored in the alpar@9: arrays \verb|ind| and \verb|val|. alpar@9: alpar@9: \subsubsection*{Comments} alpar@9: alpar@9: A column of the simplex table is computed as follows. At first, the alpar@9: routine checks that the specified variable $x_k$ is non-basic and uses alpar@9: the permutation matrix $\Pi$ (3.7) to determine index $j$ of non-basic alpar@9: variable $(x_N)_j$, which corresponds to $x_k$. alpar@9: alpar@9: The column to be computed is $j$-th column of the matrix $\Xi$ (3.12), alpar@9: therefore: alpar@9: $$\Xi_j=\Xi e_j=-B^{-1}Ne_j=-B^{-1}N_j,$$ alpar@9: where $e_j$ is $j$-th unity vector, $N_j$ is $j$-th column of matrix alpar@9: $N$ (3.9). So the routine performs FTRAN to transform $N_j$ to the alpar@9: simplex table column $\Xi_j=(\xi_{ij})$ and uses the permutation matrix alpar@9: $\Pi$ to convert row indices $i$ to original ordinal numbers of alpar@9: auxiliary and structural variables. alpar@9: alpar@9: \newpage alpar@9: alpar@9: \subsection{glp\_transform\_row---transform explicitly specified\\ alpar@9: row} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_transform_row(glp_prob *P, int len, int ind[], alpar@9: double val[]); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_transform_row| performs the same operation as the alpar@9: routine \verb|glp_eval_tab_row| with exception that the row to be alpar@9: transformed is specified explicitly as a sparse vector. alpar@9: alpar@9: The explicitly specified row may be thought as a linear form: alpar@9: $$x=a_1x_{m+1}+a_2x_{m+2}+\dots+a_nx_{m+n},$$ alpar@9: where $x$ is an auxiliary variable for this row, $a_j$ are coefficients alpar@9: of the linear form, $x_{m+j}$ are structural variables. alpar@9: alpar@9: On entry column indices and numerical values of non-zero coefficients alpar@9: $a_j$ of the specified row should be placed in locations \verb|ind[1]|, alpar@9: \dots, \verb|ind[len]| and \verb|val[1]|, \dots, \verb|val[len]|, where alpar@9: \verb|len| is number of non-zero coefficients. alpar@9: alpar@9: This routine uses the system of equality constraints and the current alpar@9: basis in order to express the auxiliary variable $x$ through the current alpar@9: non-basic variables (as if the transformed row were added to the problem alpar@9: object and the auxiliary variable $x$ were basic), i.e. the resultant alpar@9: row has the form: alpar@9: $$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n,$$ alpar@9: where $\xi_j$ are influence coefficients, $(x_N)_j$ are non-basic alpar@9: (auxiliary and structural) variables, $n$ is the number of columns in alpar@9: the problem object. alpar@9: alpar@9: On exit the routine stores indices and numerical values of non-zero alpar@9: coefficients $\xi_j$ of the resultant row in locations \verb|ind[1]|, alpar@9: \dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|, alpar@9: where $0\leq{\tt len'}\leq n$ is the number of non-zero coefficients in alpar@9: the resultant row returned by the routine. Note that indices of alpar@9: non-basic variables stored in the array \verb|ind| correspond to alpar@9: original ordinal numbers of variables: indices 1 to $m$ mean auxiliary alpar@9: variables and indices $m+1$ to $m+n$ mean structural ones. alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: The routine \verb|glp_transform_row| returns \verb|len'|, the number of alpar@9: non-zero coefficients in the resultant row stored in the arrays alpar@9: \verb|ind| and \verb|val|. alpar@9: alpar@9: \subsection{glp\_transform\_col---transform explicitly specified\\ alpar@9: column} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_transform_col(glp_prob *P, int len, int ind[], alpar@9: double val[]); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_transform_col| performs the same operation as the alpar@9: routine \verb|glp_eval_tab_col| with exception that the column to be alpar@9: transformed is specified explicitly as a sparse vector. alpar@9: alpar@9: The explicitly specified column may be thought as it were added to alpar@9: the original system of equality constraints: alpar@9: $$ alpar@9: \begin{array}{l@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r} alpar@9: x_1&=&a_{11}x_{m+1}&+\dots+&a_{1n}x_{m+n}&+&a_1x \\ alpar@9: x_2&=&a_{21}x_{m+1}&+\dots+&a_{2n}x_{m+n}&+&a_2x \\ alpar@9: \multicolumn{7}{c} alpar@9: {.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\ alpar@9: x_m&=&a_{m1}x_{m+1}&+\dots+&a_{mn}x_{m+n}&+&a_mx \\ alpar@9: \end{array} alpar@9: $$ alpar@9: where $x_i$ are auxiliary variables, $x_{m+j}$ are structural variables alpar@9: (presented in the problem object), $x$ is a structural variable for the alpar@9: explicitly specified column, $a_i$ are constraint coefficients at $x$. alpar@9: alpar@9: On entry row indices and numerical values of non-zero coefficients alpar@9: $a_i$ of the specified column should be placed in locations alpar@9: \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|, \dots, alpar@9: \verb|val[len]|, where \verb|len| is number of non-zero coefficients. alpar@9: alpar@9: This routine uses the system of equality constraints and the current alpar@9: basis in order to express the current basic variables through the alpar@9: structural variable $x$ (as if the transformed column were added to the alpar@9: problem object and the variable $x$ were non-basic): alpar@9: $$ alpar@9: \begin{array}{l@{\ }c@{\ }r} alpar@9: (x_B)_1&=\dots+&\xi_{1}x\\ alpar@9: (x_B)_2&=\dots+&\xi_{2}x\\ alpar@9: \multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\ alpar@9: (x_B)_m&=\dots+&\xi_{m}x\\ alpar@9: \end{array} alpar@9: $$ alpar@9: where $\xi_i$ are influence coefficients, $x_B$ are basic (auxiliary alpar@9: and structural) variables, $m$ is the number of rows in the problem alpar@9: object. alpar@9: alpar@9: On exit the routine stores indices and numerical values of non-zero alpar@9: coefficients $\xi_i$ of the resultant column in locations \verb|ind[1]|, alpar@9: \dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|, alpar@9: where $0\leq{\tt len'}\leq m$ is the number of non-zero coefficients in alpar@9: the resultant column returned by the routine. Note that indices of basic alpar@9: variables stored in the array \verb|ind| correspond to original ordinal alpar@9: numbers of variables, i.e. indices 1 to $m$ mean auxiliary variables, alpar@9: indices $m+1$ to $m+n$ mean structural ones. alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: The routine \verb|glp_transform_col| returns \verb|len'|, the number of alpar@9: non-zero coefficients in the resultant column stored in the arrays alpar@9: \verb|ind| and \verb|val|. alpar@9: alpar@9: \subsection{glp\_prim\_rtest---perform primal ratio test} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_prim_rtest(glp_prob *P, int len, const int ind[], alpar@9: const double val[], int dir, double eps); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_prim_rtest| performs the primal ratio test using alpar@9: an explicitly specified column of the simplex table. alpar@9: alpar@9: The current basic solution associated with the LP problem object must be alpar@9: primal feasible. alpar@9: alpar@9: The explicitly specified column of the simplex table shows how the basic alpar@9: variables $x_B$ depend on some non-basic variable $x$ (which is not alpar@9: necessarily presented in the problem object): alpar@9: $$ alpar@9: \begin{array}{l@{\ }c@{\ }r} alpar@9: (x_B)_1&=\dots+&\xi_{1}x\\ alpar@9: (x_B)_2&=\dots+&\xi_{2}x\\ alpar@9: \multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\ alpar@9: (x_B)_m&=\dots+&\xi_{m}x\\ alpar@9: \end{array} alpar@9: $$ alpar@9: alpar@9: The column is specifed on entry to the routine in sparse format. Ordinal alpar@9: numbers of basic variables $(x_B)_i$ should be placed in locations alpar@9: \verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal number 1 to $m$ alpar@9: denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$ denote alpar@9: structural variables. The corresponding non-zero coefficients $\xi_i$ alpar@9: should be placed in locations \verb|val[1]|, \dots, \verb|val[len]|. The alpar@9: arrays \verb|ind| and \verb|val| are not changed by the routine. alpar@9: alpar@9: The parameter \verb|dir| specifies direction in which the variable $x$ alpar@9: changes on entering the basis: $+1$ means increasing, $-1$ means alpar@9: decreasing. alpar@9: alpar@9: The parameter \verb|eps| is an absolute tolerance (small positive alpar@9: number, say, $10^{-9}$) used by the routine to skip $\xi_i$'s whose alpar@9: magnitude is less than \verb|eps|. alpar@9: alpar@9: The routine determines which basic variable (among those specified in alpar@9: \verb|ind[1]|, \dots, \verb|ind[len]|) reaches its (lower or upper) alpar@9: bound first before any other basic variables do, and which, therefore, alpar@9: should leave the basis in order to keep primal feasibility. alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: The routine \verb|glp_prim_rtest| returns the index, \verb|piv|, in the alpar@9: arrays \verb|ind| and \verb|val| corresponding to the pivot element alpar@9: chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic alpar@9: solution is primal unbounded, and therefore the choice cannot be made, alpar@9: the routine returns zero. alpar@9: alpar@9: \subsubsection*{Comments} alpar@9: alpar@9: If the non-basic variable $x$ is presented in the LP problem object, the alpar@9: input column can be computed with the routine \verb|glp_eval_tab_col|; alpar@9: otherwise, it can be computed with the routine \verb|glp_transform_col|. alpar@9: alpar@9: \subsection{glp\_dual\_rtest---perform dual ratio test} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: int glp_dual_rtest(glp_prob *P, int len, const int ind[], alpar@9: const double val[], int dir, double eps); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_dual_rtest| performs the dual ratio test using alpar@9: an explicitly specified row of the simplex table. alpar@9: alpar@9: The current basic solution associated with the LP problem object must be alpar@9: dual feasible. alpar@9: alpar@9: The explicitly specified row of the simplex table is a linear form alpar@9: that shows how some basic variable $x$ (which is not necessarily alpar@9: presented in the problem object) depends on non-basic variables $x_N$: alpar@9: $$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n.$$ alpar@9: alpar@9: The row is specified on entry to the routine in sparse format. Ordinal alpar@9: numbers of non-basic variables $(x_N)_j$ should be placed in locations alpar@9: \verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal numbers 1 to $m$ alpar@9: denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$ denote alpar@9: structural variables. The corresponding non-zero coefficients $\xi_j$ alpar@9: should be placed in locations \verb|val[1]|, \dots, \verb|val[len]|. alpar@9: The arrays \verb|ind| and \verb|val| are not changed by the routine. alpar@9: alpar@9: The parameter \verb|dir| specifies direction in which the variable $x$ alpar@9: changes on leaving the basis: $+1$ means that $x$ goes on its lower alpar@9: bound, so its reduced cost (dual variable) is increasing (minimization) alpar@9: or decreasing (maximization); $-1$ means that $x$ goes on its upper alpar@9: bound, so its reduced cost is decreasing (minimization) or increasing alpar@9: (maximization). alpar@9: alpar@9: The parameter \verb|eps| is an absolute tolerance (small positive alpar@9: number, say, $10^{-9}$) used by the routine to skip $\xi_j$'s whose alpar@9: magnitude is less than \verb|eps|. alpar@9: alpar@9: The routine determines which non-basic variable (among those specified alpar@9: in \verb|ind[1]|, \dots, \verb|ind[len]|) should enter the basis in alpar@9: order to keep dual feasibility, because its reduced cost reaches the alpar@9: (zero) bound first before this occurs for any other non-basic variables. alpar@9: alpar@9: \subsubsection*{Returns} alpar@9: alpar@9: The routine \verb|glp_dual_rtest| returns the index, \verb|piv|, in the alpar@9: arrays \verb|ind| and \verb|val| corresponding to the pivot element alpar@9: chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic alpar@9: solution is dual unbounded, and therefore the choice cannot be made, alpar@9: the routine returns zero. alpar@9: alpar@9: \subsubsection*{Comments} alpar@9: alpar@9: If the basic variable $x$ is presented in the LP problem object, the alpar@9: input row can be computed with the routine \verb|glp_eval_tab_row|; alpar@9: otherwise, it can be computed with the routine \verb|glp_transform_row|. alpar@9: alpar@9: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% alpar@9: alpar@9: \newpage alpar@9: alpar@9: \section{Post-optimal analysis routines} alpar@9: alpar@9: \subsection{glp\_analyze\_bound---analyze active bound of non-basic alpar@9: variable} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: void glp_analyze_bound(glp_prob *P, int k, double *limit1, alpar@9: int *var1, double *limit2, int *var2); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_analyze_bound| analyzes the effect of varying the alpar@9: active bound of specified non-basic variable. alpar@9: alpar@9: The non-basic variable is specified by the parameter $k$, where alpar@9: $1\leq k\leq m$ means auxiliary variable of corresponding row, and alpar@9: $m+1\leq k\leq m+n$ means structural variable (column). alpar@9: alpar@9: Note that the current basic solution must be optimal, and the basis alpar@9: factorization must exist. alpar@9: alpar@9: Results of the analysis have the following meaning. alpar@9: alpar@9: \verb|value1| is the minimal value of the active bound, at which the alpar@9: basis still remains primal feasible and thus optimal. \verb|-DBL_MAX| alpar@9: means that the active bound has no lower limit. alpar@9: alpar@9: \verb|var1| is the ordinal number of an auxiliary (1 to $m$) or alpar@9: structural ($m+1$ to $m+n$) basic variable, which reaches its bound alpar@9: first and thereby limits further decreasing the active bound being alpar@9: analyzed. if \verb|value1| = \verb|-DBL_MAX|, \verb|var1| is set to 0. alpar@9: alpar@9: \verb|value2| is the maximal value of the active bound, at which the alpar@9: basis still remains primal feasible and thus optimal. \verb|+DBL_MAX| alpar@9: means that the active bound has no upper limit. alpar@9: alpar@9: \verb|var2| is the ordinal number of an auxiliary (1 to $m$) or alpar@9: structural ($m+1$ to $m+n$) basic variable, which reaches its bound alpar@9: first and thereby limits further increasing the active bound being alpar@9: analyzed. if \verb|value2| = \verb|+DBL_MAX|, \verb|var2| is set to 0. alpar@9: alpar@9: The parameters \verb|value1|, \verb|var1|, \verb|value2|, \verb|var2| alpar@9: can be specified as \verb|NULL|, in which case corresponding information alpar@9: is not stored. alpar@9: alpar@9: \newpage alpar@9: alpar@9: \subsection{glp\_analyze\_coef---analyze objective coefficient at basic alpar@9: variable} alpar@9: alpar@9: \subsubsection*{Synopsis} alpar@9: alpar@9: \begin{verbatim} alpar@9: void glp_analyze_coef(glp_prob *P, int k, double *coef1, alpar@9: int *var1, double *value1, double *coef2, int *var2, alpar@9: double *value2); alpar@9: \end{verbatim} alpar@9: alpar@9: \subsubsection*{Description} alpar@9: alpar@9: The routine \verb|glp_analyze_coef| analyzes the effect of varying the alpar@9: objective coefficient at specified basic variable. alpar@9: alpar@9: The basic variable is specified by the parameter $k$, where alpar@9: $1\leq k\leq m$ means auxiliary variable of corresponding row, and alpar@9: $m+1\leq k\leq m+n$ means structural variable (column). alpar@9: alpar@9: Note that the current basic solution must be optimal, and the basis alpar@9: factorization must exist. alpar@9: alpar@9: Results of the analysis have the following meaning. alpar@9: alpar@9: \verb|coef1| is the minimal value of the objective coefficient, at alpar@9: which the basis still remains dual feasible and thus optimal. alpar@9: \verb|-DBL_MAX| means that the objective coefficient has no lower limit. alpar@9: alpar@9: \verb|var1| is the ordinal number of an auxiliary (1 to $m$) or alpar@9: structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost alpar@9: reaches its zero bound first and thereby limits further decreasing the alpar@9: objective coefficient being analyzed. If \verb|coef1| = \verb|-DBL_MAX|, alpar@9: \verb|var1| is set to 0. alpar@9: alpar@9: \verb|value1| is value of the basic variable being analyzed in an alpar@9: adjacent basis, which is defined as follows. Let the objective alpar@9: coefficient reaches its minimal value (\verb|coef1|) and continues alpar@9: decreasing. Then the reduced cost of the limiting non-basic variable alpar@9: (\verb|var1|) becomes dual infeasible and the current basis becomes alpar@9: non-optimal that forces the limiting non-basic variable to enter the alpar@9: basis replacing there some basic variable that leaves the basis to keep alpar@9: primal feasibility. Should note that on determining the adjacent basis alpar@9: current bounds of the basic variable being analyzed are ignored as if alpar@9: it were free (unbounded) variable, so it cannot leave the basis. It may alpar@9: happen that no dual feasible adjacent basis exists, in which case alpar@9: \verb|value1| is set to \verb|-DBL_MAX| or \verb|+DBL_MAX|. alpar@9: alpar@9: \verb|coef2| is the maximal value of the objective coefficient, at alpar@9: which the basis still remains dual feasible and thus optimal. alpar@9: \verb|+DBL_MAX| means that the objective coefficient has no upper limit. alpar@9: alpar@9: \verb|var2| is the ordinal number of an auxiliary (1 to $m$) or alpar@9: structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost alpar@9: reaches its zero bound first and thereby limits further increasing the alpar@9: objective coefficient being analyzed. If \verb|coef2| = \verb|+DBL_MAX|, alpar@9: \verb|var2| is set to 0. alpar@9: alpar@9: \verb|value2| is value of the basic variable being analyzed in an alpar@9: adjacent basis, which is defined exactly in the same way as alpar@9: \verb|value1| above with exception that now the objective coefficient alpar@9: is increasing. alpar@9: alpar@9: The parameters \verb|coef1|, \verb|var1|, \verb|value1|, \verb|coef2|, alpar@9: \verb|var2|, \verb|value2| can be specified as \verb|NULL|, in which alpar@9: case corresponding information is not stored. alpar@9: alpar@9: %* eof *%