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.

1385 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\_FT})
  460. Basis factorization type:
  461. \verb|GLP_BF_FT|---$LU$ + Forrest--Tomlin update;
  462. \verb|GLP_BF_BG|---$LU$ + Schur complement + Bartels--Golub update;
  463. \verb|GLP_BF_GR|---$LU$ + Schur complement + Givens rotation update.
  464. In case of \verb|GLP_BF_FT| the update is applied to matrix $U$, while
  465. in cases of \verb|GLP_BF_BG| and \verb|GLP_BF_GR| the update is applied
  466. to the Schur complement.
  467. \medskip
  468. {\tt int lu\_size} (default: {\tt 0})
  469. The initial size of the Sparse Vector Area, in non-zeros, used on
  470. computing $LU$-factorization of the basis matrix for the first time.
  471. If this parameter is set to 0, the initial SVA size is determined
  472. automatically.
  473. \medskip
  474. {\tt double piv\_tol} (default: {\tt 0.10})
  475. Threshold pivoting (Markowitz) tolerance, 0 $<$ \verb|piv_tol| $<$ 1,
  476. used on computing $LU$-factoriza\-tion of the basis matrix. Element
  477. $u_{ij}$ of the active submatrix of factor $U$ fits to be pivot if it
  478. satisfies to the stability criterion
  479. $|u_{ij}| >= {\tt piv\_tol}\cdot\max|u_{i*}|$, i.e. if it is not very
  480. small in the magnitude among other elements in the same row. Decreasing
  481. this parameter may lead to better sparsity at the expense of numerical
  482. accuracy, and vice versa.
  483. \medskip
  484. {\tt int piv\_lim} (default: {\tt 4})
  485. This parameter is used on computing $LU$-factorization of the basis
  486. matrix and specifies how many pivot candidates needs to be considered
  487. on choosing a pivot element, \verb|piv_lim| $\geq$ 1. If \verb|piv_lim|
  488. candidates have been considered, the pivoting routine prematurely
  489. terminates the search with the best candidate found.
  490. \newpage
  491. {\tt int suhl} (default: {\tt GLP\_ON})
  492. This parameter is used on computing $LU$-factorization of the basis
  493. matrix. Being set to {\tt GLP\_ON} it enables applying the following
  494. heuristic proposed by Uwe Suhl: if a column of the active submatrix has
  495. no eligible pivot candidates, it is no more considered until it becomes
  496. a column singleton. In many cases this allows reducing the time needed
  497. for pivot searching. To disable this heuristic the parameter
  498. \verb|suhl| should be set to {\tt GLP\_OFF}.
  499. \medskip
  500. {\tt double eps\_tol} (default: {\tt 1e-15})
  501. Epsilon tolerance, \verb|eps_tol| $\geq$ 0, used on computing
  502. $LU$-factorization of the basis matrix. If an element of the active
  503. submatrix of factor $U$ is less than \verb|eps_tol| in the magnitude,
  504. it is replaced by exact zero.
  505. \medskip
  506. {\tt double max\_gro} (default: {\tt 1e+10})
  507. Maximal growth of elements of factor $U$, \verb|max_gro| $\geq$ 1,
  508. allowable on computing $LU$-factorization of the basis matrix. If on
  509. some elimination step the ratio $u_{big}/b_{max}$ (where $u_{big}$ is
  510. the largest magnitude of elements of factor $U$ appeared in its active
  511. submatrix during all the factorization process, $b_{max}$ is the
  512. largest magnitude of elements of the basis matrix to be factorized),
  513. the basis matrix is considered as ill-conditioned.
  514. \medskip
  515. {\tt int nfs\_max} (default: {\tt 100})
  516. Maximal number of additional row-like factors (entries of the eta
  517. file), \verb|nfs_max| $\geq$ 1, which can be added to
  518. $LU$-factorization of the basis matrix on updating it with the
  519. Forrest--Tomlin technique. This parameter is used only once, before
  520. $LU$-factorization is computed for the first time, to allocate working
  521. arrays. As a rule, each update adds one new factor (however, some
  522. updates may need no addition), so this parameter limits the number of
  523. updates between refactorizations.
  524. \medskip
  525. {\tt double upd\_tol} (default: {\tt 1e-6})
  526. Update tolerance, 0 $<$ \verb|upd_tol| $<$ 1, used on updating
  527. $LU$-factorization of the basis matrix with the Forrest--Tomlin
  528. technique. If after updating the magnitude of some diagonal element
  529. $u_{kk}$ of factor $U$ becomes less than
  530. ${\tt upd\_tol}\cdot\max(|u_{k*}|, |u_{*k}|)$, the factorization is
  531. considered as inaccurate.
  532. \medskip
  533. {\tt int nrs\_max} (default: {\tt 100})
  534. Maximal number of additional rows and columns, \verb|nrs_max| $\geq$ 1,
  535. which can be added to $LU$-factorization of the basis matrix on
  536. updating it with the Schur complement technique. This parameter is used
  537. only once, before $LU$-factorization is computed for the first time, to
  538. allocate working arrays. As a rule, each update adds one new row and
  539. column (however, some updates may need no addition), so this parameter
  540. limits the number of updates between refactorizations.
  541. \medskip
  542. {\tt int rs\_size} (default: {\tt 0})
  543. The initial size of the Sparse Vector Area, in non-zeros, used to
  544. store non-zero elements of additional rows and columns introduced on
  545. updating $LU$-factorization of the basis matrix with the Schur
  546. complement technique. If this parameter is set to 0, the initial SVA
  547. size is determined automatically.
  548. \newpage
  549. \subsection{glp\_get\_bhead --- retrieve the basis header information}
  550. \synopsis
  551. \begin{verbatim}
  552. int glp_get_bhead(glp_prob *P, int k);
  553. \end{verbatim}
  554. \description
  555. The routine \verb|glp_get_bhead| returns the basis header information
  556. for the current basis associated with the specified problem object.
  557. \returns
  558. If basic variable $(x_B)_k$, $1\leq k\leq m$, is $i$-th auxiliary
  559. variable ($1\leq i\leq m$), the routine returns $i$. Otherwise, if
  560. $(x_B)_k$ is $j$-th structural variable ($1\leq j\leq n$), the routine
  561. returns $m+j$. Here $m$ is the number of rows and $n$ is the number of
  562. columns in the problem object.
  563. \para{Comments}
  564. Sometimes the application program may need to know which original
  565. (auxiliary and structural) variable correspond to a given basic
  566. variable, or, that is the same, which column of the augmented
  567. constraint matrix $(I\ |-\!A)$ correspond to a given column of the
  568. basis matrix $B$.
  569. \def\arraystretch{1}
  570. The correspondence is defined as follows:\footnote{For more details see
  571. Subsection \ref{basbgd}, page \pageref{basbgd}.}
  572. $$\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right)=
  573. \Pi\left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)
  574. \ \ \Leftrightarrow
  575. \ \ \left(\begin{array}{@{}c@{}}x_R\\x_S\\\end{array}\right)=
  576. \Pi^T\left(\begin{array}{@{}c@{}}x_B\\x_N\\\end{array}\right),$$
  577. where $x_B$ is the vector of basic variables, $x_N$ is the vector of
  578. non-basic variables, $x_R$ is the vector of auxiliary variables
  579. following in their original order,\footnote{The original order of
  580. auxiliary and structural variables is defined by the ordinal numbers
  581. of corresponding rows and columns in the problem object.} $x_S$ is the
  582. vector of structural variables following in their original order, $\Pi$
  583. is a permutation matrix (which is a component of the basis
  584. factorization).
  585. Thus, if $(x_B)_k=(x_R)_i$ is $i$-th auxiliary variable, the routine
  586. returns $i$, and if $(x_B)_k=(x_S)_j$ is $j$-th structural variable,
  587. the routine returns $m+j$, where $m$ is the number of rows in the
  588. problem object.
  589. \subsection{glp\_get\_row\_bind --- retrieve row index in the basis
  590. header}
  591. \synopsis
  592. \begin{verbatim}
  593. int glp_get_row_bind(glp_prob *P, int i);
  594. \end{verbatim}
  595. \returns
  596. The routine \verb|glp_get_row_bind| returns the index $k$ of basic
  597. variable $(x_B)_k$, $1\leq k\leq m$, which is $i$-th auxiliary variable
  598. (that is, the auxiliary variable corresponding to $i$-th row),
  599. $1\leq i\leq m$, in the current basis associated with the specified
  600. problem object, where $m$ is the number of rows. However, if $i$-th
  601. auxiliary variable is non-basic, the routine returns zero.
  602. \newpage
  603. \para{Comments}
  604. The routine \verb|glp_get_row_bind| is an inversion of the routine
  605. \verb|glp_get_bhead|; that is, if \linebreak
  606. \verb|glp_get_bhead|$(P,k)$ returns $i$,
  607. \verb|glp_get_row_bind|$(P,i)$ returns $k$, and vice versa.
  608. \subsection{glp\_get\_col\_bind --- retrieve column index in the basis
  609. header}
  610. \synopsis
  611. \begin{verbatim}
  612. int glp_get_col_bind(glp_prob *P, int j);
  613. \end{verbatim}
  614. \returns
  615. The routine \verb|glp_get_col_bind| returns the index $k$ of basic
  616. variable $(x_B)_k$, $1\leq k\leq m$, which is $j$-th structural
  617. variable (that is, the structural variable corresponding to $j$-th
  618. column), $1\leq j\leq n$, in the current basis associated with the
  619. specified problem object, where $m$ is the number of rows, $n$ is the
  620. number of columns. However, if $j$-th structural variable is non-basic,
  621. the routine returns zero.
  622. \para{Comments}
  623. The routine \verb|glp_get_col_bind| is an inversion of the routine
  624. \verb|glp_get_bhead|; that is, if \linebreak
  625. \verb|glp_get_bhead|$(P,k)$ returns $m+j$,
  626. \verb|glp_get_col_bind|$(P,j)$ returns $k$, and vice versa.
  627. \subsection{glp\_ftran --- perform forward transformation}
  628. \synopsis
  629. \begin{verbatim}
  630. void glp_ftran(glp_prob *P, double x[]);
  631. \end{verbatim}
  632. \description
  633. The routine \verb|glp_ftran| performs forward transformation (FTRAN),
  634. i.e. it solves the system $Bx=b$, where $B$ is the basis matrix
  635. associated with the specified problem object, $x$ is the vector of
  636. unknowns to be computed, $b$ is the vector of right-hand sides.
  637. On entry to the routine elements of the vector $b$ should be stored in
  638. locations \verb|x[1]|, \dots, \verb|x[m]|, where $m$ is the number of
  639. rows. On exit the routine stores elements of the vector $x$ in the same
  640. locations.
  641. \subsection{glp\_btran --- perform backward transformation}
  642. \synopsis
  643. \begin{verbatim}
  644. void glp_btran(glp_prob *P, double x[]);
  645. \end{verbatim}
  646. \description
  647. The routine \verb|glp_btran| performs backward transformation (BTRAN),
  648. i.e. it solves the system $B^Tx=b$, where $B^T$ is a matrix transposed
  649. to the basis matrix $B$ associated with the specified problem object,
  650. $x$ is the vector of unknowns to be computed, $b$ is the vector of
  651. right-hand sides.
  652. \newpage
  653. On entry to the routine elements of the vector $b$ should be stored in
  654. locations \verb|x[1]|, \dots, \verb|x[m]|, where $m$ is the number of
  655. rows. On exit the routine stores elements of the vector $x$ in the same
  656. locations.
  657. \subsection{glp\_warm\_up --- ``warm up'' LP basis}
  658. \synopsis
  659. \begin{verbatim}
  660. int glp_warm_up(glp_prob *P);
  661. \end{verbatim}
  662. \description
  663. The routine \verb|glp_warm_up| ``warms up'' the LP basis for the
  664. specified problem object using current statuses assigned to rows and
  665. columns (that is, to auxiliary and structural variables).
  666. This operation includes computing factorization of the basis matrix
  667. (if it does not exist), computing primal and dual components of basic
  668. solution, and determining the solution status.
  669. \returns
  670. \begin{retlist}
  671. 0 & The operation has been successfully performed.\\
  672. \verb|GLP_EBADB| & The basis matrix is invalid, because the number of
  673. basic (auxiliary and structural) variables is not the same as the
  674. number of rows in the problem object.\\
  675. \verb|GLP_ESING| & The basis matrix is singular within the working
  676. precision.\\
  677. \verb|GLP_ECOND| & The basis matrix is ill-conditioned, i.e. its
  678. condition number is too large.\\
  679. \end{retlist}
  680. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  681. \newpage
  682. \section{Simplex tableau routines}
  683. \subsection{glp\_eval\_tab\_row --- compute row of the tableau}
  684. \synopsis
  685. \begin{verbatim}
  686. int glp_eval_tab_row(glp_prob *P, int k, int ind[], double val[]);
  687. \end{verbatim}
  688. \description
  689. The routine \verb|glp_eval_tab_row| computes a row of the current
  690. simplex tableau (see Subsection 3.1.1, formula (3.12)), which (row)
  691. corresponds to some basic variable specified by the parameter $k$ as
  692. follows: if $1\leq k\leq m$, the basic variable is $k$-th auxiliary
  693. variable, and if $m+1\leq k\leq m+n$, the basic variable is $(k-m)$-th
  694. structural variable, where $m$ is the number of rows and $n$ is the
  695. number of columns in the specified problem object. The basis
  696. factorization must exist.
  697. The computed row shows how the specified basic variable depends on
  698. non-basic variables:
  699. $$x_k=(x_B)_i=\xi_{i1}(x_N)_1+\xi_{i2}(x_N)_2+\dots+\xi_{in}(x_N)_n,$$
  700. where $\xi_{i1}$, $\xi_{i2}$, \dots, $\xi_{in}$ are elements of the
  701. simplex table row, $(x_N)_1$, $(x_N)_2$, \dots, $(x_N)_n$ are non-basic
  702. (auxiliary and structural) variables.
  703. The routine stores column indices and corresponding numeric values of
  704. non-zero elements of the computed row in unordered sparse format in
  705. locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,
  706. \dots, \verb|val[len]|, respectively, where $0\leq{\tt len}\leq n$ is
  707. the number of non-zero elements in the row returned on exit.
  708. Element indices stored in the array \verb|ind| have the same sense as
  709. index $k$, i.e. indices 1 to $m$ denote auxiliary variables while
  710. indices $m+1$ to $m+n$ denote structural variables (all these variables
  711. are obviously non-basic by definition).
  712. \returns
  713. The routine \verb|glp_eval_tab_row| returns \verb|len|, which is the
  714. number of non-zero elements in the simplex table row stored in the
  715. arrays \verb|ind| and \verb|val|.
  716. \para{Comments}
  717. A row of the simplex table is computed as follows. At first, the
  718. routine checks that the specified variable $x_k$ is basic and uses the
  719. permutation matrix $\Pi$ (3.7) to determine index $i$ of basic variable
  720. $(x_B)_i$, which corresponds to $x_k$.
  721. The row to be computed is $i$-th row of the matrix $\Xi$ (3.12),
  722. therefore:
  723. $$\xi_i=e_i^T\Xi=-e_i^TB^{-1}N=-(B^{-T}e_i)^TN,$$
  724. where $e_i$ is $i$-th unity vector. So the routine performs BTRAN to
  725. obtain $i$-th row of the inverse $B^{-1}$:
  726. $$\varrho_i=B^{-T}e_i,$$
  727. and then computes elements of the simplex table row as inner products:
  728. $$\xi_{ij}=-\varrho_i^TN_j,\ \ j=1,2,\dots,n,$$
  729. where $N_j$ is $j$-th column of matrix $N$ (3.9), which (column)
  730. corresponds to non-basic variable $(x_N)_j$. The permutation matrix
  731. $\Pi$ is used again to convert indices $j$ of non-basic columns to
  732. original ordinal numbers of auxiliary and structural variables.
  733. \subsection{glp\_eval\_tab\_col --- compute column of the tableau}
  734. \synopsis
  735. \begin{verbatim}
  736. int glp_eval_tab_col(glp_prob *P, int k, int ind[], double val[]);
  737. \end{verbatim}
  738. \description
  739. The routine \verb|glp_eval_tab_col| computes a column of the current
  740. simplex tableau (see Subsection 3.1.1, formula (3.12)), which (column)
  741. corresponds to some non-basic variable specified by the parameter $k$:
  742. if $1\leq k\leq m$, the non-basic variable is $k$-th auxiliary
  743. variable, and if $m+1\leq k\leq m+n$, the non-basic variable is
  744. $(k-m)$-th structural variable, where $m$ is the number of rows and $n$
  745. is the number of columns in the specified problem object. The basis
  746. factorization must exist.
  747. The computed column shows how basic variables depends on the specified
  748. non-basic variable $x_k=(x_N)_j$:
  749. $$
  750. \begin{array}{r@{\ }c@{\ }l@{\ }l}
  751. (x_B)_1&=&\dots+\xi_{1j}(x_N)_j&+\dots\\
  752. (x_B)_2&=&\dots+\xi_{2j}(x_N)_j&+\dots\\
  753. .\ \ .&.&.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\\
  754. (x_B)_m&=&\dots+\xi_{mj}(x_N)_j&+\dots\\
  755. \end{array}
  756. $$
  757. where $\xi_{1j}$, $\xi_{2j}$, \dots, $\xi_{mj}$ are elements of the
  758. simplex table column, $(x_B)_1$, $(x_B)_2$, \dots, $(x_B)_m$ are basic
  759. (auxiliary and structural) variables.
  760. The routine stores row indices and corresponding numeric values of
  761. non-zero elements of the computed column in unordered sparse format in
  762. locations \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|,
  763. \dots, \verb|val[len]|, respectively, where $0\leq{\tt len}\leq m$ is
  764. the number of non-zero elements in the column returned on exit.
  765. Element indices stored in the array \verb|ind| have the same sense as
  766. index $k$, i.e. indices 1 to $m$ denote auxiliary variables while
  767. indices $m+1$ to $m+n$ denote structural variables (all these variables
  768. are obviously basic by definition).
  769. \returns
  770. The routine \verb|glp_eval_tab_col| returns \verb|len|, which is the
  771. number of non-zero elements in the simplex table column stored in the
  772. arrays \verb|ind| and \verb|val|.
  773. \para{Comments}
  774. A column of the simplex table is computed as follows. At first, the
  775. routine checks that the specified variable $x_k$ is non-basic and uses
  776. the permutation matrix $\Pi$ (3.7) to determine index $j$ of non-basic
  777. variable $(x_N)_j$, which corresponds to $x_k$.
  778. The column to be computed is $j$-th column of the matrix $\Xi$ (3.12),
  779. therefore:
  780. $$\Xi_j=\Xi e_j=-B^{-1}Ne_j=-B^{-1}N_j,$$
  781. where $e_j$ is $j$-th unity vector, $N_j$ is $j$-th column of matrix
  782. $N$ (3.9). So the routine performs FTRAN to transform $N_j$ to the
  783. simplex table column $\Xi_j=(\xi_{ij})$ and uses the permutation matrix
  784. $\Pi$ to convert row indices $i$ to original ordinal numbers of
  785. auxiliary and structural variables.
  786. \subsection{glp\_transform\_row --- transform explicitly specified row}
  787. \synopsis
  788. \begin{verbatim}
  789. int glp_transform_row(glp_prob *P, int len, int ind[], double val[]);
  790. \end{verbatim}
  791. \description
  792. The routine \verb|glp_transform_row| performs the same operation as the
  793. routine \verb|glp_eval_tab_row| with exception that the row to be
  794. transformed is specified explicitly as a sparse vector.
  795. The explicitly specified row may be thought as a linear form:
  796. $$x=a_1x_{m+1}+a_2x_{m+2}+\dots+a_nx_{m+n},$$
  797. where $x$ is an auxiliary variable for this row, $a_j$ are coefficients
  798. of the linear form, $x_{m+j}$ are structural variables.
  799. On entry column indices and numerical values of non-zero coefficients
  800. $a_j$ of the specified row should be placed in locations \verb|ind[1]|,
  801. \dots, \verb|ind[len]| and \verb|val[1]|, \dots, \verb|val[len]|, where
  802. \verb|len| is number of non-zero coefficients.
  803. This routine uses the system of equality constraints and the current
  804. basis in order to express the auxiliary variable $x$ through the current
  805. non-basic variables (as if the transformed row were added to the problem
  806. object and the auxiliary variable $x$ were basic), i.e. the resultant
  807. row has the form:
  808. $$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n,$$
  809. where $\xi_j$ are influence coefficients, $(x_N)_j$ are non-basic
  810. (auxiliary and structural) variables, $n$ is the number of columns in
  811. the problem object.
  812. On exit the routine stores indices and numerical values of non-zero
  813. coefficients $\xi_j$ of the resultant row in locations \verb|ind[1]|,
  814. \dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|,
  815. where $0\leq{\tt len'}\leq n$ is the number of non-zero coefficients in
  816. the resultant row returned by the routine. Note that indices of
  817. non-basic variables stored in the array \verb|ind| correspond to
  818. original ordinal numbers of variables: indices 1 to $m$ mean auxiliary
  819. variables and indices $m+1$ to $m+n$ mean structural ones.
  820. \returns
  821. The routine \verb|glp_transform_row| returns \verb|len'|, the number of
  822. non-zero coefficients in the resultant row stored in the arrays
  823. \verb|ind| and \verb|val|.
  824. \newpage
  825. \subsection{glp\_transform\_col --- transform explicitly specified
  826. column}
  827. \synopsis
  828. \begin{verbatim}
  829. int glp_transform_col(glp_prob *P, int len, int ind[], double val[]);
  830. \end{verbatim}
  831. \description
  832. The routine \verb|glp_transform_col| performs the same operation as the
  833. routine \verb|glp_eval_tab_col| with exception that the column to be
  834. transformed is specified explicitly as a sparse vector.
  835. The explicitly specified column may be thought as it were added to
  836. the original system of equality constraints:
  837. $$
  838. \begin{array}{l@{\ }c@{\ }r@{\ }c@{\ }r@{\ }c@{\ }r}
  839. x_1&=&a_{11}x_{m+1}&+\dots+&a_{1n}x_{m+n}&+&a_1x \\
  840. x_2&=&a_{21}x_{m+1}&+\dots+&a_{2n}x_{m+n}&+&a_2x \\
  841. \multicolumn{7}{c}
  842. {.\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  843. x_m&=&a_{m1}x_{m+1}&+\dots+&a_{mn}x_{m+n}&+&a_mx \\
  844. \end{array}
  845. $$
  846. where $x_i$ are auxiliary variables, $x_{m+j}$ are structural variables
  847. (presented in the problem object), $x$ is a structural variable for the
  848. explicitly specified column, $a_i$ are constraint coefficients at $x$.
  849. On entry row indices and numerical values of non-zero coefficients
  850. $a_i$ of the specified column should be placed in locations
  851. \verb|ind[1]|, \dots, \verb|ind[len]| and \verb|val[1]|, \dots,
  852. \verb|val[len]|, where \verb|len| is number of non-zero coefficients.
  853. This routine uses the system of equality constraints and the current
  854. basis in order to express the current basic variables through the
  855. structural variable $x$ (as if the transformed column were added to the
  856. problem object and the variable $x$ were non-basic):
  857. $$
  858. \begin{array}{l@{\ }c@{\ }r}
  859. (x_B)_1&=\dots+&\xi_{1}x\\
  860. (x_B)_2&=\dots+&\xi_{2}x\\
  861. \multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  862. (x_B)_m&=\dots+&\xi_{m}x\\
  863. \end{array}
  864. $$
  865. where $\xi_i$ are influence coefficients, $x_B$ are basic (auxiliary
  866. and structural) variables, $m$ is the number of rows in the problem
  867. object.
  868. On exit the routine stores indices and numerical values of non-zero
  869. coefficients $\xi_i$ of the resultant column in locations \verb|ind[1]|,
  870. \dots, \verb|ind[len']| and \verb|val[1]|, \dots, \verb|val[len']|,
  871. where $0\leq{\tt len'}\leq m$ is the number of non-zero coefficients in
  872. the resultant column returned by the routine. Note that indices of basic
  873. variables stored in the array \verb|ind| correspond to original ordinal
  874. numbers of variables, i.e. indices 1 to $m$ mean auxiliary variables,
  875. indices $m+1$ to $m+n$ mean structural ones.
  876. \returns
  877. The routine \verb|glp_transform_col| returns \verb|len'|, the number of
  878. non-zero coefficients in the resultant column stored in the arrays
  879. \verb|ind| and \verb|val|.
  880. \newpage
  881. \subsection{glp\_prim\_rtest --- perform primal ratio test}
  882. \synopsis
  883. \begin{verbatim}
  884. int glp_prim_rtest(glp_prob *P, int len, const int ind[], const double val[],
  885. int dir, double eps);
  886. \end{verbatim}
  887. \description
  888. The routine \verb|glp_prim_rtest| performs the primal ratio test using
  889. an explicitly specified column of the simplex table.
  890. The current basic solution associated with the LP problem object must
  891. be primal feasible.
  892. The explicitly specified column of the simplex table shows how the
  893. basic variables $x_B$ depend on some non-basic variable $x$ (which is
  894. not necessarily presented in the problem object):
  895. $$
  896. \begin{array}{l@{\ }c@{\ }r}
  897. (x_B)_1&=\dots+&\xi_{1}x\\
  898. (x_B)_2&=\dots+&\xi_{2}x\\
  899. \multicolumn{3}{c}{.\ \ .\ \ .\ \ .\ \ .\ \ .}\\
  900. (x_B)_m&=\dots+&\xi_{m}x\\
  901. \end{array}
  902. $$
  903. The column is specifed on entry to the routine in sparse format.
  904. Ordinal numbers of basic variables $(x_B)_i$ should be placed in
  905. locations \verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal number
  906. 1 to $m$ denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$
  907. denote structural variables. The corresponding non-zero coefficients
  908. $\xi_i$ should be placed in locations
  909. \verb|val[1]|, \dots, \verb|val[len]|. The arrays \verb|ind| and
  910. \verb|val| are not changed by the routine.
  911. The parameter \verb|dir| specifies direction in which the variable $x$
  912. changes on entering the basis: $+1$ means increasing, $-1$ means
  913. decreasing.
  914. The parameter \verb|eps| is an absolute tolerance (small positive
  915. number, say, $10^{-9}$) used by the routine to skip $\xi_i$'s whose
  916. magnitude is less than \verb|eps|.
  917. The routine determines which basic variable (among those specified in
  918. \verb|ind[1]|, \dots, \verb|ind[len]|) reaches its (lower or upper)
  919. bound first before any other basic variables do, and which, therefore,
  920. should leave the basis in order to keep primal feasibility.
  921. \returns
  922. The routine \verb|glp_prim_rtest| returns the index, \verb|piv|, in the
  923. arrays \verb|ind| and \verb|val| corresponding to the pivot element
  924. chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic
  925. solution is primal unbounded, and therefore the choice cannot be made,
  926. the routine returns zero.
  927. \para{Comments}
  928. If the non-basic variable $x$ is presented in the LP problem object,
  929. the input column can be computed with the routine
  930. \verb|glp_eval_tab_col|; otherwise, it can be computed with the routine
  931. \verb|glp_transform_col|.
  932. \newpage
  933. \subsection{glp\_dual\_rtest --- perform dual ratio test}
  934. \synopsis
  935. \begin{verbatim}
  936. int glp_dual_rtest(glp_prob *P, int len, const int ind[], const double val[],
  937. int dir, double eps);
  938. \end{verbatim}
  939. \description
  940. The routine \verb|glp_dual_rtest| performs the dual ratio test using
  941. an explicitly specified row of the simplex table.
  942. The current basic solution associated with the LP problem object must
  943. be dual feasible.
  944. The explicitly specified row of the simplex table is a linear form
  945. that shows how some basic variable $x$ (which is not necessarily
  946. presented in the problem object) depends on non-basic variables $x_N$:
  947. $$x=\xi_1(x_N)_1+\xi_2(x_N)_2+\dots+\xi_n(x_N)_n.$$
  948. The row is specified on entry to the routine in sparse format. Ordinal
  949. numbers of non-basic variables $(x_N)_j$ should be placed in locations
  950. \verb|ind[1]|, \dots, \verb|ind[len]|, where ordinal numbers 1 to $m$
  951. denote auxiliary variables, and ordinal numbers $m+1$ to $m+n$ denote
  952. structural variables. The corresponding non-zero coefficients $\xi_j$
  953. should be placed in locations \verb|val[1]|, \dots, \verb|val[len]|.
  954. The arrays \verb|ind| and \verb|val| are not changed by the routine.
  955. The parameter \verb|dir| specifies direction in which the variable $x$
  956. changes on leaving the basis: $+1$ means that $x$ goes on its lower
  957. bound, so its reduced cost (dual variable) is increasing (minimization)
  958. or decreasing (maximization); $-1$ means that $x$ goes on its upper
  959. bound, so its reduced cost is decreasing (minimization) or increasing
  960. (maximization).
  961. The parameter \verb|eps| is an absolute tolerance (small positive
  962. number, say, $10^{-9}$) used by the routine to skip $\xi_j$'s whose
  963. magnitude is less than \verb|eps|.
  964. The routine determines which non-basic variable (among those specified
  965. in \verb|ind[1]|, \dots,\linebreak \verb|ind[len]|) should enter the
  966. basis in order to keep dual feasibility, because its reduced cost
  967. reaches the (zero) bound first before this occurs for any other
  968. non-basic variables.
  969. \returns
  970. The routine \verb|glp_dual_rtest| returns the index, \verb|piv|, in the
  971. arrays \verb|ind| and \verb|val| corresponding to the pivot element
  972. chosen, $1\leq$ \verb|piv| $\leq$ \verb|len|. If the adjacent basic
  973. solution is dual unbounded, and therefore the choice cannot be made,
  974. the routine returns zero.
  975. \para{Comments}
  976. If the basic variable $x$ is presented in the LP problem object, the
  977. input row can be computed\linebreak with the routine
  978. \verb|glp_eval_tab_row|; otherwise, it can be computed with the routine
  979. \linebreak \verb|glp_transform_row|.
  980. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  981. \newpage
  982. \section{Post-optimal analysis routines}
  983. \subsection{glp\_analyze\_bound --- analyze active bound of non-basic
  984. variable}
  985. \synopsis
  986. \begin{verbatim}
  987. void glp_analyze_bound(glp_prob *P, int k, double *limit1, int *var1,
  988. double *limit2, int *var2);
  989. \end{verbatim}
  990. \description
  991. The routine \verb|glp_analyze_bound| analyzes the effect of varying the
  992. active bound of specified non-basic variable.
  993. The non-basic variable is specified by the parameter $k$, where
  994. $1\leq k\leq m$ means auxiliary variable of corresponding row, and
  995. $m+1\leq k\leq m+n$ means structural variable (column).
  996. Note that the current basic solution must be optimal, and the basis
  997. factorization must exist.
  998. Results of the analysis have the following meaning.
  999. \verb|value1| is the minimal value of the active bound, at which the
  1000. basis still remains primal feasible and thus optimal. \verb|-DBL_MAX|
  1001. means that the active bound has no lower limit.
  1002. \verb|var1| is the ordinal number of an auxiliary (1 to $m$) or
  1003. structural ($m+1$ to $m+n$) basic variable, which reaches its bound
  1004. first and thereby limits further decreasing the active bound being
  1005. analyzed. if \verb|value1| = \verb|-DBL_MAX|, \verb|var1| is set to 0.
  1006. \verb|value2| is the maximal value of the active bound, at which the
  1007. basis still remains primal feasible and thus optimal. \verb|+DBL_MAX|
  1008. means that the active bound has no upper limit.
  1009. \verb|var2| is the ordinal number of an auxiliary (1 to $m$) or
  1010. structural ($m+1$ to $m+n$) basic variable, which reaches its bound
  1011. first and thereby limits further increasing the active bound being
  1012. analyzed. if \verb|value2| = \verb|+DBL_MAX|, \verb|var2| is set to 0.
  1013. The parameters \verb|value1|, \verb|var1|, \verb|value2|, \verb|var2|
  1014. can be specified as \verb|NULL|, in which case corresponding information
  1015. is not stored.
  1016. \subsection{glp\_analyze\_coef --- analyze objective coefficient at
  1017. basic variable}
  1018. \synopsis
  1019. \begin{verbatim}
  1020. void glp_analyze_coef(glp_prob *P, int k,
  1021. double *coef1, int *var1, double *value1,
  1022. double *coef2, int *var2, double *value2);
  1023. \end{verbatim}
  1024. \description
  1025. The routine \verb|glp_analyze_coef| analyzes the effect of varying the
  1026. objective coefficient at specified basic variable.
  1027. The basic variable is specified by the parameter $k$, where
  1028. $1\leq k\leq m$ means auxiliary variable of corresponding row, and
  1029. $m+1\leq k\leq m+n$ means structural variable (column).
  1030. Note that the current basic solution must be optimal, and the basis
  1031. factorization must exist.
  1032. Results of the analysis have the following meaning.
  1033. \verb|coef1| is the minimal value of the objective coefficient, at
  1034. which the basis still remains dual feasible and thus optimal.
  1035. \verb|-DBL_MAX| means that the objective coefficient has no lower
  1036. limit.
  1037. \verb|var1| is the ordinal number of an auxiliary (1 to $m$) or
  1038. structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost
  1039. reaches its zero bound first and thereby limits further decreasing the
  1040. objective coefficient being analyzed.
  1041. If \verb|coef1| = \verb|-DBL_MAX|, \verb|var1| is set to 0.
  1042. \verb|value1| is value of the basic variable being analyzed in an
  1043. adjacent basis, which is defined as follows. Let the objective
  1044. coefficient reach its minimal value (\verb|coef1|) and continue
  1045. decreasing. Then the reduced cost of the limiting non-basic variable
  1046. (\verb|var1|) becomes dual infeasible and the current basis becomes
  1047. non-optimal that forces the limiting non-basic variable to enter the
  1048. basis replacing there some basic variable that leaves the basis to keep
  1049. primal feasibility. Should note that on determining the adjacent basis
  1050. current bounds of the basic variable being analyzed are ignored as if
  1051. it were free (unbounded) variable, so it cannot leave the basis. It may
  1052. happen that no dual feasible adjacent basis exists, in which case
  1053. \verb|value1| is set to \verb|-DBL_MAX| or \verb|+DBL_MAX|.
  1054. \verb|coef2| is the maximal value of the objective coefficient, at
  1055. which the basis still remains dual feasible and thus optimal.
  1056. \verb|+DBL_MAX| means that the objective coefficient has no upper
  1057. limit.
  1058. \verb|var2| is the ordinal number of an auxiliary (1 to $m$) or
  1059. structural ($m+1$ to $m+n$) non-basic variable, whose reduced cost
  1060. reaches its zero bound first and thereby limits further increasing the
  1061. objective coefficient being analyzed.
  1062. If \verb|coef2| = \verb|+DBL_MAX|, \verb|var2| is set to 0.
  1063. \verb|value2| is value of the basic variable being analyzed in an
  1064. adjacent basis, which is defined exactly in the same way as
  1065. \verb|value1| above with exception that now the objective coefficient
  1066. is increasing.
  1067. The parameters \verb|coef1|, \verb|var1|, \verb|value1|, \verb|coef2|,
  1068. \verb|var2|, \verb|value2| can be specified as \verb|NULL|, in which
  1069. case corresponding information is not stored.
  1070. %* eof *%