You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1392 lines
52 KiB

2 months ago
  1. %* glpk04.tex *%
  2. \chapter{Advanced API Routines}
  3. \section{Background}
  4. \label{basbgd}
  5. Using vector and matrix notations the LP problem (1.1)---(1.3) (see
  6. Section \ref{seclp}, page \pageref{seclp}) can be stated as follows:
  7. \noindent
  8. \hspace{.5in} minimize (or maximize)
  9. $$z=c^Tx_S+c_0\eqno(3.1)$$
  10. \hspace{.5in} subject to linear constraints
  11. $$x_R=Ax_S\eqno(3.2)$$
  12. \hspace{.5in} and bounds of variables
  13. $$
  14. \begin{array}{l@{\ }c@{\ }l@{\ }c@{\ }l}
  15. l_R&\leq&x_R&\leq&u_R\\
  16. l_S&\leq&x_S&\leq&u_S\\
  17. \end{array}\eqno(3.3)
  18. $$
  19. where:
  20. $x_R=(x_1,\dots,x_m)$ is the vector of auxiliary variables;
  21. $x_S=(x_{m+1},\dots,x_{m+n})$ is the vector of structural variables;
  22. $z$ is the objective function;
  23. $c=(c_1,\dots,c_n)$ is the vector of objective coefficients;
  24. $c_0$ is the constant term (``shift'') of the objective function;
  25. $A=(a_{11},\dots,a_{mn})$ is the constraint matrix;
  26. $l_R=(l_1,\dots,l_m)$ is the vector of lower bounds of auxiliary
  27. variables;
  28. $u_R=(u_1,\dots,u_m)$ is the vector of upper bounds of auxiliary
  29. variables;
  30. $l_S=(l_{m+1},\dots,l_{m+n})$ is the vector of lower bounds of
  31. structural variables;
  32. $u_S=(u_{m+1},\dots,u_{m+n})$ is the vector of upper bounds of
  33. structural variables.
  34. From the simplex method's standpoint there is no difference between
  35. auxiliary and structural variables. This allows combining all these
  36. variables into one vector that leads to the following problem
  37. statement:
  38. \newpage
  39. \noindent
  40. \hspace{.5in} minimize (or maximize)
  41. $$z=(0\ |\ c)^Tx+c_0\eqno(3.4)$$
  42. \hspace{.5in} subject to linear constraints
  43. $$(I\ |-\!A)x=0\eqno(3.5)$$
  44. \hspace{.5in} and bounds of variables
  45. $$l\leq x\leq u\eqno(3.6)$$
  46. where:
  47. $x=(x_R\ |\ x_S)$ is the $(m+n)$-vector of (all) variables;
  48. $(0\ |\ c)$ is the $(m+n)$-vector of objective
  49. coefficients;\footnote{Subvector 0 corresponds to objective
  50. coefficients at auxiliary variables.}
  51. $(I\ |-\!A)$ is the {\it augmented} constraint
  52. $m\times(m+n)$-matrix;\footnote{Note that due to auxiliary variables
  53. matrix $(I\ |-\!A)$ contains the unity submatrix and therefore has full
  54. rank. This means, in particular, that the system (3.5) has no linearly
  55. dependent constraints.}
  56. $l=(l_R\ |\ l_S)$ is the $(m+n)$-vector of lower bounds of (all)
  57. variables;
  58. $u=(u_R\ |\ u_S)$ is the $(m+n)$-vector of upper bounds of (all)
  59. variables.
  60. By definition an {\it LP basic solution} geometrically is a point in
  61. the space of all variables, which is the intersection of hyperplanes
  62. corresponding to active constraints\footnote{A constraint is called
  63. {\it active} if at a given point it is satisfied as equality, otherwise
  64. it is called {\it inactive}.}. The space of all variables has the
  65. dimension $m+n$, therefore, to define some basic solution we have to
  66. define $m+n$ active constraints. Note that $m$ constraints (3.5) being
  67. linearly independent equalities are always active, so remaining $n$
  68. active constraints can be chosen only from bound constraints (3.6).
  69. A variable is called {\it non-basic}, if its (lower or upper) bound is
  70. active, otherwise it is called {\it basic}. Since, as was said above,
  71. exactly $n$ bound constraints must be active, in any basic solution
  72. there are always $n$ non-basic variables and $m$ basic variables.
  73. (Note that a free variable also can be non-basic. Although such
  74. variable has no bounds, we can think it as the difference between two
  75. non-negative variables, which both are non-basic in this case.)
  76. Now consider how to determine numeric values of all variables for a
  77. given basic solution.
  78. Let $\Pi$ be an appropriate permutation matrix of the order $(m+n)$.
  79. Then we can write:
  80. $$\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=
  81. \Pi\left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)=\Pi x,
  82. \eqno(3.7)$$
  83. where $x_B$ is the vector of basic variables, $x_N$ is the vector of
  84. non-basic variables, $x=(x_R\ |\ x_S)$ is the vector of all variables
  85. in the original order. In this case the system of linear constraints
  86. (3.5) can be rewritten as follows:
  87. $$(I\ |-\!A)\Pi^T\Pi x=0\ \ \ \Rightarrow\ \ \ (B\ |\ N)
  88. \left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=0,\eqno(3.8)$$
  89. where
  90. $$(B\ |\ N)=(I\ |-\!A)\Pi^T.\eqno(3.9)$$
  91. %\newpage
  92. Matrix $B$ is a square non-singular $m\times m$-matrix, which is
  93. composed from columns of the augmented constraint matrix corresponding
  94. to basic variables. It is called the {\it basis matrix} or simply the
  95. {\it basis}. Matrix $N$ is a rectangular $m\times n$-matrix, which is
  96. composed from columns of the augmented constraint matrix corresponding
  97. to non-basic variables.
  98. From (3.8) it follows that:
  99. $$Bx_B+Nx_N=0,\eqno(3.10)$$
  100. therefore,
  101. $$x_B=-B^{-1}Nx_N.\eqno(3.11)$$
  102. Thus, the formula (3.11) shows how to determine numeric values of basic
  103. variables $x_B$ assuming that non-basic variables $x_N$ are fixed on
  104. their active bounds.
  105. The $m\times n$-matrix
  106. $$\Xi=-B^{-1}N,\eqno(3.12)$$
  107. which appears in (3.11), is called the {\it simplex
  108. tableau}.\footnote{This definition corresponds to the GLPK
  109. implementation.} It shows how basic variables depend on non-basic
  110. variables:
  111. $$x_B=\Xi x_N.\eqno(3.13)$$
  112. The system (3.13) is equivalent to the system (3.5) in the sense that
  113. they both define the same set of points in the space of (primal)
  114. variables, which satisfy to these systems. If, moreover, values of all
  115. basic variables satisfy to their bound constraints (3.3), the
  116. corresponding basic solution is called {\it (primal) feasible},
  117. otherwise {\it (primal) infeasible}. It is understood that any (primal)
  118. feasible basic solution satisfy to all constraints (3.2) and (3.3).
  119. The LP theory says that if LP has optimal solution, it has (at least
  120. one) basic feasible solution, which corresponds to the optimum. And the
  121. most natural way to determine whether a given basic solution is optimal
  122. or not is to use the Karush---Kuhn---Tucker optimality conditions.
  123. \def\arraystretch{1.5}
  124. For the problem statement (3.4)---(3.6) the optimality conditions are
  125. the following:\footnote{These conditions can be appiled to any solution,
  126. not only to a basic solution.}
  127. $$(I\ |-\!A)x=0\eqno(3.14)$$
  128. $$(I\ |-\!A)^T\pi+\lambda_l+\lambda_u=\nabla z=(0\ |\ c)^T\eqno(3.15)$$
  129. $$l\leq x\leq u\eqno(3.16)$$
  130. $$\lambda_l\geq 0,\ \ \lambda_u\leq 0\ \ \mbox{(minimization)}
  131. \eqno(3.17)$$
  132. $$\lambda_l\leq 0,\ \ \lambda_u\geq 0\ \ \mbox{(maximization)}
  133. \eqno(3.18)$$
  134. $$(\lambda_l)_k(x_k-l_k)=0,\ \ (\lambda_u)_k(x_k-u_k)=0,\ \ k=1,2,\dots,
  135. m+n\eqno(3.19)$$
  136. where:
  137. $\pi=(\pi_1,\dots,\pi_m)$ is a $m$-vector of Lagrange
  138. multipliers for equality constraints (3.5);
  139. $\lambda_l=[(\lambda_l)_1,\dots,(\lambda_l)_n]$ is a $n$-vector of
  140. Lagrange multipliers for lower bound constraints (3.6);
  141. $\lambda_u=[(\lambda_u)_1,\dots,(\lambda_u)_n]$ is a $n$-vector of
  142. Lagrange multipliers for upper bound constraints (3.6).
  143. %\newpage
  144. Condition (3.14) is the {\it primal} (original) system of equality
  145. constraints (3.5).
  146. Condition (3.15) is the {\it dual} system of equality constraints.
  147. It requires the gradient of the objective function to be a linear
  148. combination of normals to the planes defined by constraints of the
  149. original problem.
  150. Condition (3.16) is the primal (original) system of bound constraints
  151. (3.6).
  152. Condition (3.17) (or (3.18) in case of maximization) is the dual system
  153. of bound constraints.
  154. Condition (3.19) is the {\it complementary slackness condition}. It
  155. requires, for each original (auxiliary or structural) variable $x_k$,
  156. that either its (lower or upper) bound must be active, or zero bound of
  157. the corresponding Lagrange multiplier ($(\lambda_l)_k$ or
  158. $(\lambda_u)_k$) must be active.
  159. In GLPK two multipliers $(\lambda_l)_k$ and $(\lambda_u)_k$ for each
  160. primal variable $x_k$, $k=1,\dots,m+n$, are combined into one
  161. multiplier:
  162. $$\lambda_k=(\lambda_l)_k+(\lambda_u)_k,\eqno(3.20)$$
  163. which is called a {\it dual variable} for $x_k$. This {\it cannot} lead
  164. to an ambiguity, because both lower and upper bounds of $x_k$ cannot be
  165. active at the same time,\footnote{If $x_k$ is a fixed variable, we can
  166. think it as double-bounded variable $l_k\leq x_k\leq u_k$, where
  167. $l_k=u_k.$} so at least one of $(\lambda_l)_k$ and $(\lambda_u)_k$ must
  168. be equal to zero, and because these multipliers have different signs,
  169. the combined multiplier, which is their sum, uniquely defines each of
  170. them.
  171. \def\arraystretch{1}
  172. Using dual variables $\lambda_k$ the dual system of bound constraints
  173. (3.17) and (3.18) can be written in the form of so called {\it ``rule of
  174. signs''} as follows:
  175. \medskip
  176. \begin{center}
  177. \begin{tabular}{|@{\,}c@{$\,$}|@{$\,$}c@{$\,$}|@{$\,$}c@{$\,$}|
  178. @{$\,$}c|c@{$\,$}|@{$\,$}c@{$\,$}|@{$\,$}c@{$\,$}|}
  179. \hline
  180. Original bound&\multicolumn{3}{c|}{Minimization}&\multicolumn{3}{c|}
  181. {Maximization}\\
  182. \cline{2-7}
  183. constraint&$(\lambda_l)_k$&$(\lambda_u)_k$&$(\lambda_l)_k+
  184. (\lambda_u)_k$&$(\lambda_l)_k$&$(\lambda_u)_k$&$(\lambda_l)_k+
  185. (\lambda_u)_k$\\
  186. \hline
  187. $-\infty<x_k<+\infty$&$=0$&$=0$&$\lambda_k=0$&$=0$&$=0$&$\lambda_k=0$\\
  188. $x_k\geq l_k$&$\geq 0$&$=0$&$\lambda_k\geq 0$&$\leq 0$&$=0$&$\lambda_k
  189. \leq0$\\
  190. $x_k\leq u_k$&$=0$&$\leq 0$&$\lambda_k\leq 0$&$=0$&$\geq 0$&$\lambda_k
  191. \geq0$\\
  192. $l_k\leq x_k\leq u_k$&$\geq 0$& $\leq 0$& $-\infty\!<\!\lambda_k\!<
  193. \!+\infty$
  194. &$\leq 0$& $\geq 0$& $-\infty\!<\!\lambda_k\!<\!+\infty$\\
  195. $x_k=l_k=u_k$&$\geq 0$& $\leq 0$& $-\infty\!<\!\lambda_k\!<\!+\infty$&
  196. $\leq 0$&
  197. $\geq 0$& $-\infty\!<\!\lambda_k\!<\!+\infty$\\
  198. \hline
  199. \end{tabular}
  200. \end{center}
  201. \medskip
  202. May note that each primal variable $x_k$ has its dual counterpart
  203. $\lambda_k$ and vice versa. This allows applying the same partition for
  204. the vector of dual variables as (3.7):
  205. $$\left(\begin{array}{@{}c@{}}\lambda_B\\\lambda_N\\\end{array}\right)=
  206. \Pi\lambda,\eqno(3.21)$$
  207. where $\lambda_B$ is a vector of dual variables for basic variables
  208. $x_B$, $\lambda_N$ is a vector of dual variables for non-basic variables
  209. $x_N$.
  210. By definition, bounds of basic variables are inactive constraints, so in
  211. any basic solution $\lambda_B=0$. Corresponding values of dual variables
  212. $\lambda_N$ for non-basic variables $x_N$ can be determined in the
  213. following way. From the dual system (3.15) we have:
  214. $$(I\ |-\!A)^T\pi+\lambda=(0\ |\ c)^T,\eqno(3.22)$$
  215. so multiplying both sides of (3.22) by matrix $\Pi$ gives:
  216. $$\Pi(I\ |-\!A)^T\pi+\Pi\lambda=\Pi(0\ |\ c)^T.\eqno(3.23)$$
  217. From (3.9) it follows that
  218. $$\Pi(I\ |-\!A)^T=[(I\ |-\!A)\Pi^T]^T=(B\ |\ N)^T.\eqno(3.24)$$
  219. Further, we can apply the partition (3.7) also to the vector of
  220. objective coefficients (see (3.4)):
  221. $$\left(\begin{array}{@{}c@{}}c_B\\c_N\\\end{array}\right)=
  222. \Pi\left(\begin{array}{@{}c@{}}0\\c\\\end{array}\right),\eqno(3.25)$$
  223. where $c_B$ is a vector of objective coefficients at basic variables,
  224. $c_N$ is a vector of objective coefficients at non-basic variables.
  225. Now, substituting (3.24), (3.21), and (3.25) into (3.23), leads to:
  226. $$(B\ |\ N)^T\pi+(\lambda_B\ |\ \lambda_N)^T=(c_B\ |\ c_N)^T,
  227. \eqno(3.26)$$
  228. and transposing both sides of (3.26) gives the system:
  229. $$\left(\begin{array}{@{}c@{}}B^T\\N^T\\\end{array}\right)\pi+
  230. \left(\begin{array}{@{}c@{}}\lambda_B\\\lambda_N\\\end{array}\right)=
  231. \left(\begin{array}{@{}c@{}}c_B\\c_T\\\end{array}\right),\eqno(3.27)$$
  232. which can be written as follows:
  233. $$\left\{
  234. \begin{array}{@{\ }r@{\ }c@{\ }r@{\ }c@{\ }l@{\ }}
  235. B^T\pi&+&\lambda_B&=&c_B\\
  236. N^T\pi&+&\lambda_N&=&c_N\\
  237. \end{array}
  238. \right.\eqno(3.28)
  239. $$
  240. Lagrange multipliers $\pi=(\pi_i)$ correspond to equality constraints
  241. (3.5) and therefore can have any sign. This allows resolving the first
  242. subsystem of (3.28) as follows:\footnote{$B^{-T}$ means $(B^T)^{-1}=
  243. (B^{-1})^T$.}
  244. $$\pi=B^{-T}(c_B-\lambda_B)=-B^{-T}\lambda_B+B^{-T}c_B,\eqno(3.29)$$
  245. and substitution of $\pi$ from (3.29) into the second subsystem of
  246. (3.28) gives:
  247. $$\lambda_N=-N^T\pi+c_N=N^TB^{-T}\lambda_B+(c_N-N^TB^{-T}c_B).
  248. \eqno(3.30)$$
  249. The latter system can be written in the following final form:
  250. $$\lambda_N=-\Xi^T\lambda_B+d,\eqno(3.31)$$
  251. where $\Xi$ is the simplex tableau (see (3.12)), and
  252. $$d=c_N-N^TB^{-T}c_B=c_N+\Xi^Tc_B\eqno(3.32)$$
  253. is the vector of so called {\it reduced costs} of non-basic variables.
  254. Above it was said that in any basic solution $\lambda_B=0$, so
  255. $\lambda_N=d$ as it follows from (3.31).
  256. The system (3.31) is equivalent to the system (3.15) in the sense that
  257. they both define the same set of points in the space of dual variables
  258. $\lambda$, which satisfy to these systems. If, moreover, values of all
  259. dual variables $\lambda_N$ (i.e. reduced costs $d$) satisfy to their
  260. bound constraints (i.e. to the ``rule of signs''; see the table above),
  261. the corresponding basic solution is called {\it dual feasible},
  262. otherwise {\it dual infeasible}. It is understood that any dual feasible
  263. solution satisfy to all constraints (3.15) and (3.17) (or (3.18) in case
  264. of maximization).
  265. It can be easily shown that the complementary slackness condition
  266. (3.19) is always satisfied for {\it any} basic solution.\footnote{Until
  267. double-bounded variables appear.} Therefore, a basic
  268. solution\footnote{It is assumed that a complete basic solution has the
  269. form $(x,\lambda)$, i.e. it includes primal as well as dual variables.}
  270. is {\it optimal} if and only if it is primal and dual feasible, because
  271. in this case it satifies to all the optimality conditions
  272. (3.14)---(3.19).
  273. \def\arraystretch{1.5}
  274. The meaning of reduced costs $d=(d_j)$ of non-basic variables can be
  275. explained in the following way. From (3.4), (3.7), and (3.25) it follows
  276. that:
  277. $$z=c_B^Tx_B+c_N^Tx_N+c_0.\eqno(3.33)$$
  278. Substituting $x_B$ from (3.11) into (3.33) we can eliminate basic
  279. variables and express the objective only through non-basic variables:
  280. $$
  281. \begin{array}{r@{\ }c@{\ }l}
  282. z&=&c_B^T(-B^{-1}Nx_N)+c_N^Tx_N+c_0=\\
  283. &=&(c_N^T-c_B^TB^{-1}N)x_N+c_0=\\
  284. &=&(c_N-N^TB^{-T}c_B)^Tx_N+c_0=\\
  285. &=&d^Tx_N+c_0.
  286. \end{array}\eqno(3.34)
  287. $$
  288. From (3.34) it is seen that reduced cost $d_j$ shows how the objective
  289. function $z$ depends on non-basic variable $(x_N)_j$ in the neighborhood
  290. of the current basic solution, i.e. while the current basis remains
  291. unchanged.
  292. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  293. \newpage
  294. \section{LP basis routines}
  295. \label{lpbasis}
  296. \subsection{glp\_bf\_exists --- check if the basis factorization
  297. exists}
  298. \synopsis
  299. \begin{verbatim}
  300. int glp_bf_exists(glp_prob *P);
  301. \end{verbatim}
  302. \returns
  303. If the basis factorization for the current basis associated with the
  304. specified problem object exists and therefore is available for
  305. computations, the routine \verb|glp_bf_exists| returns non-zero.
  306. Otherwise the routine returns zero.
  307. \para{Comments}
  308. Let the problem object have $m$ rows and $n$ columns. In GLPK the
  309. {\it basis matrix} $B$ is a square non-singular matrix of the order $m$,
  310. whose columns correspond to basic (auxiliary and/or structural)
  311. variables. It is defined by the following main
  312. equality:\footnote{For more details see Subsection \ref{basbgd},
  313. page \pageref{basbgd}.}
  314. $$(B\ |\ N)=(I\ |-\!A)\Pi^T,$$
  315. where $I$ is the unity matrix of the order $m$, whose columns correspond
  316. to auxiliary variables; $A$ is the original constraint
  317. $m\times n$-matrix, whose columns correspond to structural variables;
  318. $(I\ |-\!A)$ is the augmented constraint $m\times(m+n)$-matrix, whose
  319. columns correspond to all (auxiliary and structural) variables
  320. following in the original order; $\Pi$ is a permutation matrix of the
  321. order $m+n$; and $N$ is a rectangular $m\times n$-matrix, whose columns
  322. correspond to non-basic (auxiliary and/or structural) variables.
  323. For various reasons it may be necessary to solve linear systems with
  324. matrix $B$. To provide this possibility the GLPK implementation
  325. maintains an invertable form of $B$ (that is, some representation of
  326. $B^{-1}$) called the {\it basis factorization}, which is an internal
  327. component of the problem object. Typically, the basis factorization is
  328. computed by the simplex solver, which keeps it in the problem object
  329. to be available for other computations.
  330. Should note that any changes in the problem object, which affects the
  331. basis matrix (e.g. changing the status of a row or column, changing
  332. a basic column of the constraint matrix, removing an active constraint,
  333. etc.), invalidates the basis factorization. So before calling any API
  334. routine, which uses the basis factorization, the application program
  335. must make sure (using the routine \verb|glp_bf_exists|) that the
  336. factorization exists and therefore available for computations.
  337. %\newpage
  338. \subsection{glp\_factorize --- compute the basis factorization}
  339. \synopsis
  340. \begin{verbatim}
  341. int glp_factorize(glp_prob *P);
  342. \end{verbatim}
  343. \description
  344. The routine \verb|glp_factorize| computes the basis factorization for
  345. the current basis associated with the specified problem
  346. object.\footnote{The current basis is defined by the current statuses
  347. of rows (auxiliary variables) and columns (structural variables).}
  348. The basis factorization is computed from ``scratch'' even if it exists,
  349. so the application program may use the routine \verb|glp_bf_exists|,
  350. and, if the basis factorization already exists, not to call the routine
  351. \verb|glp_factorize| to prevent an extra work.
  352. The routine \verb|glp_factorize| {\it does not} compute components of
  353. the basic solution (i.e. primal and dual values).
  354. \returns
  355. \begin{retlist}
  356. 0 & The basis factorization has been successfully computed.\\
  357. \verb|GLP_EBADB| & The basis matrix is invalid, because the number of
  358. basic (auxiliary and structural) variables is not the same as the number
  359. of rows in the problem object.\\
  360. \verb|GLP_ESING| & The basis matrix is singular within the working
  361. precision.\\
  362. \verb|GLP_ECOND| & The basis matrix is ill-conditioned, i.e. its
  363. condition number is too large.\\
  364. \end{retlist}
  365. \subsection{glp\_bf\_updated --- check if the basis factorization has
  366. been updated}
  367. \synopsis
  368. \begin{verbatim}
  369. int glp_bf_updated(glp_prob *P);
  370. \end{verbatim}
  371. \returns
  372. If the basis factorization has been just computed from ``scratch'', the
  373. routine \verb|glp_bf_updated| returns zero. Otherwise, if the
  374. factorization has been updated at least once, the routine returns
  375. non-zero.
  376. \para{Comments}
  377. {\it Updating} the basis factorization means recomputing it to reflect
  378. changes in the basis matrix. For example, on every iteration of the
  379. simplex method some column of the current basis matrix is replaced by
  380. a new column that gives a new basis matrix corresponding to the
  381. adjacent basis. In this case computing the basis factorization for the
  382. adjacent basis from ``scratch'' (as the routine \verb|glp_factorize|
  383. does) would be too time-consuming.
  384. On the other hand, since the basis factorization update is a numeric
  385. computational procedure, applying it many times may lead to
  386. accumulating round-off errors. Therefore the basis is periodically
  387. refactorized (reinverted) from ``scratch'' (with the routine
  388. \verb|glp_factorize|) that allows improving its numerical properties.
  389. The routine \verb|glp_bf_updated| allows determining if the basis
  390. factorization has been updated at least once since it was computed from
  391. ``scratch''.
  392. \subsection{glp\_get\_bfcp --- retrieve basis factorization control
  393. parameters}
  394. \synopsis
  395. \begin{verbatim}
  396. void glp_get_bfcp(glp_prob *P, glp_bfcp *parm);
  397. \end{verbatim}
  398. \description
  399. The routine \verb|glp_get_bfcp| retrieves control parameters, which are
  400. used on computing and updating the basis factorization associated with
  401. the specified problem object.
  402. Current values of the control parameters are stored in
  403. a \verb|glp_bfcp| structure, which the parameter \verb|parm| points to.
  404. For a detailed description of the structure \verb|glp_bfcp| see
  405. comments to the routine \verb|glp_set_bfcp| in the next subsection.
  406. \para{Comments}
  407. The purpose of the routine \verb|glp_get_bfcp| is two-fold. First, it
  408. allows the application program obtaining current values of control
  409. parameters used by internal GLPK routines, which compute and update the
  410. basis factorization.
  411. The second purpose of this routine is to provide proper values for all
  412. fields of the structure \verb|glp_bfcp| in the case when the
  413. application program needs to change some control parameters.
  414. \subsection{glp\_set\_bfcp --- change basis factorization control
  415. parameters}
  416. \synopsis
  417. \begin{verbatim}
  418. void glp_set_bfcp(glp_prob *P, const glp_bfcp *parm);
  419. \end{verbatim}
  420. \description
  421. The routine \verb|glp_set_bfcp| changes control parameters, which are
  422. used by internal GLPK routines on computing and updating the basis
  423. factorization associated with the specified problem object.
  424. New values of the control parameters should be passed in a structure
  425. \verb|glp_bfcp|, which the parameter \verb|parm| points to. For a
  426. detailed description of the structure \verb|glp_bfcp| see paragraph
  427. ``Control parameters'' below.
  428. The parameter \verb|parm| can be specified as \verb|NULL|, in which
  429. case all control parameters are reset to their default values.
  430. \para{Comments}
  431. Before changing some control parameters with the routine
  432. \verb|glp_set_bfcp| the application program should retrieve current
  433. values of all control parameters with the routine \verb|glp_get_bfcp|.
  434. This is needed for backward compatibility, because in the future there
  435. may appear new members in the structure \verb|glp_bfcp|.
  436. Note that new values of control parameters come into effect on a next
  437. computation of the basis factorization, not immediately.
  438. \para{Example}
  439. \begin{footnotesize}
  440. \begin{verbatim}
  441. glp_prob *lp;
  442. glp_bfcp parm;
  443. . . .
  444. /* retrieve current values of control parameters */
  445. glp_get_bfcp(lp, &parm);
  446. /* change the threshold pivoting tolerance */
  447. parm.piv_tol = 0.05;
  448. /* set new values of control parameters */
  449. glp_set_bfcp(lp, &parm);
  450. . . .
  451. \end{verbatim}
  452. \end{footnotesize}
  453. \newpage
  454. \para{Control parameters}
  455. This paragraph describes all basis factorization control parameters
  456. currently used in the package. Symbolic names of control parameters are
  457. names of corresponding members in the structure \verb|glp_bfcp|.
  458. \medskip
  459. {\tt int type} (default: {\tt GLP\_BF\_LUF + GLP\_BF\_FT})
  460. Basis factorization type:
  461. \verb~GLP_BF_LUF + GLP_BF_FT~ --- $LUF$, Forrest--Tomlin update;
  462. \verb~GLP_BF_LUF + GLP_BF_BG~ --- $LUF$, Schur complement,
  463. Bartels--Golub update;
  464. \verb~GLP_BF_LUF + GLP_BF_GR~ --- $LUF$, Schur complement,
  465. Givens rotation update;
  466. \verb~GLP_BF_BTF + GLP_BF_BG~ --- $BTF$, Schur complement,
  467. Bartels--Golub update;
  468. \verb~GLP_BF_BTF + GLP_BF_GR~ --- $BTF$, Schur complement,
  469. Givens rotation update.
  470. In case of \verb|GLP_BF_FT| the update is applied to matrix $U$, while
  471. in cases of \verb|GLP_BF_BG| and \verb|GLP_BF_GR| the update is applied
  472. to the Schur complement.
  473. %\medskip
  474. %
  475. %{\tt int lu\_size} (default: {\tt 0})
  476. %
  477. %The initial size of the Sparse Vector Area, in non-zeros, used on
  478. %computing $LU$-factorization of the basis matrix for the first time.
  479. %If this parameter is set to 0, the initial SVA size is determined
  480. %automatically.
  481. \medskip
  482. {\tt double piv\_tol} (default: {\tt 0.10})
  483. Threshold pivoting (Markowitz) tolerance, 0 $<$ \verb|piv_tol| $<$ 1,
  484. used on computing $LU$-factoriza\-tion of the basis matrix. Element
  485. $u_{ij}$ of the active submatrix of factor $U$ fits to be pivot if it
  486. satisfies to the stability criterion
  487. $|u_{ij}| >= {\tt piv\_tol}\cdot\max|u_{i*}|$, i.e. if it is not very
  488. small in the magnitude among other elements in the same row. Decreasing
  489. this parameter may lead to better sparsity at the expense of numerical
  490. accuracy, and vice versa.
  491. \medskip
  492. {\tt int piv\_lim} (default: {\tt 4})
  493. This parameter is used on computing $LU$-factorization of the basis
  494. matrix and specifies how many pivot candidates needs to be considered
  495. on choosing a pivot element, \verb|piv_lim| $\geq$ 1. If \verb|piv_lim|
  496. candidates have been considered, the pivoting routine prematurely
  497. terminates the search with the best candidate found.
  498. \medskip
  499. {\tt int suhl} (default: {\tt GLP\_ON})
  500. This parameter is used on computing $LU$-factorization of the basis
  501. matrix. Being set to {\tt GLP\_ON} it enables applying the following
  502. heuristic proposed by Uwe Suhl: if a column of the active submatrix has
  503. no eligible pivot candidates, it is no more considered until it becomes
  504. a column singleton. In many cases this allows reducing the time needed
  505. for pivot searching. To disable this heuristic the parameter
  506. \verb|suhl| should be set to {\tt GLP\_OFF}.
  507. \medskip
  508. {\tt double eps\_tol} (default: {\tt 1e-15})
  509. Epsilon tolerance, \verb|eps_tol| $\geq$ 0, used on computing
  510. $LU$-factorization of the basis matrix. If an element of the active
  511. submatrix of factor $U$ is less than \verb|eps_tol| in the magnitude,
  512. it is replaced by exact zero.
  513. %\medskip
  514. %
  515. %{\tt double max\_gro} (default: {\tt 1e+10})
  516. %
  517. %Maximal growth of elements of factor $U$, \verb|max_gro| $\geq$ 1,
  518. %allowable on computing $LU$-factorization of the basis matrix. If on
  519. %some elimination step the ratio $u_{big}/b_{max}$ (where $u_{big}$ is
  520. %the largest magnitude of elements of factor $U$ appeared in its active
  521. %submatrix during all the factorization process, $b_{max}$ is the
  522. %largest magnitude of elements of the basis matrix to be factorized),
  523. %the basis matrix is considered as ill-conditioned.
  524. \medskip
  525. {\tt int nfs\_max} (default: {\tt 100})
  526. Maximal number of additional row-like factors (entries of the eta
  527. file), \verb|nfs_max| $\geq$ 1, which can be added to
  528. $LU$-factorization of the basis matrix on updating it with the
  529. Forrest--Tomlin technique. This parameter is used only once, before
  530. $LU$-factorization is computed for the first time, to allocate working
  531. arrays. As a rule, each update adds one new factor (however, some
  532. updates may need no addition), so this parameter limits the number of
  533. updates between refactorizations.
  534. \medskip
  535. {\tt double upd\_tol} (default: {\tt 1e-6})
  536. Update tolerance, 0 $<$ \verb|upd_tol| $<$ 1, used on updating
  537. $LU$-factorization of the basis matrix with the Forrest--Tomlin
  538. technique. If after updating the magnitude of some diagonal element
  539. $u_{kk}$ of factor $U$ becomes less than
  540. ${\tt upd\_tol}\cdot\max(|u_{k*}|, |u_{*k}|)$, the factorization is
  541. considered as inaccurate.
  542. \medskip
  543. {\tt int nrs\_max} (default: {\tt 100})
  544. Maximal number of additional rows and columns, \verb|nrs_max| $\geq$ 1,
  545. which can be added to $LU$-factorization of the basis matrix on
  546. updating it with the Schur complement technique. This parameter is used
  547. only once, before $LU$-factorization is computed for the first time, to
  548. allocate working arrays. As a rule, each update adds one new row and
  549. column (however, some updates may need no addition), so this parameter
  550. limits the number of updates between refactorizations.
  551. %\medskip
  552. %
  553. %{\tt int rs\_size} (default: {\tt 0})
  554. %
  555. %The initial size of the Sparse Vector Area, in non-zeros, used to
  556. %store non-zero elements of additional rows and columns introduced on
  557. %updating $LU$-factorization of the basis matrix with the Schur
  558. %complement technique. If this parameter is set to 0, the initial SVA
  559. %size is determined automatically.
  560. \subsection{glp\_get\_bhead --- retrieve the basis header information}
  561. \synopsis
  562. \begin{verbatim}
  563. int glp_get_bhead(glp_prob *P, int k);
  564. \end{verbatim}
  565. \description
  566. The routine \verb|glp_get_bhead| returns the basis header information
  567. for the current basis associated with the specified problem object.
  568. \returns
  569. If basic variable $(x_B)_k$, $1\leq k\leq m$, is $i$-th auxiliary
  570. variable ($1\leq i\leq m$), the routine returns $i$. Otherwise, if
  571. $(x_B)_k$ is $j$-th structural variable ($1\leq j\leq n$), the routine
  572. returns $m+j$. Here $m$ is the number of rows and $n$ is the number of
  573. columns in the problem object.
  574. \para{Comments}
  575. Sometimes the application program may need to know which original
  576. (auxiliary and structural) variable correspond to a given basic
  577. variable, or, that is the same, which column of the augmented
  578. constraint matrix $(I\ |-\!A)$ correspond to a given column of the
  579. basis matrix $B$.
  580. \def\arraystretch{1}
  581. The correspondence is defined as follows:\footnote{For more details see
  582. Subsection \ref{basbgd}, page \pageref{basbgd}.}
  583. $$\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=
  584. \Pi\left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)
  585. \ \ \Leftrightarrow
  586. \ \ \left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)=
  587. \Pi^T\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right),$$
  588. where $x_B$ is the vector of basic variables, $x_N$ is the vector of
  589. non-basic variables, $x_R$ is the vector of auxiliary variables
  590. following in their original order,\footnote{The original order of
  591. auxiliary and structural variables is defined by the ordinal numbers
  592. of corresponding rows and columns in the problem object.} $x_S$ is the
  593. vector of structural variables following in their original order, $\Pi$
  594. is a permutation matrix (which is a component of the basis
  595. factorization).
  596. Thus, if $(x_B)_k=(x_R)_i$ is $i$-th auxiliary variable, the routine
  597. returns $i$, and if $(x_B)_k=(x_S)_j$ is $j$-th structural variable,
  598. the routine returns $m+j$, where $m$ is the number of rows in the
  599. problem object.
  600. \subsection{glp\_get\_row\_bind --- retrieve row index in the basis
  601. header}
  602. \synopsis
  603. \begin{verbatim}
  604. int glp_get_row_bind(glp_prob *P, int i);
  605. \end{verbatim}
  606. \returns
  607. The routine \verb|glp_get_row_bind| returns the index $k$ of basic
  608. variable $(x_B)_k$, $1\leq k\leq m$, which is $i$-th auxiliary variable
  609. (that is, the auxiliary variable corresponding to $i$-th row),
  610. $1\leq i\leq m$, in the current basis associated with the specified
  611. problem object, where $m$ is the number of rows. However, if $i$-th
  612. auxiliary variable is non-basic, the routine returns zero.
  613. \para{Comments}
  614. The routine \verb|glp_get_row_bind| is an inversion of the routine
  615. \verb|glp_get_bhead|; that is, if \linebreak
  616. \verb|glp_get_bhead|$(P,k)$ returns $i$,
  617. \verb|glp_get_row_bind|$(P,i)$ returns $k$, and vice versa.
  618. \subsection{glp\_get\_col\_bind --- retrieve column index in the basis
  619. header}
  620. \synopsis
  621. \begin{verbatim}
  622. int glp_get_col_bind(glp_prob *P, int j);
  623. \end{verbatim}
  624. \returns
  625. The routine \verb|glp_get_col_bind| returns the index $k$ of basic
  626. variable $(x_B)_k$, $1\leq k\leq m$, which is $j$-th structural
  627. variable (that is, the structural variable corresponding to $j$-th
  628. column), $1\leq j\leq n$, in the current basis associated with the
  629. specified problem object, where $m$ is the number of rows, $n$ is the
  630. number of columns. However, if $j$-th structural variable is non-basic,
  631. the routine returns zero.
  632. \para{Comments}
  633. The routine \verb|glp_get_col_bind| is an inversion of the routine
  634. \verb|glp_get_bhead|; that is, if \linebreak
  635. \verb|glp_get_bhead|$(P,k)$ returns $m+j$,
  636. \verb|glp_get_col_bind|$(P,j)$ returns $k$, and vice versa.
  637. \subsection{glp\_ftran --- perform forward transformation}
  638. \synopsis
  639. \begin{verbatim}
  640. void glp_ftran(glp_prob *P, double x[]);
  641. \end{verbatim}
  642. \description
  643. The routine \verb|glp_ftran| performs forward transformation (FTRAN),
  644. i.e. it solves the system $Bx=b$, where $B$ is the basis matrix
  645. associated with the specified problem object, $x$ is the vector of
  646. unknowns to be computed, $b$ is the vector of right-hand sides.
  647. On entry to the routine elements of the vector $b$ should be stored in
  648. locations \verb|x[1]|, \dots, \verb|x[m]|, where $m$ is the number of
  649. rows. On exit the routine stores elements of the vector $x$ in the same
  650. locations.
  651. \subsection{glp\_btran --- perform backward transformation}
  652. \synopsis
  653. \begin{verbatim}
  654. void glp_btran(glp_prob *P, double x[]);
  655. \end{verbatim}
  656. \description
  657. The routine \verb|glp_btran| performs backward transformation (BTRAN),
  658. i.e. it solves the system $B^Tx=b$, where $B^T$ is a matrix transposed
  659. to the basis matrix $B$ associated with the specified problem object,
  660. $x$ is the vector of unknowns to be computed, $b$ is the vector of
  661. right-hand sides.
  662. On entry to the routine elements of the vector $b$ should be stored in
  663. locations \verb|x[1]|, \dots, \verb|x[m]|, where $m$ is the number of
  664. rows. On exit the routine stores elements of the vector $x$ in the same
  665. locations.
  666. \subsection{glp\_warm\_up --- ``warm up'' LP basis}
  667. \synopsis
  668. \begin{verbatim}
  669. int glp_warm_up(glp_prob *P);
  670. \end{verbatim}
  671. \description
  672. The routine \verb|glp_warm_up| ``warms up'' the LP basis for the
  673. specified problem object using current statuses assigned to rows and
  674. columns (that is, to auxiliary and structural variables).
  675. This operation includes computing factorization of the basis matrix
  676. (if it does not exist), computing primal and dual components of basic
  677. solution, and determining the solution status.
  678. \returns
  679. \begin{retlist}
  680. 0 & The operation has been successfully performed.\\
  681. \verb|GLP_EBADB| & The basis matrix is invalid, because the number of
  682. basic (auxiliary and structural) variables is not the same as the
  683. number of rows in the problem object.\\
  684. \verb|GLP_ESING| & The basis matrix is singular within the working
  685. precision.\\
  686. \verb|GLP_ECOND| & The basis matrix is ill-conditioned, i.e. its
  687. condition number is too large.\\
  688. \end{retlist}
  689. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  690. \newpage
  691. \section{Simplex tableau routines}
  692. \subsection{glp\_eval\_tab\_row --- compute row of the tableau}
  693. \synopsis
  694. \begin{verbatim}
  695. int glp_eval_tab_row(glp_prob *P, int k, int ind[], double val[]);
  696. \end{verbatim}
  697. \description
  698. The routine \verb|glp_eval_tab_row| computes a row of the current
  699. simplex tableau (see Subsection 3.1.1, formula (3.12)), which (row)
  700. corresponds to some basic variable specified by the parameter $k$ as
  701. follows: if $1\leq k\leq m$, the basic variable is $k$-th auxiliary
  702. variable, and if $m+1\leq k\leq m+n$, the basic variable is $(k-m)$-th
  703. structural variable, where $m$ is the number of rows and $n$ is the
  704. number of columns in the specified problem object. The basis
  705. factorization must exist.
  706. The computed row shows how the specified basic variable depends on
  707. non-basic variables:
  708. $$x_k=(x_B)_i=\xi_{i1}(x_N)_1+\xi_{i2}(x_N)_2+\dots+\xi_{in}(x_N)_n,$$
  709. where $\xi_{i1}$, $\xi_{i2}$, \dots, $\xi_{in}$ are elements of the
  710. simplex table row, $(x_N)_1$, $(x_N)_2$, \dots, $(x_N)_n$ are non-basic
  711. (auxiliary and structural) variables.
  712. The routine stores column indices and corresponding numeric values of
  713. non-zero elements of the computed row in unordered sparse format in
  714. locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,
  715. \dots, \verb|val[len]|, respectively, where $0\leq{\tt len}\leq n$ is
  716. the number of non-zero elements in the row returned on exit.
  717. Element indices stored in the array \verb|ind| have the same sense as
  718. index $k$, i.e. indices 1 to $m$ denote auxiliary variables while
  719. indices $m+1$ to $m+n$ denote structural variables (all these variables
  720. are obviously non-basic by definition).
  721. \returns
  722. The routine \verb|glp_eval_tab_row| returns \verb|len|, which is the
  723. number of non-zero elements in the simplex table row stored in the
  724. arrays \verb|ind| and \verb|val|.
  725. \para{Comments}
  726. A row of the simplex table is computed as follows. At first, the
  727. routine checks that the specified variable $x_k$ is basic and uses the
  728. permutation matrix $\Pi$ (3.7) to determine index $i$ of basic variable
  729. $(x_B)_i$, which corresponds to $x_k$.
  730. The row to be computed is $i$-th row of the matrix $\Xi$ (3.12),
  731. therefore:
  732. $$\xi_i=e_i^T\Xi=-e_i^TB^{-1}N=-(B^{-T}e_i)^TN,$$
  733. where $e_i$ is $i$-th unity vector. So the routine performs BTRAN to
  734. obtain $i$-th row of the inverse $B^{-1}$:
  735. $$\varrho_i=B^{-T}e_i,$$
  736. and then computes elements of the simplex table row as inner products:
  737. $$\xi_{ij}=-\varrho_i^TN_j,\ \ j=1,2,\dots,n,$$
  738. where $N_j$ is $j$-th column of matrix $N$ (3.9), which (column)
  739. corresponds to non-basic variable $(x_N)_j$. The permutation matrix
  740. $\Pi$ is used again to convert indices $j$ of non-basic columns to
  741. original ordinal numbers of auxiliary and structural variables.
  742. \subsection{glp\_eval\_tab\_col --- compute column of the tableau}
  743. \synopsis
  744. \begin{verbatim}
  745. int glp_eval_tab_col(glp_prob *P, int k, int ind[], double val[]);
  746. \end{verbatim}
  747. \description
  748. The routine \verb|glp_eval_tab_col| computes a column of the current
  749. simplex tableau (see Subsection 3.1.1, formula (3.12)), which (column)
  750. corresponds to some non-basic variable specified by the parameter $k$:
  751. if $1\leq k\leq m$, the non-basic variable is $k$-th auxiliary
  752. variable, and if $m+1\leq k\leq m+n$, the non-basic variable is
  753. $(k-m)$-th structural variable, where $m$ is the number of rows and $n$
  754. is the number of columns in the specified problem object. The basis
  755. factorization must exist.
  756. The computed column shows how basic variables depends on the specified
  757. non-basic variable $x_k=(x_N)_j$:
  758. $$
  759. \begin{array}{r@{\ }c@{\ }l@{\ }l}
  760. (x_B)_1&=&\dots+\xi_{1j}(x_N)_j&+\dots\\
  761. (x_B)_2&=&\dots+\xi_{2j}(x_N)_j&+\dots\\
  762. .\ \ .&.&.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\\
  763. (x_B)_m&=&\dots+\xi_{mj}(x_N)_j&+\dots\\
  764. \end{array}
  765. $$
  766. where $\xi_{1j}$, $\xi_{2j}$, \dots, $\xi_{mj}$ are elements of the
  767. simplex table column, $(x_B)_1$, $(x_B)_2$, \dots, $(x_B)_m$ are basic
  768. (auxiliary and structural) variables.
  769. The routine stores row indices and corresponding numeric values of
  770. non-zero elements of the computed column in unordered sparse format in
  771. locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,
  772. \dots, \verb|val[len]|, respectively, where $0\leq{\tt len}\leq m$ is
  773. the number of non-zero elements in the column returned on exit.
  774. Element indices stored in the array \verb|ind| have the same sense as
  775. index $k$, i.e. indices 1 to $m$ denote auxiliary variables while
  776. indices $m+1$ to $m+n$ denote structural variables (all these variables
  777. are obviously basic by definition).
  778. \returns
  779. The routine \verb|glp_eval_tab_col| returns \verb|len|, which is the
  780. number of non-zero elements in the simplex table column stored in the
  781. arrays \verb|ind| and \verb|val|.
  782. \para{Comments}
  783. A column of the simplex table is computed as follows. At first, the
  784. routine checks that the specified variable $x_k$ is non-basic and uses
  785. the permutation matrix $\Pi$ (3.7) to determine index $j$ of non-basic
  786. variable $(x_N)_j$, which corresponds to $x_k$.
  787. The column to be computed is $j$-th column of the matrix $\Xi$ (3.12),
  788. therefore:
  789. $$\Xi_j=\Xi e_j=-B^{-1}Ne_j=-B^{-1}N_j,$$
  790. where $e_j$ is $j$-th unity vector, $N_j$ is $j$-th column of matrix
  791. $N$ (3.9). So the routine performs FTRAN to transform $N_j$ to the
  792. simplex table column $\Xi_j=(\xi_{ij})$ and uses the permutation matrix
  793. $\Pi$ to convert row indices $i$ to original ordinal numbers of
  794. auxiliary and structural variables.
  795. \newpage
  796. \subsection{glp\_transform\_row --- transform explicitly specified row}
  797. \synopsis
  798. \begin{verbatim}
  799. int glp_transform_row(glp_prob *P, int len, int ind[], double val[]);
  800. \end{verbatim}
  801. \description
  802. The routine \verb|glp_transform_row| performs the same operation as the
  803. routine \verb|glp_eval_tab_row| with exception that the row to be
  804. transformed is specified explicitly as a sparse vector.
  805. The explicitly specified row may be thought as a linear form:
  806. $$x=a_1x_{m+1}+a_2x_{m+2}+\dots+a_nx_{m+n},$$
  807. where $x$ is an auxiliary variable for this row, $a_j$ are coefficients
  808. of the linear form, $x_{m+j}$ are structural variables.
  809. On entry column indices and numerical values of non-zero coefficients
  810. $a_j$ of the specified row should be placed in locations \verb|ind[1]|,
  811. \dots, \verb|ind[len]| and \verb|val[1]|, \dots, \verb|val[len]|, where
  812. \verb|len| is number of non-zero coefficients.
  813. This routine uses the system of equality constraints and the current
  814. basis in order to express the auxiliary variable $x$ through the current
  815. non-basic variables (as if the transformed row were added to the problem
  816. object and the auxiliary variable $x$ were basic), i.e. the resultant
  817. row has the form:
  818. $$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n,$$
  819. where $\xi_j$ are influence coefficients, $(x_N)_j$ are non-basic
  820. (auxiliary and structural) variables, $n$ is the number of columns in
  821. the problem object.
  822. On exit the routine stores indices and numerical values of non-zero
  823. coefficients $\xi_j$ of the resultant row in locations \verb|ind[1]|,
  824. \dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|,
  825. where $0\leq{\tt len'}\leq n$ is the number of non-zero coefficients in
  826. the resultant row returned by the routine. Note that indices of
  827. non-basic variables stored in the array \verb|ind| correspond to
  828. original ordinal numbers of variables: indices 1 to $m$ mean auxiliary
  829. variables and indices $m+1$ to $m+n$ mean structural ones.
  830. \returns
  831. The routine \verb|glp_transform_row| returns \verb|len'|, the number of
  832. non-zero coefficients in the resultant row stored in the arrays
  833. \verb|ind| and \verb|val|.
  834. \newpage
  835. \subsection{glp\_transform\_col --- transform explicitly specified
  836. column}
  837. \synopsis
  838. \begin{verbatim}
  839. int glp_transform_col(glp_prob *P, int len, int ind[], double val[]);
  840. \end{verbatim}
  841. \description
  842. The routine \verb|glp_transform_col| performs the same operation as the
  843. routine \verb|glp_eval_tab_col| with exception that the column to be
  844. transformed is specified explicitly as a sparse vector.
  845. The explicitly specified column may be thought as it were added to
  846. the original system of equality constraints:
  847. $$
  848. \begin{array}{l@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r}
  849. x_1&=&a_{11}x_{m+1}&+\dots+&a_{1n}x_{m+n}&+&a_1x \\
  850. x_2&=&a_{21}x_{m+1}&+\dots+&a_{2n}x_{m+n}&+&a_2x \\
  851. \multicolumn{7}{c}
  852. {.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  853. x_m&=&a_{m1}x_{m+1}&+\dots+&a_{mn}x_{m+n}&+&a_mx \\
  854. \end{array}
  855. $$
  856. where $x_i$ are auxiliary variables, $x_{m+j}$ are structural variables
  857. (presented in the problem object), $x$ is a structural variable for the
  858. explicitly specified column, $a_i$ are constraint coefficients at $x$.
  859. On entry row indices and numerical values of non-zero coefficients
  860. $a_i$ of the specified column should be placed in locations
  861. \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|, \dots,
  862. \verb|val[len]|, where \verb|len| is number of non-zero coefficients.
  863. This routine uses the system of equality constraints and the current
  864. basis in order to express the current basic variables through the
  865. structural variable $x$ (as if the transformed column were added to the
  866. problem object and the variable $x$ were non-basic):
  867. $$
  868. \begin{array}{l@{\ }c@{\ }r}
  869. (x_B)_1&=\dots+&\xi_{1}x\\
  870. (x_B)_2&=\dots+&\xi_{2}x\\
  871. \multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  872. (x_B)_m&=\dots+&\xi_{m}x\\
  873. \end{array}
  874. $$
  875. where $\xi_i$ are influence coefficients, $x_B$ are basic (auxiliary
  876. and structural) variables, $m$ is the number of rows in the problem
  877. object.
  878. On exit the routine stores indices and numerical values of non-zero
  879. coefficients $\xi_i$ of the resultant column in locations \verb|ind[1]|,
  880. \dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|,
  881. where $0\leq{\tt len'}\leq m$ is the number of non-zero coefficients in
  882. the resultant column returned by the routine. Note that indices of basic
  883. variables stored in the array \verb|ind| correspond to original ordinal
  884. numbers of variables, i.e. indices 1 to $m$ mean auxiliary variables,
  885. indices $m+1$ to $m+n$ mean structural ones.
  886. \returns
  887. The routine \verb|glp_transform_col| returns \verb|len'|, the number of
  888. non-zero coefficients in the resultant column stored in the arrays
  889. \verb|ind| and \verb|val|.
  890. \newpage
  891. \subsection{glp\_prim\_rtest --- perform primal ratio test}
  892. \synopsis
  893. \begin{verbatim}
  894. int glp_prim_rtest(glp_prob *P, int len, const int ind[], const double val[],
  895. int dir, double eps);
  896. \end{verbatim}
  897. \description
  898. The routine \verb|glp_prim_rtest| performs the primal ratio test using
  899. an explicitly specified column of the simplex table.
  900. The current basic solution associated with the LP problem object must
  901. be primal feasible.
  902. The explicitly specified column of the simplex table shows how the
  903. basic variables $x_B$ depend on some non-basic variable $x$ (which is
  904. not necessarily presented in the problem object):
  905. $$
  906. \begin{array}{l@{\ }c@{\ }r}
  907. (x_B)_1&=\dots+&\xi_{1}x\\
  908. (x_B)_2&=\dots+&\xi_{2}x\\
  909. \multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  910. (x_B)_m&=\dots+&\xi_{m}x\\
  911. \end{array}
  912. $$
  913. The column is specifed on entry to the routine in sparse format.
  914. Ordinal numbers of basic variables $(x_B)_i$ should be placed in
  915. locations \verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal number
  916. 1 to $m$ denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$
  917. denote structural variables. The corresponding non-zero coefficients
  918. $\xi_i$ should be placed in locations
  919. \verb|val[1]|, \dots, \verb|val[len]|. The arrays \verb|ind| and
  920. \verb|val| are not changed by the routine.
  921. The parameter \verb|dir| specifies direction in which the variable $x$
  922. changes on entering the basis: $+1$ means increasing, $-1$ means
  923. decreasing.
  924. The parameter \verb|eps| is an absolute tolerance (small positive
  925. number, say, $10^{-9}$) used by the routine to skip $\xi_i$'s whose
  926. magnitude is less than \verb|eps|.
  927. The routine determines which basic variable (among those specified in
  928. \verb|ind[1]|, \dots, \verb|ind[len]|) reaches its (lower or upper)
  929. bound first before any other basic variables do, and which, therefore,
  930. should leave the basis in order to keep primal feasibility.
  931. \returns
  932. The routine \verb|glp_prim_rtest| returns the index, \verb|piv|, in the
  933. arrays \verb|ind| and \verb|val| corresponding to the pivot element
  934. chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic
  935. solution is primal unbounded, and therefore the choice cannot be made,
  936. the routine returns zero.
  937. \para{Comments}
  938. If the non-basic variable $x$ is presented in the LP problem object,
  939. the input column can be computed with the routine
  940. \verb|glp_eval_tab_col|; otherwise, it can be computed with the routine
  941. \verb|glp_transform_col|.
  942. \newpage
  943. \subsection{glp\_dual\_rtest --- perform dual ratio test}
  944. \synopsis
  945. \begin{verbatim}
  946. int glp_dual_rtest(glp_prob *P, int len, const int ind[], const double val[],
  947. int dir, double eps);
  948. \end{verbatim}
  949. \description
  950. The routine \verb|glp_dual_rtest| performs the dual ratio test using
  951. an explicitly specified row of the simplex table.
  952. The current basic solution associated with the LP problem object must
  953. be dual feasible.
  954. The explicitly specified row of the simplex table is a linear form
  955. that shows how some basic variable $x$ (which is not necessarily
  956. presented in the problem object) depends on non-basic variables $x_N$:
  957. $$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n.$$
  958. The row is specified on entry to the routine in sparse format. Ordinal
  959. numbers of non-basic variables $(x_N)_j$ should be placed in locations
  960. \verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal numbers 1 to $m$
  961. denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$ denote
  962. structural variables. The corresponding non-zero coefficients $\xi_j$
  963. should be placed in locations \verb|val[1]|, \dots, \verb|val[len]|.
  964. The arrays \verb|ind| and \verb|val| are not changed by the routine.
  965. The parameter \verb|dir| specifies direction in which the variable $x$
  966. changes on leaving the basis: $+1$ means that $x$ goes on its lower
  967. bound, so its reduced cost (dual variable) is increasing (minimization)
  968. or decreasing (maximization); $-1$ means that $x$ goes on its upper
  969. bound, so its reduced cost is decreasing (minimization) or increasing
  970. (maximization).
  971. The parameter \verb|eps| is an absolute tolerance (small positive
  972. number, say, $10^{-9}$) used by the routine to skip $\xi_j$'s whose
  973. magnitude is less than \verb|eps|.
  974. The routine determines which non-basic variable (among those specified
  975. in \verb|ind[1]|, \dots,\linebreak \verb|ind[len]|) should enter the
  976. basis in order to keep dual feasibility, because its reduced cost
  977. reaches the (zero) bound first before this occurs for any other
  978. non-basic variables.
  979. \returns
  980. The routine \verb|glp_dual_rtest| returns the index, \verb|piv|, in the
  981. arrays \verb|ind| and \verb|val| corresponding to the pivot element
  982. chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic
  983. solution is dual unbounded, and therefore the choice cannot be made,
  984. the routine returns zero.
  985. \para{Comments}
  986. If the basic variable $x$ is presented in the LP problem object, the
  987. input row can be computed\linebreak with the routine
  988. \verb|glp_eval_tab_row|; otherwise, it can be computed with the routine
  989. \linebreak \verb|glp_transform_row|.
  990. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  991. \newpage
  992. \section{Post-optimal analysis routines}
  993. \subsection{glp\_analyze\_bound --- analyze active bound of non-basic
  994. variable}
  995. \synopsis
  996. \begin{verbatim}
  997. void glp_analyze_bound(glp_prob *P, int k, double *limit1, int *var1,
  998. double *limit2, int *var2);
  999. \end{verbatim}
  1000. \description
  1001. The routine \verb|glp_analyze_bound| analyzes the effect of varying the
  1002. active bound of specified non-basic variable.
  1003. The non-basic variable is specified by the parameter $k$, where
  1004. $1\leq k\leq m$ means auxiliary variable of corresponding row, and
  1005. $m+1\leq k\leq m+n$ means structural variable (column).
  1006. Note that the current basic solution must be optimal, and the basis
  1007. factorization must exist.
  1008. Results of the analysis have the following meaning.
  1009. \verb|value1| is the minimal value of the active bound, at which the
  1010. basis still remains primal feasible and thus optimal. \verb|-DBL_MAX|
  1011. means that the active bound has no lower limit.
  1012. \verb|var1| is the ordinal number of an auxiliary (1 to $m$) or
  1013. structural ($m+1$ to $m+n$) basic variable, which reaches its bound
  1014. first and thereby limits further decreasing the active bound being
  1015. analyzed. if \verb|value1| = \verb|-DBL_MAX|, \verb|var1| is set to 0.
  1016. \verb|value2| is the maximal value of the active bound, at which the
  1017. basis still remains primal feasible and thus optimal. \verb|+DBL_MAX|
  1018. means that the active bound has no upper limit.
  1019. \verb|var2| is the ordinal number of an auxiliary (1 to $m$) or
  1020. structural ($m+1$ to $m+n$) basic variable, which reaches its bound
  1021. first and thereby limits further increasing the active bound being
  1022. analyzed. if \verb|value2| = \verb|+DBL_MAX|, \verb|var2| is set to 0.
  1023. The parameters \verb|value1|, \verb|var1|, \verb|value2|, \verb|var2|
  1024. can be specified as \verb|NULL|, in which case corresponding information
  1025. is not stored.
  1026. \subsection{glp\_analyze\_coef --- analyze objective coefficient at
  1027. basic variable}
  1028. \synopsis
  1029. \begin{verbatim}
  1030. void glp_analyze_coef(glp_prob *P, int k,
  1031. double *coef1, int *var1, double *value1,
  1032. double *coef2, int *var2, double *value2);
  1033. \end{verbatim}
  1034. \description
  1035. The routine \verb|glp_analyze_coef| analyzes the effect of varying the
  1036. objective coefficient at specified basic variable.
  1037. The basic variable is specified by the parameter $k$, where
  1038. $1\leq k\leq m$ means auxiliary variable of corresponding row, and
  1039. $m+1\leq k\leq m+n$ means structural variable (column).
  1040. Note that the current basic solution must be optimal, and the basis
  1041. factorization must exist.
  1042. Results of the analysis have the following meaning.
  1043. \verb|coef1| is the minimal value of the objective coefficient, at
  1044. which the basis still remains dual feasible and thus optimal.
  1045. \verb|-DBL_MAX| means that the objective coefficient has no lower
  1046. limit.
  1047. \verb|var1| is the ordinal number of an auxiliary (1 to $m$) or
  1048. structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost
  1049. reaches its zero bound first and thereby limits further decreasing the
  1050. objective coefficient being analyzed.
  1051. If \verb|coef1| = \verb|-DBL_MAX|, \verb|var1| is set to 0.
  1052. \verb|value1| is value of the basic variable being analyzed in an
  1053. adjacent basis, which is defined as follows. Let the objective
  1054. coefficient reach its minimal value (\verb|coef1|) and continue
  1055. decreasing. Then the reduced cost of the limiting non-basic variable
  1056. (\verb|var1|) becomes dual infeasible and the current basis becomes
  1057. non-optimal that forces the limiting non-basic variable to enter the
  1058. basis replacing there some basic variable that leaves the basis to keep
  1059. primal feasibility. Should note that on determining the adjacent basis
  1060. current bounds of the basic variable being analyzed are ignored as if
  1061. it were free (unbounded) variable, so it cannot leave the basis. It may
  1062. happen that no dual feasible adjacent basis exists, in which case
  1063. \verb|value1| is set to \verb|-DBL_MAX| or \verb|+DBL_MAX|.
  1064. \verb|coef2| is the maximal value of the objective coefficient, at
  1065. which the basis still remains dual feasible and thus optimal.
  1066. \verb|+DBL_MAX| means that the objective coefficient has no upper
  1067. limit.
  1068. \verb|var2| is the ordinal number of an auxiliary (1 to $m$) or
  1069. structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost
  1070. reaches its zero bound first and thereby limits further increasing the
  1071. objective coefficient being analyzed.
  1072. If \verb|coef2| = \verb|+DBL_MAX|, \verb|var2| is set to 0.
  1073. \verb|value2| is value of the basic variable being analyzed in an
  1074. adjacent basis, which is defined exactly in the same way as
  1075. \verb|value1| above with exception that now the objective coefficient
  1076. is increasing.
  1077. The parameters \verb|coef1|, \verb|var1|, \verb|value1|, \verb|coef2|,
  1078. \verb|var2|, \verb|value2| can be specified as \verb|NULL|, in which
  1079. case corresponding information is not stored.
  1080. %* eof *%