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.

1387 lines
52 KiB

  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. \noindent
  39. \hspace{.5in} minimize (or maximize)
  40. $$z=(0\ |\ c)^Tx+c_0\eqno(3.4)$$
  41. \hspace{.5in} subject to linear constraints
  42. $$(I\ |-\!A)x=0\eqno(3.5)$$
  43. \hspace{.5in} and bounds of variables
  44. $$l\leq x\leq u\eqno(3.6)$$
  45. where:
  46. $x=(x_R\ |\ x_S)$ is the $(m+n)$-vector of (all) variables;
  47. $(0\ |\ c)$ is the $(m+n)$-vector of objective
  48. coefficients;\footnote{Subvector 0 corresponds to objective
  49. coefficients at auxiliary variables.}
  50. $(I\ |-\!A)$ is the {\it augmented} constraint
  51. $m\times(m+n)$-matrix;\footnote{Note that due to auxiliary variables
  52. matrix $(I\ |-\!A)$ contains the unity submatrix and therefore has full
  53. rank. This means, in particular, that the system (3.5) has no linearly
  54. dependent constraints.}
  55. $l=(l_R\ |\ l_S)$ is the $(m+n)$-vector of lower bounds of (all)
  56. variables;
  57. $u=(u_R\ |\ u_S)$ is the $(m+n)$-vector of upper bounds of (all)
  58. variables.
  59. By definition an {\it LP basic solution} geometrically is a point in
  60. the space of all variables, which is the intersection of hyperplanes
  61. corresponding to active constraints\footnote{A constraint is called
  62. {\it active} if at a given point it is satisfied as equality, otherwise
  63. it is called {\it inactive}.}. The space of all variables has the
  64. dimension $m+n$, therefore, to define some basic solution we have to
  65. define $m+n$ active constraints. Note that $m$ constraints (3.5) being
  66. linearly independent equalities are always active, so remaining $n$
  67. active constraints can be chosen only from bound constraints (3.6).
  68. A variable is called {\it non-basic}, if its (lower or upper) bound is
  69. active, otherwise it is called {\it basic}. Since, as was said above,
  70. exactly $n$ bound constraints must be active, in any basic solution
  71. there are always $n$ non-basic variables and $m$ basic variables.
  72. (Note that a free variable also can be non-basic. Although such
  73. variable has no bounds, we can think it as the difference between two
  74. non-negative variables, which both are non-basic in this case.)
  75. Now consider how to determine numeric values of all variables for a
  76. given basic solution.
  77. Let $\Pi$ be an appropriate permutation matrix of the order $(m+n)$.
  78. Then we can write:
  79. $$\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=
  80. \Pi\left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)=\Pi x,
  81. \eqno(3.7)$$
  82. where $x_B$ is the vector of basic variables, $x_N$ is the vector of
  83. non-basic variables, $x=(x_R\ |\ x_S)$ is the vector of all variables
  84. in the original order. In this case the system of linear constraints
  85. (3.5) can be rewritten as follows:
  86. $$(I\ |-\!A)\Pi^T\Pi x=0\ \ \ \Rightarrow\ \ \ (B\ |\ N)
  87. \left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=0,\eqno(3.8)$$
  88. where
  89. $$(B\ |\ N)=(I\ |-\!A)\Pi^T.\eqno(3.9)$$
  90. \newpage
  91. Matrix $B$ is a square non-singular $m\times m$-matrix, which is
  92. composed from columns of the augmented constraint matrix corresponding
  93. to basic variables. It is called the {\it basis matrix} or simply the
  94. {\it basis}. Matrix $N$ is a rectangular $m\times n$-matrix, which is
  95. composed from columns of the augmented constraint matrix corresponding
  96. to non-basic variables.
  97. From (3.8) it follows that:
  98. $$Bx_B+Nx_N=0,\eqno(3.10)$$
  99. therefore,
  100. $$x_B=-B^{-1}Nx_N.\eqno(3.11)$$
  101. Thus, the formula (3.11) shows how to determine numeric values of basic
  102. variables $x_B$ assuming that non-basic variables $x_N$ are fixed on
  103. their active bounds.
  104. The $m\times n$-matrix
  105. $$\Xi=-B^{-1}N,\eqno(3.12)$$
  106. which appears in (3.11), is called the {\it simplex
  107. tableau}.\footnote{This definition corresponds to the GLPK
  108. implementation.} It shows how basic variables depend on non-basic
  109. variables:
  110. $$x_B=\Xi x_N.\eqno(3.13)$$
  111. The system (3.13) is equivalent to the system (3.5) in the sense that
  112. they both define the same set of points in the space of (primal)
  113. variables, which satisfy to these systems. If, moreover, values of all
  114. basic variables satisfy to their bound constraints (3.3), the
  115. corresponding basic solution is called {\it (primal) feasible},
  116. otherwise {\it (primal) infeasible}. It is understood that any (primal)
  117. feasible basic solution satisfy to all constraints (3.2) and (3.3).
  118. The LP theory says that if LP has optimal solution, it has (at least
  119. one) basic feasible solution, which corresponds to the optimum. And the
  120. most natural way to determine whether a given basic solution is optimal
  121. or not is to use the Karush---Kuhn---Tucker optimality conditions.
  122. \def\arraystretch{1.5}
  123. For the problem statement (3.4)---(3.6) the optimality conditions are
  124. the following:\footnote{These conditions can be appiled to any solution,
  125. not only to a basic solution.}
  126. $$(I\ |-\!A)x=0\eqno(3.14)$$
  127. $$(I\ |-\!A)^T\pi+\lambda_l+\lambda_u=\nabla z=(0\ |\ c)^T\eqno(3.15)$$
  128. $$l\leq x\leq u\eqno(3.16)$$
  129. $$\lambda_l\geq 0,\ \ \lambda_u\leq 0\ \ \mbox{(minimization)}
  130. \eqno(3.17)$$
  131. $$\lambda_l\leq 0,\ \ \lambda_u\geq 0\ \ \mbox{(maximization)}
  132. \eqno(3.18)$$
  133. $$(\lambda_l)_k(x_k-l_k)=0,\ \ (\lambda_u)_k(x_k-u_k)=0,\ \ k=1,2,\dots,
  134. m+n\eqno(3.19)$$
  135. where:
  136. $\pi=(\pi_1,\pi_2,\dots,\pi_m)$ is a $m$-vector of Lagrange
  137. multipliers for equality constraints (3.5);
  138. $\lambda_l=[(\lambda_l)_1,(\lambda_l)_2,\dots,(\lambda_l)_n]$ is a
  139. $n$-vector of Lagrange multipliers for lower bound constraints (3.6);
  140. $\lambda_u=[(\lambda_u)_1,(\lambda_u)_2,\dots,(\lambda_u)_n]$ is a
  141. $n$-vector of Lagrange multipliers for upper bound constraints (3.6).
  142. \newpage
  143. Condition (3.14) is the {\it primal} (original) system of equality
  144. constraints (3.5).
  145. Condition (3.15) is the {\it dual} system of equality constraints.
  146. It requires the gradient of the objective function to be a linear
  147. combination of normals to the planes defined by constraints of the
  148. original problem.
  149. Condition (3.16) is the primal (original) system of bound constraints
  150. (3.6).
  151. Condition (3.17) (or (3.18) in case of maximization) is the dual system
  152. of bound constraints.
  153. Condition (3.19) is the {\it complementary slackness condition}. It
  154. requires, for each original (auxiliary or structural) variable $x_k$,
  155. that either its (lower or upper) bound must be active, or zero bound of
  156. the corresponding Lagrange multiplier ($(\lambda_l)_k$ or
  157. $(\lambda_u)_k$) must be active.
  158. In GLPK two multipliers $(\lambda_l)_k$ and $(\lambda_u)_k$ for each
  159. primal (original) variable $x_k$, $k=1,2,\dots,\linebreak m+n$, are
  160. combined into one multiplier:
  161. $$\lambda_k=(\lambda_l)_k+(\lambda_u)_k,\eqno(3.20)$$
  162. which is called a {\it dual variable} for $x_k$. This {\it cannot} lead
  163. to the ambiguity, because both lower and upper bounds of $x_k$ cannot be
  164. active at the same time,\footnote{If $x_k$ is a fixed variable, we can
  165. think it as double-bounded variable $l_k\leq x_k\leq u_k$, where
  166. $l_k=u_k.$} so at least one of $(\lambda_l)_k$ and $(\lambda_u)_k$ must
  167. be equal to zero, and because these multipliers have different signs,
  168. the combined multiplier, which is their sum, uniquely defines each of
  169. them.
  170. \def\arraystretch{1}
  171. Using dual variables $\lambda_k$ the dual system of bound constraints
  172. (3.17) and (3.18) can be written in the form of so called {\it ``rule of
  173. signs''} as follows:
  174. \medskip
  175. \begin{center}
  176. \begin{tabular}{|@{\,}c@{$\,$}|@{$\,$}c@{$\,$}|@{$\,$}c@{$\,$}|
  177. @{$\,$}c|c@{$\,$}|@{$\,$}c@{$\,$}|@{$\,$}c@{$\,$}|}
  178. \hline
  179. Original bound&\multicolumn{3}{c|}{Minimization}&\multicolumn{3}{c|}
  180. {Maximization}\\
  181. \cline{2-7}
  182. constraint&$(\lambda_l)_k$&$(\lambda_u)_k$&$(\lambda_l)_k+
  183. (\lambda_u)_k$&$(\lambda_l)_k$&$(\lambda_u)_k$&$(\lambda_l)_k+
  184. (\lambda_u)_k$\\
  185. \hline
  186. $-\infty<x_k<+\infty$&$=0$&$=0$&$\lambda_k=0$&$=0$&$=0$&$\lambda_k=0$\\
  187. $x_k\geq l_k$&$\geq 0$&$=0$&$\lambda_k\geq 0$&$\leq 0$&$=0$&$\lambda_k
  188. \leq0$\\
  189. $x_k\leq u_k$&$=0$&$\leq 0$&$\lambda_k\leq 0$&$=0$&$\geq 0$&$\lambda_k
  190. \geq0$\\
  191. $l_k\leq x_k\leq u_k$&$\geq 0$& $\leq 0$& $-\infty\!<\!\lambda_k\!<
  192. \!+\infty$
  193. &$\leq 0$& $\geq 0$& $-\infty\!<\!\lambda_k\!<\!+\infty$\\
  194. $x_k=l_k=u_k$&$\geq 0$& $\leq 0$& $-\infty\!<\!\lambda_k\!<\!+\infty$&
  195. $\leq 0$&
  196. $\geq 0$& $-\infty\!<\!\lambda_k\!<\!+\infty$\\
  197. \hline
  198. \end{tabular}
  199. \end{center}
  200. \medskip
  201. May note that each primal variable $x_k$ has its dual counterpart
  202. $\lambda_k$ and vice versa. This allows applying the same partition for
  203. the vector of dual variables as (3.7):
  204. $$\left(\begin{array}{@{}c@{}}\lambda_B\\\lambda_N\\\end{array}\right)=
  205. \Pi\lambda,\eqno(3.21)$$
  206. where $\lambda_B$ is a vector of dual variables for basic variables
  207. $x_B$, $\lambda_N$ is a vector of dual variables for non-basic variables
  208. $x_N$.
  209. By definition, bounds of basic variables are inactive constraints, so in
  210. any basic solution $\lambda_B=0$. Corresponding values of dual variables
  211. $\lambda_N$ for non-basic variables $x_N$ can be determined in the
  212. following way. From the dual system (3.15) we have:
  213. $$(I\ |-\!A)^T\pi+\lambda=(0\ |\ c)^T,\eqno(3.22)$$
  214. \newpage
  215. \noindent
  216. so multiplying both sides of (3.22) by matrix $\Pi$ gives:
  217. $$\Pi(I\ |-\!A)^T\pi+\Pi\lambda=\Pi(0\ |\ c)^T.\eqno(3.23)$$
  218. From (3.9) it follows that
  219. $$\Pi(I\ |-\!A)^T=[(I\ |-\!A)\Pi^T]^T=(B\ |\ N)^T.\eqno(3.24)$$
  220. Further, we can apply the partition (3.7) also to the vector of
  221. objective coefficients (see (3.4)):
  222. $$\left(\begin{array}{@{}c@{}}c_B\\c_N\\\end{array}\right)=
  223. \Pi\left(\begin{array}{@{}c@{}}0\\c\\\end{array}\right),\eqno(3.25)$$
  224. where $c_B$ is a vector of objective coefficients at basic variables,
  225. $c_N$ is a vector of objective coefficients at non-basic variables.
  226. Now, substituting (3.24), (3.21), and (3.25) into (3.23), leads to:
  227. $$(B\ |\ N)^T\pi+(\lambda_B\ |\ \lambda_N)^T=(c_B\ |\ c_N)^T,
  228. \eqno(3.26)$$
  229. and transposing both sides of (3.26) gives the system:
  230. $$\left(\begin{array}{@{}c@{}}B^T\\N^T\\\end{array}\right)\pi+
  231. \left(\begin{array}{@{}c@{}}\lambda_B\\\lambda_N\\\end{array}\right)=
  232. \left(\begin{array}{@{}c@{}}c_B\\c_T\\\end{array}\right),\eqno(3.27)$$
  233. which can be written as follows:
  234. $$\left\{
  235. \begin{array}{@{\ }r@{\ }c@{\ }r@{\ }c@{\ }l@{\ }}
  236. B^T\pi&+&\lambda_B&=&c_B\\
  237. N^T\pi&+&\lambda_N&=&c_N\\
  238. \end{array}
  239. \right.\eqno(3.28)
  240. $$
  241. Lagrange multipliers $\pi=(\pi_i)$ correspond to equality constraints
  242. (3.5) and therefore can have any sign. This allows resolving the first
  243. subsystem of (3.28) as follows:\footnote{$B^{-T}$ means $(B^T)^{-1}=
  244. (B^{-1})^T$.}
  245. $$\pi=B^{-T}(c_B-\lambda_B)=-B^{-T}\lambda_B+B^{-T}c_B,\eqno(3.29)$$
  246. and substitution of $\pi$ from (3.29) into the second subsystem of
  247. (3.28) gives:
  248. $$\lambda_N=-N^T\pi+c_N=N^TB^{-T}\lambda_B+(c_N-N^TB^{-T}c_B).
  249. \eqno(3.30)$$
  250. The latter system can be written in the following final form:
  251. $$\lambda_N=-\Xi^T\lambda_B+d,\eqno(3.31)$$
  252. where $\Xi$ is the simplex tableau (see (3.12)), and
  253. $$d=c_N-N^TB^{-T}c_B=c_N+\Xi^Tc_B\eqno(3.32)$$
  254. is the vector of so called {\it reduced costs} of non-basic variables.
  255. Above it was said that in any basic solution $\lambda_B=0$, so
  256. $\lambda_N=d$ as it follows from (3.31).
  257. The system (3.31) is equivalent to the system (3.15) in the sense that
  258. they both define the same set of points in the space of dual variables
  259. $\lambda$, which satisfy to these systems. If, moreover, values of all
  260. dual variables $\lambda_N$ (i.e. reduced costs $d$) satisfy to their
  261. bound constraints (i.e. to the ``rule of signs''; see the table above),
  262. the corresponding basic solution is called {\it dual feasible},
  263. otherwise {\it dual infeasible}. It is understood that any dual feasible
  264. solution satisfy to all constraints (3.15) and (3.17) (or (3.18) in case
  265. of maximization).
  266. It can be easily shown that the complementary slackness condition
  267. (3.19) is always satisfied for {\it any} basic solution.\footnote{Until
  268. double-bounded variables appear.} Therefore, a basic
  269. solution\footnote{It is assumed that a complete basic solution has the
  270. form $(x,\lambda)$, i.e. it includes primal as well as dual variables.}
  271. is {\it optimal} if and only if it is primal and dual feasible, because
  272. in this case it satifies to all the optimality conditions
  273. (3.14)---(3.19).
  274. \def\arraystretch{1.5}
  275. The meaning of reduced costs $d=(d_j)$ of non-basic variables can be
  276. explained in the following way. From (3.4), (3.7), and (3.25) it follows
  277. that:
  278. $$z=c_B^Tx_B+c_N^Tx_N+c_0.\eqno(3.33)$$
  279. Substituting $x_B$ from (3.11) into (3.33) we can eliminate basic
  280. variables and express the objective only through non-basic variables:
  281. $$
  282. \begin{array}{r@{\ }c@{\ }l}
  283. z&=&c_B^T(-B^{-1}Nx_N)+c_N^Tx_N+c_0=\\
  284. &=&(c_N^T-c_B^TB^{-1}N)x_N+c_0=\\
  285. &=&(c_N-N^TB^{-T}c_B)^Tx_N+c_0=\\
  286. &=&d^Tx_N+c_0.
  287. \end{array}\eqno(3.34)
  288. $$
  289. From (3.34) it is seen that reduced cost $d_j$ shows how the objective
  290. function $z$ depends on non-basic variable $(x_N)_j$ in the neighborhood
  291. of the current basic solution, i.e. while the current basis remains
  292. unchanged.
  293. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  294. \newpage
  295. \section{LP basis routines}
  296. \label{lpbasis}
  297. \subsection{glp\_bf\_exists --- check if the basis factorization
  298. exists}
  299. \synopsis
  300. \begin{verbatim}
  301. int glp_bf_exists(glp_prob *P);
  302. \end{verbatim}
  303. \returns
  304. If the basis factorization for the current basis associated with the
  305. specified problem object exists and therefore is available for
  306. computations, the routine \verb|glp_bf_exists| returns non-zero.
  307. Otherwise the routine returns zero.
  308. \para{Comments}
  309. Let the problem object have $m$ rows and $n$ columns. In GLPK the
  310. {\it basis matrix} $B$ is a square non-singular matrix of the order $m$,
  311. whose columns correspond to basic (auxiliary and/or structural)
  312. variables. It is defined by the following main
  313. equality:\footnote{For more details see Subsection \ref{basbgd},
  314. page \pageref{basbgd}.}
  315. $$(B\ |\ N)=(I\ |-\!A)\Pi^T,$$
  316. where $I$ is the unity matrix of the order $m$, whose columns correspond
  317. to auxiliary variables; $A$ is the original constraint
  318. $m\times n$-matrix, whose columns correspond to structural variables;
  319. $(I\ |-\!A)$ is the augmented constraint $m\times(m+n)$-matrix, whose
  320. columns correspond to all (auxiliary and structural) variables
  321. following in the original order; $\Pi$ is a permutation matrix of the
  322. order $m+n$; and $N$ is a rectangular $m\times n$-matrix, whose columns
  323. correspond to non-basic (auxiliary and/or structural) variables.
  324. For various reasons it may be necessary to solve linear systems with
  325. matrix $B$. To provide this possibility the GLPK implementation
  326. maintains an invertable form of $B$ (that is, some representation of
  327. $B^{-1}$) called the {\it basis factorization}, which is an internal
  328. component of the problem object. Typically, the basis factorization is
  329. computed by the simplex solver, which keeps it in the problem object
  330. to be available for other computations.
  331. Should note that any changes in the problem object, which affects the
  332. basis matrix (e.g. changing the status of a row or column, changing
  333. a basic column of the constraint matrix, removing an active constraint,
  334. etc.), invalidates the basis factorization. So before calling any API
  335. routine, which uses the basis factorization, the application program
  336. must make sure (using the routine \verb|glp_bf_exists|) that the
  337. factorization exists and therefore available for computations.
  338. \newpage
  339. \subsection{glp\_factorize --- compute the basis factorization}
  340. \synopsis
  341. \begin{verbatim}
  342. int glp_factorize(glp_prob *P);
  343. \end{verbatim}
  344. \description
  345. The routine \verb|glp_factorize| computes the basis factorization for
  346. the current basis associated with the specified problem
  347. object.\footnote{The current basis is defined by the current statuses
  348. of rows (auxiliary variables) and columns (structural variables).}
  349. The basis factorization is computed from ``scratch'' even if it exists,
  350. so the application program may use the routine \verb|glp_bf_exists|,
  351. and, if the basis factorization already exists, not to call the routine
  352. \verb|glp_factorize| to prevent an extra work.
  353. The routine \verb|glp_factorize| {\it does not} compute components of
  354. the basic solution (i.e. primal and dual values).
  355. \returns
  356. \begin{retlist}
  357. 0 & The basis factorization has been successfully computed.\\
  358. \verb|GLP_EBADB| & The basis matrix is invalid, because the number of
  359. basic (auxiliary and structural) variables is not the same as the number
  360. of rows in the problem object.\\
  361. \verb|GLP_ESING| & The basis matrix is singular within the working
  362. precision.\\
  363. \verb|GLP_ECOND| & The basis matrix is ill-conditioned, i.e. its
  364. condition number is too large.\\
  365. \end{retlist}
  366. \subsection{glp\_bf\_updated --- check if the basis factorization has
  367. been updated}
  368. \synopsis
  369. \begin{verbatim}
  370. int glp_bf_updated(glp_prob *P);
  371. \end{verbatim}
  372. \returns
  373. If the basis factorization has been just computed from ``scratch'', the
  374. routine \verb|glp_bf_updated| returns zero. Otherwise, if the
  375. factorization has been updated at least once, the routine returns
  376. non-zero.
  377. \para{Comments}
  378. {\it Updating} the basis factorization means recomputing it to reflect
  379. changes in the basis matrix. For example, on every iteration of the
  380. simplex method some column of the current basis matrix is replaced by
  381. a new column that gives a new basis matrix corresponding to the
  382. adjacent basis. In this case computing the basis factorization for the
  383. adjacent basis from ``scratch'' (as the routine \verb|glp_factorize|
  384. does) would be too time-consuming.
  385. On the other hand, since the basis factorization update is a numeric
  386. computational procedure, applying it many times may lead to
  387. accumulating round-off errors. Therefore the basis is periodically
  388. refactorized (reinverted) from ``scratch'' (with the routine
  389. \verb|glp_factorize|) that allows improving its numerical properties.
  390. The routine \verb|glp_bf_updated| allows determining if the basis
  391. factorization has been updated at least once since it was computed from
  392. ``scratch''.
  393. \subsection{glp\_get\_bfcp --- retrieve basis factorization control
  394. parameters}
  395. \synopsis
  396. \begin{verbatim}
  397. void glp_get_bfcp(glp_prob *P, glp_bfcp *parm);
  398. \end{verbatim}
  399. \description
  400. The routine \verb|glp_get_bfcp| retrieves control parameters, which are
  401. used on computing and updating the basis factorization associated with
  402. the specified problem object.
  403. Current values of the control parameters are stored in
  404. a \verb|glp_bfcp| structure, which the parameter \verb|parm| points to.
  405. For a detailed description of the structure \verb|glp_bfcp| see
  406. comments to the routine \verb|glp_set_bfcp| in the next subsection.
  407. \para{Comments}
  408. The purpose of the routine \verb|glp_get_bfcp| is two-fold. First, it
  409. allows the application program obtaining current values of control
  410. parameters used by internal GLPK routines, which compute and update the
  411. basis factorization.
  412. The second purpose of this routine is to provide proper values for all
  413. fields of the structure \verb|glp_bfcp| in the case when the
  414. application program needs to change some control parameters.
  415. \subsection{glp\_set\_bfcp --- change basis factorization control
  416. parameters}
  417. \synopsis
  418. \begin{verbatim}
  419. void glp_set_bfcp(glp_prob *P, const glp_bfcp *parm);
  420. \end{verbatim}
  421. \description
  422. The routine \verb|glp_set_bfcp| changes control parameters, which are
  423. used by internal GLPK routines on computing and updating the basis
  424. factorization associated with the specified problem object.
  425. New values of the control parameters should be passed in a structure
  426. \verb|glp_bfcp|, which the parameter \verb|parm| points to. For a
  427. detailed description of the structure \verb|glp_bfcp| see paragraph
  428. ``Control parameters'' below.
  429. The parameter \verb|parm| can be specified as \verb|NULL|, in which
  430. case all control parameters are reset to their default values.
  431. \para{Comments}
  432. Before changing some control parameters with the routine
  433. \verb|glp_set_bfcp| the application program should retrieve current
  434. values of all control parameters with the routine \verb|glp_get_bfcp|.
  435. This is needed for backward compatibility, because in the future there
  436. may appear new members in the structure \verb|glp_bfcp|.
  437. Note that new values of control parameters come into effect on a next
  438. computation of the basis factorization, not immediately.
  439. \para{Example}
  440. \begin{footnotesize}
  441. \begin{verbatim}
  442. glp_prob *lp;
  443. glp_bfcp parm;
  444. . . .
  445. /* retrieve current values of control parameters */
  446. glp_get_bfcp(lp, &parm);
  447. /* change the threshold pivoting tolerance */
  448. parm.piv_tol = 0.05;
  449. /* set new values of control parameters */
  450. glp_set_bfcp(lp, &parm);
  451. . . .
  452. \end{verbatim}
  453. \end{footnotesize}
  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. \newpage
  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. \subsection{glp\_transform\_row --- transform explicitly specified row}
  796. \synopsis
  797. \begin{verbatim}
  798. int glp_transform_row(glp_prob *P, int len, int ind[], double val[]);
  799. \end{verbatim}
  800. \description
  801. The routine \verb|glp_transform_row| performs the same operation as the
  802. routine \verb|glp_eval_tab_row| with exception that the row to be
  803. transformed is specified explicitly as a sparse vector.
  804. The explicitly specified row may be thought as a linear form:
  805. $$x=a_1x_{m+1}+a_2x_{m+2}+\dots+a_nx_{m+n},$$
  806. where $x$ is an auxiliary variable for this row, $a_j$ are coefficients
  807. of the linear form, $x_{m+j}$ are structural variables.
  808. On entry column indices and numerical values of non-zero coefficients
  809. $a_j$ of the specified row should be placed in locations \verb|ind[1]|,
  810. \dots, \verb|ind[len]| and \verb|val[1]|, \dots, \verb|val[len]|, where
  811. \verb|len| is number of non-zero coefficients.
  812. This routine uses the system of equality constraints and the current
  813. basis in order to express the auxiliary variable $x$ through the current
  814. non-basic variables (as if the transformed row were added to the problem
  815. object and the auxiliary variable $x$ were basic), i.e. the resultant
  816. row has the form:
  817. $$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n,$$
  818. where $\xi_j$ are influence coefficients, $(x_N)_j$ are non-basic
  819. (auxiliary and structural) variables, $n$ is the number of columns in
  820. the problem object.
  821. On exit the routine stores indices and numerical values of non-zero
  822. coefficients $\xi_j$ of the resultant row in locations \verb|ind[1]|,
  823. \dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|,
  824. where $0\leq{\tt len'}\leq n$ is the number of non-zero coefficients in
  825. the resultant row returned by the routine. Note that indices of
  826. non-basic variables stored in the array \verb|ind| correspond to
  827. original ordinal numbers of variables: indices 1 to $m$ mean auxiliary
  828. variables and indices $m+1$ to $m+n$ mean structural ones.
  829. \returns
  830. The routine \verb|glp_transform_row| returns \verb|len'|, the number of
  831. non-zero coefficients in the resultant row stored in the arrays
  832. \verb|ind| and \verb|val|.
  833. \newpage
  834. \subsection{glp\_transform\_col --- transform explicitly specified
  835. column}
  836. \synopsis
  837. \begin{verbatim}
  838. int glp_transform_col(glp_prob *P, int len, int ind[], double val[]);
  839. \end{verbatim}
  840. \description
  841. The routine \verb|glp_transform_col| performs the same operation as the
  842. routine \verb|glp_eval_tab_col| with exception that the column to be
  843. transformed is specified explicitly as a sparse vector.
  844. The explicitly specified column may be thought as it were added to
  845. the original system of equality constraints:
  846. $$
  847. \begin{array}{l@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r}
  848. x_1&=&a_{11}x_{m+1}&+\dots+&a_{1n}x_{m+n}&+&a_1x \\
  849. x_2&=&a_{21}x_{m+1}&+\dots+&a_{2n}x_{m+n}&+&a_2x \\
  850. \multicolumn{7}{c}
  851. {.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  852. x_m&=&a_{m1}x_{m+1}&+\dots+&a_{mn}x_{m+n}&+&a_mx \\
  853. \end{array}
  854. $$
  855. where $x_i$ are auxiliary variables, $x_{m+j}$ are structural variables
  856. (presented in the problem object), $x$ is a structural variable for the
  857. explicitly specified column, $a_i$ are constraint coefficients at $x$.
  858. On entry row indices and numerical values of non-zero coefficients
  859. $a_i$ of the specified column should be placed in locations
  860. \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|, \dots,
  861. \verb|val[len]|, where \verb|len| is number of non-zero coefficients.
  862. This routine uses the system of equality constraints and the current
  863. basis in order to express the current basic variables through the
  864. structural variable $x$ (as if the transformed column were added to the
  865. problem object and the variable $x$ were non-basic):
  866. $$
  867. \begin{array}{l@{\ }c@{\ }r}
  868. (x_B)_1&=\dots+&\xi_{1}x\\
  869. (x_B)_2&=\dots+&\xi_{2}x\\
  870. \multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  871. (x_B)_m&=\dots+&\xi_{m}x\\
  872. \end{array}
  873. $$
  874. where $\xi_i$ are influence coefficients, $x_B$ are basic (auxiliary
  875. and structural) variables, $m$ is the number of rows in the problem
  876. object.
  877. On exit the routine stores indices and numerical values of non-zero
  878. coefficients $\xi_i$ of the resultant column in locations \verb|ind[1]|,
  879. \dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|,
  880. where $0\leq{\tt len'}\leq m$ is the number of non-zero coefficients in
  881. the resultant column returned by the routine. Note that indices of basic
  882. variables stored in the array \verb|ind| correspond to original ordinal
  883. numbers of variables, i.e. indices 1 to $m$ mean auxiliary variables,
  884. indices $m+1$ to $m+n$ mean structural ones.
  885. \returns
  886. The routine \verb|glp_transform_col| returns \verb|len'|, the number of
  887. non-zero coefficients in the resultant column stored in the arrays
  888. \verb|ind| and \verb|val|.
  889. \newpage
  890. \subsection{glp\_prim\_rtest --- perform primal ratio test}
  891. \synopsis
  892. \begin{verbatim}
  893. int glp_prim_rtest(glp_prob *P, int len, const int ind[], const double val[],
  894. int dir, double eps);
  895. \end{verbatim}
  896. \description
  897. The routine \verb|glp_prim_rtest| performs the primal ratio test using
  898. an explicitly specified column of the simplex table.
  899. The current basic solution associated with the LP problem object must
  900. be primal feasible.
  901. The explicitly specified column of the simplex table shows how the
  902. basic variables $x_B$ depend on some non-basic variable $x$ (which is
  903. not necessarily presented in the problem object):
  904. $$
  905. \begin{array}{l@{\ }c@{\ }r}
  906. (x_B)_1&=\dots+&\xi_{1}x\\
  907. (x_B)_2&=\dots+&\xi_{2}x\\
  908. \multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  909. (x_B)_m&=\dots+&\xi_{m}x\\
  910. \end{array}
  911. $$
  912. The column is specifed on entry to the routine in sparse format.
  913. Ordinal numbers of basic variables $(x_B)_i$ should be placed in
  914. locations \verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal number
  915. 1 to $m$ denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$
  916. denote structural variables. The corresponding non-zero coefficients
  917. $\xi_i$ should be placed in locations
  918. \verb|val[1]|, \dots, \verb|val[len]|. The arrays \verb|ind| and
  919. \verb|val| are not changed by the routine.
  920. The parameter \verb|dir| specifies direction in which the variable $x$
  921. changes on entering the basis: $+1$ means increasing, $-1$ means
  922. decreasing.
  923. The parameter \verb|eps| is an absolute tolerance (small positive
  924. number, say, $10^{-9}$) used by the routine to skip $\xi_i$'s whose
  925. magnitude is less than \verb|eps|.
  926. The routine determines which basic variable (among those specified in
  927. \verb|ind[1]|, \dots, \verb|ind[len]|) reaches its (lower or upper)
  928. bound first before any other basic variables do, and which, therefore,
  929. should leave the basis in order to keep primal feasibility.
  930. \returns
  931. The routine \verb|glp_prim_rtest| returns the index, \verb|piv|, in the
  932. arrays \verb|ind| and \verb|val| corresponding to the pivot element
  933. chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic
  934. solution is primal unbounded, and therefore the choice cannot be made,
  935. the routine returns zero.
  936. \para{Comments}
  937. If the non-basic variable $x$ is presented in the LP problem object,
  938. the input column can be computed with the routine
  939. \verb|glp_eval_tab_col|; otherwise, it can be computed with the routine
  940. \verb|glp_transform_col|.
  941. \newpage
  942. \subsection{glp\_dual\_rtest --- perform dual ratio test}
  943. \synopsis
  944. \begin{verbatim}
  945. int glp_dual_rtest(glp_prob *P, int len, const int ind[], const double val[],
  946. int dir, double eps);
  947. \end{verbatim}
  948. \description
  949. The routine \verb|glp_dual_rtest| performs the dual ratio test using
  950. an explicitly specified row of the simplex table.
  951. The current basic solution associated with the LP problem object must
  952. be dual feasible.
  953. The explicitly specified row of the simplex table is a linear form
  954. that shows how some basic variable $x$ (which is not necessarily
  955. presented in the problem object) depends on non-basic variables $x_N$:
  956. $$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n.$$
  957. The row is specified on entry to the routine in sparse format. Ordinal
  958. numbers of non-basic variables $(x_N)_j$ should be placed in locations
  959. \verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal numbers 1 to $m$
  960. denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$ denote
  961. structural variables. The corresponding non-zero coefficients $\xi_j$
  962. should be placed in locations \verb|val[1]|, \dots, \verb|val[len]|.
  963. The arrays \verb|ind| and \verb|val| are not changed by the routine.
  964. The parameter \verb|dir| specifies direction in which the variable $x$
  965. changes on leaving the basis: $+1$ means that $x$ goes on its lower
  966. bound, so its reduced cost (dual variable) is increasing (minimization)
  967. or decreasing (maximization); $-1$ means that $x$ goes on its upper
  968. bound, so its reduced cost is decreasing (minimization) or increasing
  969. (maximization).
  970. The parameter \verb|eps| is an absolute tolerance (small positive
  971. number, say, $10^{-9}$) used by the routine to skip $\xi_j$'s whose
  972. magnitude is less than \verb|eps|.
  973. The routine determines which non-basic variable (among those specified
  974. in \verb|ind[1]|, \dots,\linebreak \verb|ind[len]|) should enter the
  975. basis in order to keep dual feasibility, because its reduced cost
  976. reaches the (zero) bound first before this occurs for any other
  977. non-basic variables.
  978. \returns
  979. The routine \verb|glp_dual_rtest| returns the index, \verb|piv|, in the
  980. arrays \verb|ind| and \verb|val| corresponding to the pivot element
  981. chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic
  982. solution is dual unbounded, and therefore the choice cannot be made,
  983. the routine returns zero.
  984. \para{Comments}
  985. If the basic variable $x$ is presented in the LP problem object, the
  986. input row can be computed\linebreak with the routine
  987. \verb|glp_eval_tab_row|; otherwise, it can be computed with the routine
  988. \linebreak \verb|glp_transform_row|.
  989. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  990. \newpage
  991. \section{Post-optimal analysis routines}
  992. \subsection{glp\_analyze\_bound --- analyze active bound of non-basic
  993. variable}
  994. \synopsis
  995. \begin{verbatim}
  996. void glp_analyze_bound(glp_prob *P, int k, double *limit1, int *var1,
  997. double *limit2, int *var2);
  998. \end{verbatim}
  999. \description
  1000. The routine \verb|glp_analyze_bound| analyzes the effect of varying the
  1001. active bound of specified non-basic variable.
  1002. The non-basic variable is specified by the parameter $k$, where
  1003. $1\leq k\leq m$ means auxiliary variable of corresponding row, and
  1004. $m+1\leq k\leq m+n$ means structural variable (column).
  1005. Note that the current basic solution must be optimal, and the basis
  1006. factorization must exist.
  1007. Results of the analysis have the following meaning.
  1008. \verb|value1| is the minimal value of the active bound, at which the
  1009. basis still remains primal feasible and thus optimal. \verb|-DBL_MAX|
  1010. means that the active bound has no lower limit.
  1011. \verb|var1| is the ordinal number of an auxiliary (1 to $m$) or
  1012. structural ($m+1$ to $m+n$) basic variable, which reaches its bound
  1013. first and thereby limits further decreasing the active bound being
  1014. analyzed. if \verb|value1| = \verb|-DBL_MAX|, \verb|var1| is set to 0.
  1015. \verb|value2| is the maximal value of the active bound, at which the
  1016. basis still remains primal feasible and thus optimal. \verb|+DBL_MAX|
  1017. means that the active bound has no upper limit.
  1018. \verb|var2| is the ordinal number of an auxiliary (1 to $m$) or
  1019. structural ($m+1$ to $m+n$) basic variable, which reaches its bound
  1020. first and thereby limits further increasing the active bound being
  1021. analyzed. if \verb|value2| = \verb|+DBL_MAX|, \verb|var2| is set to 0.
  1022. The parameters \verb|value1|, \verb|var1|, \verb|value2|, \verb|var2|
  1023. can be specified as \verb|NULL|, in which case corresponding information
  1024. is not stored.
  1025. \subsection{glp\_analyze\_coef --- analyze objective coefficient at
  1026. basic variable}
  1027. \synopsis
  1028. \begin{verbatim}
  1029. void glp_analyze_coef(glp_prob *P, int k,
  1030. double *coef1, int *var1, double *value1,
  1031. double *coef2, int *var2, double *value2);
  1032. \end{verbatim}
  1033. \description
  1034. The routine \verb|glp_analyze_coef| analyzes the effect of varying the
  1035. objective coefficient at specified basic variable.
  1036. The basic variable is specified by the parameter $k$, where
  1037. $1\leq k\leq m$ means auxiliary variable of corresponding row, and
  1038. $m+1\leq k\leq m+n$ means structural variable (column).
  1039. Note that the current basic solution must be optimal, and the basis
  1040. factorization must exist.
  1041. Results of the analysis have the following meaning.
  1042. \verb|coef1| is the minimal value of the objective coefficient, at
  1043. which the basis still remains dual feasible and thus optimal.
  1044. \verb|-DBL_MAX| means that the objective coefficient has no lower
  1045. limit.
  1046. \verb|var1| is the ordinal number of an auxiliary (1 to $m$) or
  1047. structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost
  1048. reaches its zero bound first and thereby limits further decreasing the
  1049. objective coefficient being analyzed.
  1050. If \verb|coef1| = \verb|-DBL_MAX|, \verb|var1| is set to 0.
  1051. \verb|value1| is value of the basic variable being analyzed in an
  1052. adjacent basis, which is defined as follows. Let the objective
  1053. coefficient reach its minimal value (\verb|coef1|) and continue
  1054. decreasing. Then the reduced cost of the limiting non-basic variable
  1055. (\verb|var1|) becomes dual infeasible and the current basis becomes
  1056. non-optimal that forces the limiting non-basic variable to enter the
  1057. basis replacing there some basic variable that leaves the basis to keep
  1058. primal feasibility. Should note that on determining the adjacent basis
  1059. current bounds of the basic variable being analyzed are ignored as if
  1060. it were free (unbounded) variable, so it cannot leave the basis. It may
  1061. happen that no dual feasible adjacent basis exists, in which case
  1062. \verb|value1| is set to \verb|-DBL_MAX| or \verb|+DBL_MAX|.
  1063. \verb|coef2| is the maximal value of the objective coefficient, at
  1064. which the basis still remains dual feasible and thus optimal.
  1065. \verb|+DBL_MAX| means that the objective coefficient has no upper
  1066. limit.
  1067. \verb|var2| is the ordinal number of an auxiliary (1 to $m$) or
  1068. structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost
  1069. reaches its zero bound first and thereby limits further increasing the
  1070. objective coefficient being analyzed.
  1071. If \verb|coef2| = \verb|+DBL_MAX|, \verb|var2| is set to 0.
  1072. \verb|value2| is value of the basic variable being analyzed in an
  1073. adjacent basis, which is defined exactly in the same way as
  1074. \verb|value1| above with exception that now the objective coefficient
  1075. is increasing.
  1076. The parameters \verb|coef1|, \verb|var1|, \verb|value1|, \verb|coef2|,
  1077. \verb|var2|, \verb|value2| can be specified as \verb|NULL|, in which
  1078. case corresponding information is not stored.
  1079. %* eof *%