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.

1572 lines
51 KiB

  1. %* glpk03.tex *%
  2. \chapter{Utility API routines}
  3. \section{Problem data reading/writing routines}
  4. \subsection{glp\_read\_mps --- read problem data in MPS format}
  5. \synopsis
  6. \begin{verbatim}
  7. int glp_read_mps(glp_prob *P, int fmt, const glp_mpscp *parm,
  8. const char *fname);
  9. \end{verbatim}
  10. \description
  11. The routine \verb|glp_read_mps| reads problem data in MPS format from a
  12. text file. (The MPS format is described in Appendix \ref{champs}, page
  13. \pageref{champs}.)
  14. The parameter \verb|fmt| specifies the MPS format version as follows:
  15. \verb|GLP_MPS_DECK| --- fixed (ancient) MPS format;
  16. \verb|GLP_MPS_FILE| --- free (modern) MPS format.
  17. The parameter \verb|parm| is reserved for use in the future and should
  18. be specified as \verb|NULL|.
  19. The character string \verb|fname| specifies a name of the text file to
  20. be read in. (If the file name ends with suffix `\verb|.gz|', the file
  21. is assumed to be compressed, in which case the routine
  22. \verb|glp_read_mps| decompresses it ``on the fly''.)
  23. Note that before reading data the current content of the problem object
  24. is completely erased with the routine \verb|glp_erase_prob|.
  25. \returns
  26. If the operation was successful, the routine \verb|glp_read_mps|
  27. returns zero. Otherwise, it prints an error message and returns
  28. non-zero.
  29. \newpage
  30. \subsection{glp\_write\_mps --- write problem data in MPS format}
  31. \synopsis
  32. \begin{verbatim}
  33. int glp_write_mps(glp_prob *P, int fmt, const glp_mpscp *parm,
  34. const char *fname);
  35. \end{verbatim}
  36. \description
  37. The routine \verb|glp_write_mps| writes problem data in MPS format to
  38. a text file. (The MPS format is described in Appendix \ref{champs},
  39. page \pageref{champs}.)
  40. The parameter \verb|fmt| specifies the MPS format version as follows:
  41. \verb|GLP_MPS_DECK| --- fixed (ancient) MPS format;
  42. \verb|GLP_MPS_FILE| --- free (modern) MPS format.
  43. The parameter \verb|parm| is reserved for use in the future and should
  44. be specified as \verb|NULL|.
  45. The character string \verb|fname| specifies a name of the text file to
  46. be written out. (If the file name ends with suffix `\verb|.gz|', the
  47. file is assumed to be compressed, in which case the routine
  48. \verb|glp_write_mps| performs automatic compression on writing it.)
  49. \returns
  50. If the operation was successful, the routine \verb|glp_write_mps|
  51. returns zero. Otherwise, it prints an error message and returns
  52. non-zero.
  53. \subsection{glp\_read\_lp --- read problem data in CPLEX LP format}
  54. \synopsis
  55. {\tt int glp\_read\_lp(glp\_prob *P, const glp\_cpxcp *parm,
  56. const char *fname);}
  57. \description
  58. The routine \verb|glp_read_lp| reads problem data in CPLEX LP format
  59. from a text file. (The CPLEX LP format is described in Appendix
  60. \ref{chacplex}, page \pageref{chacplex}.)
  61. The parameter \verb|parm| is reserved for use in the future and should
  62. be specified as \verb|NULL|.
  63. The character string \verb|fname| specifies a name of the text file to
  64. be read in. (If the file name ends with suffix `\verb|.gz|', the file
  65. is assumed to be compressed, in which case the routine
  66. \verb|glp_read_lp| decompresses it ``on the fly''.)
  67. Note that before reading data the current content of the problem object
  68. is completely erased with the routine \verb|glp_erase_prob|.
  69. \returns
  70. If the operation was successful, the routine \verb|glp_read_lp| returns
  71. zero. Otherwise, it prints an error message and returns non-zero.
  72. \newpage
  73. \subsection{glp\_write\_lp --- write problem data in CPLEX LP format}
  74. \synopsis
  75. {\tt int glp\_write\_lp(glp\_prob *P, const glp\_cpxcp *parm,
  76. const char *fname);}
  77. \description
  78. The routine \verb|glp_write_lp| writes problem data in CPLEX LP format
  79. to a text file. (The CPLEX LP format is described in Appendix
  80. \ref{chacplex}, page \pageref{chacplex}.)
  81. The parameter \verb|parm| is reserved for use in the future and should
  82. be specified as \verb|NULL|.
  83. The character string \verb|fname| specifies a name of the text file to
  84. be written out. (If the file name ends with suffix `\verb|.gz|', the
  85. file is assumed to be compressed, in which case the routine
  86. \verb|glp_write_lp| performs automatic compression on writing it.)
  87. \returns
  88. If the operation was successful, the routine \verb|glp_write_lp|
  89. returns zero. Otherwise, it prints an error message and returns
  90. non-zero.
  91. \subsection{glp\_read\_prob --- read problem data in GLPK format}
  92. \synopsis
  93. \begin{verbatim}
  94. int glp_read_prob(glp_prob *P, int flags, const char *fname);
  95. \end{verbatim}
  96. \description
  97. The routine \verb|glp_read_prob| reads problem data in the GLPK LP/MIP
  98. format from a text file. (For description of the GLPK LP/MIP format see
  99. below.)
  100. The parameter \verb|flags| is reserved for use in the future and should
  101. be specified as zero.
  102. The character string \verb|fname| specifies a name of the text file to
  103. be read in. (If the file name ends with suffix `\verb|.gz|', the file
  104. is assumed to be compressed, in which case the routine
  105. \verb|glp_read_prob| decompresses it ``on the fly''.)
  106. Note that before reading data the current content of the problem object
  107. is completely erased with the routine \verb|glp_erase_prob|.
  108. \returns
  109. If the operation was successful, the routine \verb|glp_read_prob|
  110. returns zero. Otherwise, it prints an error message and returns
  111. non-zero.
  112. \newpage
  113. \para{GLPK LP/MIP format}
  114. The GLPK LP/MIP format is a DIMACS-like format.\footnote{The DIMACS
  115. formats were developed by the Center for Discrete Mathematics and
  116. Theoretical Computer Science (DIMACS) to facilitate exchange of problem
  117. data. For details see: {\tt <http://dimacs.rutgers.edu/Challenges/>}. }
  118. The file in this format is a plain ASCII text file containing lines of
  119. several types described below. A line is terminated with the
  120. end-of-line character. Fields in each line are separated by at least
  121. one blank space. Each line begins with a one-character designator to
  122. identify the line type.
  123. The first line of the data file must be the problem line (except
  124. optional comment lines, which may precede the problem line). The last
  125. line of the data file must be the end line. Other lines may follow in
  126. arbitrary order, however, duplicate lines are not allowed.
  127. \para{Comment lines.} Comment lines give human-readable
  128. information about the data file and are ignored by GLPK routines.
  129. Comment lines can appear anywhere in the data file. Each comment line
  130. begins with the lower-case character \verb|c|.
  131. \begin{verbatim}
  132. c This is an example of comment line
  133. \end{verbatim}
  134. \para{Problem line.} There must be exactly one problem line in the
  135. data file. This line must appear before any other lines except comment
  136. lines and has the following format:
  137. \begin{verbatim}
  138. p CLASS DIR ROWS COLS NONZ
  139. \end{verbatim}
  140. The lower-case letter \verb|p| specifies that this is the problem line.
  141. The \verb|CLASS| field defines the problem class and can contain either
  142. the keyword \verb|lp| (that means linear programming problem) or
  143. \verb|mip| (that means mixed integer programming problem).
  144. The \verb|DIR| field defines the optimization direction (that is, the
  145. objective function sense) and can contain either the keyword \verb|min|
  146. (that means minimization) or \verb|max| (that means maximization).
  147. The \verb|ROWS|, \verb|COLS|, and \verb|NONZ| fields contain
  148. non-negative integer values specifying, respectively, the number of
  149. rows (constraints), columns (variables), and non-zero constraint
  150. coefficients in the problem instance. Note that \verb|NONZ| value does
  151. not account objective coefficients.
  152. \para{Row descriptors.} There must be at most one row descriptor line
  153. in the data file for each row (constraint). This line has one of the
  154. following formats:
  155. \begin{verbatim}
  156. i ROW f
  157. i ROW l RHS
  158. i ROW u RHS
  159. i ROW d RHS1 RHS2
  160. i ROW s RHS
  161. \end{verbatim}
  162. The lower-case letter \verb|i| specifies that this is the row
  163. descriptor line.
  164. The \verb|ROW| field specifies the row ordinal number, an integer
  165. between 1 and $m$, where $m$ is the number of rows in the problem
  166. instance.
  167. The next lower-case letter specifies the row type as follows:
  168. \verb|f| --- free (unbounded) row: $-\infty<\sum a_jx_j<+\infty$;
  169. \verb|l| --- inequality constraint of `$\geq$' type:
  170. $\sum a_jx_j\geq b$;
  171. \verb|u| --- inequality constraint of `$\leq$' type:
  172. $\sum a_jx_j\leq b$;
  173. \verb|d| --- double-sided inequality constraint:
  174. $b_1\leq\sum a_jx_j\leq b_2$;
  175. \verb|s| --- equality constraint: $\sum a_jx_j=b$.
  176. The \verb|RHS| field contains a floaing-point value specifying the
  177. row right-hand side. The \verb|RHS1| and \verb|RHS2| fields contain
  178. floating-point values specifying, respectively, the lower and upper
  179. right-hand sides for the double-sided row.
  180. If for some row its descriptor line does not appear in the data file,
  181. by default that row is assumed to be an equality constraint with zero
  182. right-hand side.
  183. \para{Column descriptors.} There must be at most one column descriptor
  184. line in the data file for each column (variable). This line has one of
  185. the following formats depending on the problem class specified in the
  186. problem line:
  187. \begin{tabular}{@{}l@{\hspace*{40pt}}l}
  188. LP class & MIP class \\
  189. \hline
  190. \verb|j COL f| & \verb|j COL KIND f| \\
  191. \verb|j COL l BND| & \verb|j COL KIND l BND| \\
  192. \verb|j COL u BND| & \verb|j COL KIND u BND| \\
  193. \verb|j COL d BND1 BND2| & \verb|j COL KIND d BND1 BND2| \\
  194. \verb|j COL s BND| & \verb|j COL KIND s BND| \\
  195. \end{tabular}
  196. The lower-case letter \verb|j| specifies that this is the column
  197. descriptor line.
  198. The \verb|COL| field specifies the column ordinal number, an integer
  199. between 1 and $n$, where $n$ is the number of columns in the problem
  200. instance.
  201. The \verb|KIND| field is used only for MIP problems and specifies the
  202. column kind as follows:
  203. \verb|c| --- continuous column;
  204. \verb|i| --- integer column;
  205. \verb|b| --- binary column (in this case all remaining fields must be
  206. omitted).
  207. The next lower-case letter specifies the column type as follows:
  208. \verb|f| --- free (unbounded) column: $-\infty<x<+\infty$;
  209. \verb|l| --- column with lower bound: $x\geq l$;
  210. \verb|u| --- column with upper bound: $x\leq u$;
  211. \verb|d| --- double-bounded column: $l\leq x\leq u$;
  212. \verb|s| --- fixed column: $x=s$.
  213. The \verb|BND| field contains a floating-point value that specifies the
  214. column bound. The \verb|BND1| and \verb|BND2| fields contain
  215. floating-point values specifying, respectively, the lower and upper
  216. bounds for the double-bounded column.
  217. If for some column its descriptor line does not appear in the file, by
  218. default that column is assumed to be non-negative (in case of LP class)
  219. or binary (in case of MIP class).
  220. \para{Coefficient descriptors.} There must be exactly one coefficient
  221. descriptor line in the data file for each non-zero objective or
  222. constraint coefficient. This line has the following format:
  223. \begin{verbatim}
  224. a ROW COL VAL
  225. \end{verbatim}
  226. The lower-case letter \verb|a| specifies that this is the coefficient
  227. descriptor line.
  228. For objective coefficients the \verb|ROW| field must contain 0. For
  229. constraint coefficients the \verb|ROW| field specifies the row ordinal
  230. number, an integer between 1 and $m$, where $m$ is the number of rows
  231. in the problem instance.
  232. The \verb|COL| field specifies the column ordinal number, an integer
  233. between 1 and $n$, where $n$ is the number of columns in the problem
  234. instance.
  235. If both the \verb|ROW| and \verb|COL| fields contain 0, the line
  236. specifies the constant term (``shift'') of the objective function
  237. rather than objective coefficient.
  238. The \verb|VAL| field contains a floating-point coefficient value (it is
  239. allowed to specify zero value in this field).
  240. The number of constraint coefficient descriptor lines must be exactly
  241. the same as specified in the field \verb|NONZ| of the problem line.
  242. \para{Symbolic name descriptors.} There must be at most one symbolic
  243. name descriptor line for the problem instance, objective function, each
  244. row (constraint), and each column (variable). This line has one of the
  245. following formats:
  246. \begin{verbatim}
  247. n p NAME
  248. n z NAME
  249. n i ROW NAME
  250. n j COL NAME
  251. \end{verbatim}
  252. The lower-case letter \verb|n| specifies that this is the symbolic name
  253. descriptor line.
  254. The next lower-case letter specifies which object should be assigned a
  255. symbolic name:
  256. \verb|p| --- problem instance;
  257. \verb|z| --- objective function;
  258. \verb|i| --- row (constraint);
  259. \verb|j| --- column (variable).
  260. The \verb|ROW| field specifies the row ordinal number, an integer
  261. between 1 and $m$, where $m$ is the number of rows in the problem
  262. instance.
  263. The \verb|COL| field specifies the column ordinal number, an integer
  264. between 1 and $n$, where $n$ is the number of columns in the problem
  265. instance.
  266. The \verb|NAME| field contains the symbolic name, a sequence from 1 to
  267. 255 arbitrary graphic ASCII characters, assigned to corresponding
  268. object.
  269. \para{End line.} There must be exactly one end line in the data file.
  270. This line must appear last in the file and has the following format:
  271. \begin{verbatim}
  272. e
  273. \end{verbatim}
  274. The lower-case letter \verb|e| specifies that this is the end line.
  275. Anything that follows the end line is ignored by GLPK routines.
  276. \newpage
  277. \para{Example of data file in GLPK LP/MIP format}
  278. The following example of a data file in GLPK LP/MIP format specifies
  279. the same LP problem as in Subsection ``Example of MPS file''.
  280. \bigskip
  281. \begin{center}
  282. \footnotesize\tt
  283. \begin{tabular}{l@{\hspace*{50pt}}}
  284. p lp min 8 7 48 \\
  285. n p PLAN \\
  286. n z VALUE \\
  287. i 1 f \\
  288. n i 1 VALUE \\
  289. i 2 s 2000 \\
  290. n i 2 YIELD \\
  291. i 3 u 60 \\
  292. n i 3 FE \\
  293. i 4 u 100 \\
  294. n i 4 CU \\
  295. i 5 u 40 \\
  296. n i 5 MN \\
  297. i 6 u 30 \\
  298. n i 6 MG \\
  299. i 7 l 1500 \\
  300. n i 7 AL \\
  301. i 8 d 250 300 \\
  302. n i 8 SI \\
  303. j 1 d 0 200 \\
  304. n j 1 BIN1 \\
  305. j 2 d 0 2500 \\
  306. n j 2 BIN2 \\
  307. j 3 d 400 800 \\
  308. n j 3 BIN3 \\
  309. j 4 d 100 700 \\
  310. n j 4 BIN4 \\
  311. j 5 d 0 1500 \\
  312. n j 5 BIN5 \\
  313. n j 6 ALUM \\
  314. n j 7 SILICON \\
  315. a 0 1 0.03 \\
  316. a 0 2 0.08 \\
  317. a 0 3 0.17 \\
  318. a 0 4 0.12 \\
  319. a 0 5 0.15 \\
  320. a 0 6 0.21 \\
  321. a 0 7 0.38 \\
  322. a 1 1 0.03 \\
  323. a 1 2 0.08 \\
  324. a 1 3 0.17 \\
  325. a 1 4 0.12 \\
  326. a 1 5 0.15 \\
  327. a 1 6 0.21 \\
  328. \end{tabular}
  329. \begin{tabular}{|@{\hspace*{80pt}}l}
  330. a 1 7 0.38 \\
  331. a 2 1 1 \\
  332. a 2 2 1 \\
  333. a 2 3 1 \\
  334. a 2 4 1 \\
  335. a 2 5 1 \\
  336. a 2 6 1 \\
  337. a 2 7 1 \\
  338. a 3 1 0.15 \\
  339. a 3 2 0.04 \\
  340. a 3 3 0.02 \\
  341. a 3 4 0.04 \\
  342. a 3 5 0.02 \\
  343. a 3 6 0.01 \\
  344. a 3 7 0.03 \\
  345. a 4 1 0.03 \\
  346. a 4 2 0.05 \\
  347. a 4 3 0.08 \\
  348. a 4 4 0.02 \\
  349. a 4 5 0.06 \\
  350. a 4 6 0.01 \\
  351. a 5 1 0.02 \\
  352. a 5 2 0.04 \\
  353. a 5 3 0.01 \\
  354. a 5 4 0.02 \\
  355. a 5 5 0.02 \\
  356. a 6 1 0.02 \\
  357. a 6 2 0.03 \\
  358. a 6 5 0.01 \\
  359. a 7 1 0.7 \\
  360. a 7 2 0.75 \\
  361. a 7 3 0.8 \\
  362. a 7 4 0.75 \\
  363. a 7 5 0.8 \\
  364. a 7 6 0.97 \\
  365. a 8 1 0.02 \\
  366. a 8 2 0.06 \\
  367. a 8 3 0.08 \\
  368. a 8 4 0.12 \\
  369. a 8 5 0.02 \\
  370. a 8 6 0.01 \\
  371. a 8 7 0.97 \\
  372. e o f \\
  373. \\
  374. \end{tabular}
  375. \end{center}
  376. \newpage
  377. \subsection{glp\_write\_prob --- write problem data in GLPK format}
  378. \synopsis
  379. \begin{verbatim}
  380. int glp_write_prob(glp_prob *P, int flags, const char *fname);
  381. \end{verbatim}
  382. \description
  383. The routine \verb|glp_write_prob| writes problem data in the GLPK
  384. LP/MIP format to a text file. (For description of the GLPK LP/MIP
  385. format see Subsection ``Read problem data in GLPK format''.)
  386. The parameter \verb|flags| is reserved for use in the future and should
  387. be specified as zero.
  388. The character string \verb|fname| specifies a name of the text file to
  389. be written out. (If the file name ends with suffix `\verb|.gz|', the
  390. file is assumed to be compressed, in which case the routine
  391. \verb|glp_write_prob| performs automatic compression on writing it.)
  392. \returns
  393. If the operation was successful, the routine \verb|glp_read_prob|
  394. returns zero. Otherwise, it prints an error message and returns
  395. non-zero.
  396. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  397. \newpage
  398. \section{Routines for processing MathProg models}
  399. \subsection{Introduction}
  400. GLPK supports the {\it GNU MathProg modeling language}.\footnote{The
  401. GNU MathProg modeling language is a subset of the AMPL language. For
  402. its detailed description see the document ``Modeling Language GNU
  403. MathProg: Language Reference'' included in the GLPK distribution.}
  404. As a rule, models written in MathProg are solved with the GLPK LP/MIP
  405. stand-alone solver \verb|glpsol| (see Appendix D) and do not need any
  406. programming with API routines. However, for various reasons the user
  407. may need to process MathProg models directly in his/her application
  408. program, in which case he/she may use API routines described in this
  409. section. These routines provide an interface to the {\it MathProg
  410. translator}, a component of GLPK, which translates MathProg models into
  411. an internal code and then interprets (executes) this code.
  412. The processing of a model written in GNU MathProg includes several
  413. steps, which should be performed in the following order:
  414. \vspace*{-8pt}
  415. \begin{enumerate}
  416. \item{\it Allocating the workspace.}
  417. The translator allocates the workspace, an internal data structure used
  418. on all subsequent steps.
  419. \item{\it Reading model section.} The translator reads model section
  420. and, optionally, data section from a specified text file and translates
  421. them into the internal code. If necessary, on this step data section
  422. may be ignored.
  423. \item{\it Reading data section(s).} The translator reads one or more
  424. data sections from specified text file(s) and translates them into the
  425. internal code.
  426. \item{\it Generating the model.} The translator executes the internal
  427. code to evaluate the content of the model objects such as sets,
  428. parameters, variables, constraints, and objectives. On this step the
  429. execution is suspended at the solve statement.
  430. \item {\it Building the problem object.} The translator obtains all
  431. necessary information from the workspace and builds the standard
  432. problem object (that is, the program object of type \verb|glp_prob|).
  433. \item{\it Solving the problem.} On this step the problem object built
  434. on the previous step is passed to a solver, which solves the problem
  435. instance and stores its solution back to the problem object.
  436. \item{\it Postsolving the model.} The translator copies the solution
  437. from the problem object to the workspace and then executes the internal
  438. code from the solve statement to the end of the model. (If model has
  439. no solve statement, the translator does nothing on this step.)
  440. \item{\it Freeing the workspace.} The translator frees all the memory
  441. allocated to the workspace.
  442. \end{enumerate}
  443. \vspace*{-8pt}
  444. Note that the MathProg translator performs no error correction, so if
  445. any of steps 2 to 7 fails (due to errors in the model), the application
  446. program should terminate processing and go to\linebreak step 8.
  447. \newpage
  448. \para{Example 1}
  449. In this example the program reads model and data sections from input
  450. file \verb|egypt.mod|\footnote{This is an example model included in
  451. the GLPK distribution.} and writes the model to output file
  452. \verb|egypt.mps| in free MPS format (see Appendix B). No solution is
  453. performed.
  454. \bigskip
  455. \begin{small}
  456. \begin{verbatim}
  457. /* mplsamp1.c */
  458. #include <stdio.h>
  459. #include <stdlib.h>
  460. #include <glpk.h>
  461. int main(void)
  462. { glp_prob *lp;
  463. glp_tran *tran;
  464. int ret;
  465. lp = glp_create_prob();
  466. tran = glp_mpl_alloc_wksp();
  467. ret = glp_mpl_read_model(tran, "egypt.mod", 0);
  468. if (ret != 0)
  469. { fprintf(stderr, "Error on translating model\n");
  470. goto skip;
  471. }
  472. ret = glp_mpl_generate(tran, NULL);
  473. if (ret != 0)
  474. { fprintf(stderr, "Error on generating model\n");
  475. goto skip;
  476. }
  477. glp_mpl_build_prob(tran, lp);
  478. ret = glp_write_mps(lp, GLP_MPS_FILE, NULL, "egypt.mps");
  479. if (ret != 0)
  480. fprintf(stderr, "Error on writing MPS file\n");
  481. skip: glp_mpl_free_wksp(tran);
  482. glp_delete_prob(lp);
  483. return 0;
  484. }
  485. /* eof */
  486. \end{verbatim}
  487. \end{small}
  488. \newpage
  489. \subsubsection*{Example 2}
  490. In this example the program reads model section from file
  491. \verb|sudoku.mod|\footnote{This is an example model which is included
  492. in the GLPK distribution along with alternative data file
  493. {\tt sudoku.dat}.} ignoring data section in this file, reads alternative
  494. data section from file \verb|sudoku.dat|, solves the problem instance
  495. and passes the solution found back to the model.
  496. \bigskip
  497. \begin{small}
  498. \begin{verbatim}
  499. /* mplsamp2.c */
  500. #include <stdio.h>
  501. #include <stdlib.h>
  502. #include <glpk.h>
  503. int main(void)
  504. { glp_prob *mip;
  505. glp_tran *tran;
  506. int ret;
  507. mip = glp_create_prob();
  508. tran = glp_mpl_alloc_wksp();
  509. ret = glp_mpl_read_model(tran, "sudoku.mod", 1);
  510. if (ret != 0)
  511. { fprintf(stderr, "Error on translating model\n");
  512. goto skip;
  513. }
  514. ret = glp_mpl_read_data(tran, "sudoku.dat");
  515. if (ret != 0)
  516. { fprintf(stderr, "Error on translating data\n");
  517. goto skip;
  518. }
  519. ret = glp_mpl_generate(tran, NULL);
  520. if (ret != 0)
  521. { fprintf(stderr, "Error on generating model\n");
  522. goto skip;
  523. }
  524. glp_mpl_build_prob(tran, mip);
  525. glp_simplex(mip, NULL);
  526. glp_intopt(mip, NULL);
  527. ret = glp_mpl_postsolve(tran, mip, GLP_MIP);
  528. if (ret != 0)
  529. fprintf(stderr, "Error on postsolving model\n");
  530. skip: glp_mpl_free_wksp(tran);
  531. glp_delete_prob(mip);
  532. return 0;
  533. }
  534. /* eof */
  535. \end{verbatim}
  536. \end{small}
  537. \newpage
  538. \subsection{glp\_mpl\_alloc\_wksp --- allocate the translator
  539. workspace}
  540. \synopsis
  541. \begin{verbatim}
  542. glp_tran *glp_mpl_alloc_wksp(void);
  543. \end{verbatim}
  544. \description
  545. The routine \verb|glp_mpl_alloc_wksp| allocates the MathProg translator
  546. work\-space. (Note that multiple instances of the workspace may be
  547. allocated, if necessary.)
  548. \returns
  549. The routine returns a pointer to the workspace, which should be used in
  550. all subsequent operations.
  551. \subsection{glp\_mpl\_read\_model --- read and translate model section}
  552. \synopsis
  553. \begin{verbatim}
  554. int glp_mpl_read_model(glp_tran *tran, const char *fname, int skip);
  555. \end{verbatim}
  556. \description
  557. The routine \verb|glp_mpl_read_model| reads model section and,
  558. optionally, data section, which may follow the model section, from a
  559. text file, whose name is the character string \verb|fname|, performs
  560. translation of model statements and data blocks, and stores all the
  561. information in the workspace.
  562. The parameter \verb|skip| is a flag. If the input file contains the
  563. data section and this flag is non-zero, the data section is not read as
  564. if there were no data section and a warning message is printed. This
  565. allows reading data section(s) from other file(s).
  566. \returns
  567. If the operation is successful, the routine returns zero. Otherwise
  568. the routine prints an error message and returns non-zero.
  569. \subsection{glp\_mpl\_read\_data --- read and translate data section}
  570. \synopsis
  571. \begin{verbatim}
  572. int glp_mpl_read_data(glp_tran *tran, const char *fname);
  573. \end{verbatim}
  574. \description
  575. The routine \verb|glp_mpl_read_data| reads data section from a text
  576. file, whose name is the character string \verb|fname|, performs
  577. translation of data blocks, and stores the data read in the translator
  578. workspace. If necessary, this routine may be called more than once.
  579. \returns
  580. If the operation is successful, the routine returns zero. Otherwise
  581. the routine prints an error message and returns non-zero.
  582. \newpage
  583. \subsection{glp\_mpl\_generate --- generate the model}
  584. \synopsis
  585. \begin{verbatim}
  586. int glp_mpl_generate(glp_tran *tran, const char *fname);
  587. \end{verbatim}
  588. \description
  589. The routine \verb|glp_mpl_generate| generates the model using its
  590. description stored in the translator workspace. This operation means
  591. generating all variables, constraints, and objectives, executing check
  592. and display statements, which precede the solve statement (if it is
  593. presented).
  594. The character string \verb|fname| specifies the name of an output text
  595. file, to which output produced by display statements should be written.
  596. If \verb|fname| is \verb|NULL|, the output is sent to the terminal.
  597. \returns
  598. If the operation is successful, the routine returns zero. Otherwise
  599. the routine prints an error message and returns non-zero.
  600. \vspace*{-6pt}
  601. \subsection{glp\_mpl\_build\_prob --- build problem instance from the
  602. model}
  603. \synopsis
  604. \begin{verbatim}
  605. void glp_mpl_build_prob(glp_tran *tran, glp_prob *P);
  606. \end{verbatim}
  607. \description
  608. The routine \verb|glp_mpl_build_prob| obtains all necessary information
  609. from the translator work\-space and stores it in the specified problem
  610. object \verb|P|. Note that before building the current content of the
  611. problem object is erased with the routine \verb|glp_erase_prob|.
  612. \vspace*{-6pt}
  613. \subsection{glp\_mpl\_postsolve --- postsolve the model}
  614. \synopsis
  615. \begin{verbatim}
  616. int glp_mpl_postsolve(glp_tran *tran, glp_prob *P, int sol);
  617. \end{verbatim}
  618. \description
  619. The routine \verb|glp_mpl_postsolve| copies the solution from the
  620. specified problem object \verb|prob| to the translator workspace and
  621. then executes all the remaining model statements, which follow the
  622. solve statement.
  623. The parameter \verb|sol| specifies which solution should be copied
  624. from the problem object to the workspace as follows:
  625. \verb|GLP_SOL| --- basic solution;
  626. \verb|GLP_IPT| --- interior-point solution;
  627. \verb|GLP_MIP| --- mixed integer solution.
  628. \returns
  629. If the operation is successful, the routine returns zero. Otherwise
  630. the routine prints an error message and returns non-zero.
  631. \subsection{glp\_mpl\_free\_wksp --- free the translator workspace}
  632. \synopsis
  633. \begin{verbatim}
  634. void glp_mpl_free_wksp(glp_tran *tran);
  635. \end{verbatim}
  636. \description
  637. The routine \verb|glp_mpl_free_wksp| frees all the memory allocated to
  638. the translator workspace. It also frees all other resources, which are
  639. still used by the translator.
  640. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  641. \newpage
  642. \section{Problem solution reading/writing routines}
  643. \subsection{glp\_print\_sol --- write basic solution in printable
  644. format}
  645. \synopsis
  646. \begin{verbatim}
  647. int glp_print_sol(glp_prob *P, const char *fname);
  648. \end{verbatim}
  649. \description
  650. The routine \verb|glp_print_sol writes| the current basic solution of
  651. an LP problem, which is specified by the pointer \verb|P|, to a text
  652. file, whose name is the character string \verb|fname|, in printable
  653. format.
  654. Information reported by the routine \verb|glp_print_sol| is intended
  655. mainly for visual analysis.
  656. \returns
  657. If no errors occurred, the routine returns zero. Otherwise the routine
  658. prints an error message and returns non-zero.
  659. \subsection{glp\_read\_sol --- read basic solution from text file}
  660. \synopsis
  661. \begin{verbatim}
  662. int glp_read_sol(glp_prob *P, const char *fname);
  663. \end{verbatim}
  664. \description
  665. The routine \verb|glp_read_sol| reads basic solution from a text file
  666. whose name is specified by the parameter \verb|fname| into the problem
  667. object.
  668. For the file format see description of the routine
  669. \verb|glp_write_sol|.
  670. \returns
  671. On success the routine returns zero, otherwise non-zero.
  672. \subsection{glp\_write\_sol --- write basic solution to text file}
  673. \synopsis
  674. \begin{verbatim}
  675. int glp_write_sol(glp_prob *P, const char *fname);
  676. \end{verbatim}
  677. \description
  678. The routine \verb|glp_write_sol| writes the current basic solution to
  679. a text file whose name is specified by the parameter \verb|fname|. This
  680. file can be read back with the routine \verb|glp_read_sol|.
  681. \returns
  682. On success the routine returns zero, otherwise non-zero.
  683. \newpage
  684. \para{File format}
  685. The file created by the routine \verb|glp_write_sol| is a plain text
  686. file, which contains the following information:
  687. \begin{verbatim}
  688. m n
  689. p_stat d_stat obj_val
  690. r_stat[1] r_prim[1] r_dual[1]
  691. . . .
  692. r_stat[m] r_prim[m] r_dual[m]
  693. c_stat[1] c_prim[1] c_dual[1]
  694. . . .
  695. c_stat[n] c_prim[n] c_dual[n]
  696. \end{verbatim}
  697. \noindent
  698. where:
  699. \noindent
  700. $m$ is the number of rows (auxiliary variables);
  701. \noindent
  702. $n$ is the number of columns (structural variables);
  703. \noindent
  704. \verb|p_stat| is the primal status of the basic solution\\
  705. (\verb|GLP_UNDEF| = 1, \verb|GLP_FEAS| = 2, \verb|GLP_INFEAS| = 3, or
  706. \verb|GLP_NOFEAS| = 4);
  707. \noindent
  708. \verb|d_stat| is the dual status of the basic solution\\
  709. (\verb|GLP_UNDEF| = 1, \verb|GLP_FEAS| = 2, \verb|GLP_INFEAS| = 3, or
  710. \verb|GLP_NOFEAS| = 4);
  711. \noindent
  712. \verb|obj_val| is the objective value;
  713. \noindent
  714. \verb|r_stat[i]|, $i=1,\dots,m$, is the status of $i$-th row\\
  715. (\verb|GLP_BS| = 1, \verb|GLP_NL| = 2, \verb|GLP_NU| = 3,
  716. \verb|GLP_NF| = 4, or \verb|GLP_NS| = 5);
  717. \noindent
  718. \verb|r_prim[i]|, $i=1,\dots,m$, is the primal value of $i$-th row;
  719. \noindent
  720. \verb|r_dual[i]|, $i=1,\dots,m$, is the dual value of $i$-th row;
  721. \noindent
  722. \verb|c_stat[j]|, $j=1,\dots,n$, is the status of $j$-th column\\
  723. (\verb|GLP_BS| = 1, \verb|GLP_NL| = 2, \verb|GLP_NU| = 3,
  724. \verb|GLP_NF| = 4, or \verb|GLP_NS| = 5);
  725. \noindent
  726. \verb|c_prim[j]|, $j=1,\dots,n$, is the primal value of $j$-th column;
  727. \noindent
  728. \verb|c_dual[j]|, $j=1,\dots,n$, is the dual value of $j$-th column.
  729. \subsection{glp\_print\_ipt --- write interior-point solution in
  730. printable format}
  731. \synopsis
  732. \begin{verbatim}
  733. int glp_print_ipt(glp_prob *P, const char *fname);
  734. \end{verbatim}
  735. \description
  736. The routine \verb|glp_print_ipt| writes the current interior point
  737. solution of an LP problem, which the parameter \verb|P| points to, to
  738. a text file, whose name is the character string \verb|fname|, in
  739. printable format.
  740. Information reported by the routine \verb|glp_print_ipt| is intended
  741. mainly for visual analysis.
  742. \newpage
  743. \returns
  744. If no errors occurred, the routine returns zero. Otherwise the routine
  745. prints an error message and returns non-zero.
  746. \subsection{glp\_read\_ipt --- read interior-point solution from text
  747. file}
  748. \synopsis
  749. \begin{verbatim}
  750. int glp_read_ipt(glp_prob *P, const char *fname);
  751. \end{verbatim}
  752. \description
  753. The routine \verb|glp_read_ipt| reads interior-point solution from
  754. a text file whose name is specified by the parameter \verb|fname| into
  755. the problem object.
  756. For the file format see description of the routine
  757. \verb|glp_write_ipt|.
  758. \returns
  759. On success the routine returns zero, otherwise non-zero.
  760. \subsection{glp\_write\_ipt --- write interior-point solution to text
  761. file}
  762. \synopsis
  763. \begin{verbatim}
  764. int glp_write_ipt(glp_prob *P, const char *fname);
  765. \end{verbatim}
  766. \description
  767. The routine \verb|glp_write_ipt| writes the current interior-point
  768. solution to a text file whose name is specified by the parameter
  769. \verb|fname|. This file can be read back with the routine
  770. \verb|glp_read_ipt|.
  771. \returns
  772. On success the routine returns zero, otherwise non-zero.
  773. \para{File format}
  774. The file created by the routine \verb|glp_write_ipt| is a plain text
  775. file, which contains the following information:
  776. \begin{verbatim}
  777. m n
  778. stat obj_val
  779. r_prim[1] r_dual[1]
  780. . . .
  781. r_prim[m] r_dual[m]
  782. c_prim[1] c_dual[1]
  783. . . .
  784. c_prim[n] c_dual[n]
  785. \end{verbatim}
  786. \noindent
  787. where:
  788. \noindent
  789. $m$ is the number of rows (auxiliary variables);
  790. \noindent
  791. $n$ is the number of columns (structural variables);
  792. \noindent
  793. \verb|stat| is the solution status (\verb|GLP_UNDEF| = 1 or
  794. \verb|GLP_OPT| = 5);
  795. \noindent
  796. \verb|obj_val| is the objective value;
  797. \noindent
  798. \verb|r_prim[i]|, $i=1,\dots,m$, is the primal value of $i$-th row;
  799. \noindent
  800. \verb|r_dual[i]|, $i=1,\dots,m$, is the dual value of $i$-th row;
  801. \noindent
  802. \verb|c_prim[j]|, $j=1,\dots,n$, is the primal value of $j$-th column;
  803. \noindent
  804. \verb|c_dual[j]|, $j=1,\dots,n$, is the dual value of $j$-th column.
  805. \subsection{glp\_print\_mip --- write MIP solution in printable format}
  806. \synopsis
  807. \begin{verbatim}
  808. int glp_print_mip(glp_prob *P, const char *fname);
  809. \end{verbatim}
  810. \description
  811. The routine \verb|glp_print_mip| writes a best known integer solution
  812. of a MIP problem, which is specified by the pointer \verb|P|, to
  813. a text file, whose name is the character string \verb|fname|, in
  814. printable format.
  815. Information reported by the routine \verb|glp_print_mip| is intended
  816. mainly for visual analysis.
  817. \returns
  818. If no errors occurred, the routine returns zero. Otherwise the routine
  819. prints an error message and returns non-zero.
  820. \subsection{glp\_read\_mip --- read MIP solution from text file}
  821. \synopsis
  822. \begin{verbatim}
  823. int glp_read_mip(glp_prob *P, const char *fname);
  824. \end{verbatim}
  825. \description
  826. The routine \verb|glp_read_mip| reads MIP solution from a text file
  827. whose name is specified by the parameter \verb|fname| into the problem
  828. object.
  829. For the file format see description of the routine
  830. \verb|glp_write_mip|.
  831. \returns
  832. On success the routine returns zero, otherwise non-zero.
  833. \newpage
  834. \subsection{glp\_write\_mip --- write MIP solution to text file}
  835. \synopsis
  836. \begin{verbatim}
  837. int glp_write_mip(glp_prob *P, const char *fname);
  838. \end{verbatim}
  839. \description
  840. The routine \verb|glp_write_mip| writes the current MIP solution to
  841. a text file whose name is specified by the parameter \verb|fname|. This
  842. file can be read back with the routine \verb|glp_read_mip|.
  843. \returns
  844. On success the routine returns zero, otherwise non-zero.
  845. \para{File format}
  846. The file created by the routine \verb|glp_write_sol| is a plain text
  847. file, which contains the following information:
  848. \begin{verbatim}
  849. m n
  850. stat obj_val
  851. r_val[1]
  852. . . .
  853. r_val[m]
  854. c_val[1]
  855. . . .
  856. c_val[n]
  857. \end{verbatim}
  858. \noindent
  859. where:
  860. \noindent
  861. $m$ is the number of rows (auxiliary variables);
  862. \noindent
  863. $n$ is the number of columns (structural variables);
  864. \noindent
  865. \verb|stat| is the solution status\\(\verb|GLP_UNDEF| = 1,
  866. \verb|GLP_FEAS| = 2, \verb|GLP_NOFEAS| = 4, or \verb|GLP_OPT| = 5);
  867. \noindent
  868. \verb|obj_val| is the objective value;
  869. \noindent
  870. \verb|r_val[i]|, $i=1,\dots,m$, is the value of $i$-th row;
  871. \noindent
  872. \verb|c_val[j]|, $j=1,\dots,n$, is the value of $j$-th column.
  873. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  874. \newpage
  875. \section{Post-optimal analysis routines}
  876. \subsection{glp\_print\_ranges --- print sensitivity analysis report}
  877. \synopsis
  878. {\tt int glp\_print\_ranges(glp\_prob *P, int len, const int list[],
  879. int flags,\\
  880. \hspace*{134pt}const char *fname);}
  881. \description
  882. The routine \verb|glp_print_ranges| performs sensitivity analysis of
  883. current optimal basic solution and writes the analysis report in
  884. human-readable format to a text file, whose name is the character
  885. string {\it fname}. (Detailed description of the report structure is
  886. given below.)
  887. The parameter {\it len} specifies the length of the row/column list.
  888. The array {\it list} specifies ordinal number of rows and columns to be
  889. analyzed. The ordinal numbers should be passed in locations
  890. {\it list}[1], {\it list}[2], \dots, {\it list}[{\it len}]. Ordinal
  891. numbers from 1 to $m$ refer to rows, and ordinal numbers from $m+1$ to
  892. $m+n$ refer to columns, where $m$ and $n$ are, resp., the total number
  893. of rows and columns in the problem object. Rows and columns appear in
  894. the analysis report in the same order as they follow in the array list.
  895. It is allowed to specify $len=0$, in which case the array {\it list} is
  896. not used (so it can be specified as \verb|NULL|), and the routine
  897. performs analysis for all rows and columns of the problem object.
  898. The parameter {\it flags} is reserved for use in the future and must be
  899. specified as zero.
  900. On entry to the routine \verb|glp_print_ranges| the current basic
  901. solution must be optimal and the basis factorization must exist.
  902. The application program can check that with the routine
  903. \verb|glp_bf_exists|, and if the factorization does
  904. not exist, compute it with the routine \verb|glp_factorize|. Note that
  905. if the LP preprocessor is not used, on normal exit from the simplex
  906. solver routine \verb|glp_simplex| the basis factorization always exists.
  907. \returns
  908. If the operation was successful, the routine \verb|glp_print_ranges|
  909. returns zero. Otherwise, it prints an error message and returns
  910. non-zero.
  911. \para{Analysis report example}
  912. An example of the sensitivity analysis report is shown on the next two
  913. pages. This example corresponds to the example of LP problem described
  914. in Subsection ``Example of MPS file''.
  915. \para{Structure of the analysis report}
  916. For each row and column specified in the array {\it list} the routine
  917. prints two lines containing generic information and analysis
  918. information, which depends on the status of corresponding row or column.
  919. Note that analysis of a row is analysis of its auxiliary variable,
  920. which is equal to the row linear form $\sum a_jx_j$, and analysis of
  921. a column is analysis of corresponding structural variable. Therefore,
  922. formally, on performing the sensitivity analysis there is no difference
  923. between rows and columns.
  924. \newpage
  925. \begin{landscape}
  926. \begin{footnotesize}
  927. \begin{verbatim}
  928. GLPK 4.42 - SENSITIVITY ANALYSIS REPORT Page 1
  929. Problem: PLAN
  930. Objective: VALUE = 296.2166065 (MINimum)
  931. No. Row name St Activity Slack Lower bound Activity Obj coef Obj value at Limiting
  932. Marginal Upper bound range range break point variable
  933. ------ ------------ -- ------------- ------------- ------------- ------------- ------------- ------------- ------------
  934. 1 VALUE BS 296.21661 -296.21661 -Inf 299.25255 -1.00000 . MN
  935. . +Inf 296.21661 +Inf +Inf
  936. 2 YIELD NS 2000.00000 . 2000.00000 1995.06864 -Inf 296.28365 BIN3
  937. -.01360 2000.00000 2014.03479 +Inf 296.02579 CU
  938. 3 FE NU 60.00000 . -Inf 55.89016 -Inf 306.77162 BIN4
  939. -2.56823 60.00000 62.69978 2.56823 289.28294 BIN3
  940. 4 CU BS 83.96751 16.03249 -Inf 93.88467 -.30613 270.51157 MN
  941. . 100.00000 79.98213 .21474 314.24798 BIN5
  942. 5 MN NU 40.00000 . -Inf 34.42336 -Inf 299.25255 BIN4
  943. -.54440 40.00000 41.68691 .54440 295.29825 BIN3
  944. 6 MG BS 19.96029 10.03971 -Inf 24.74427 -1.79618 260.36433 BIN1
  945. . 30.00000 9.40292 .28757 301.95652 MN
  946. 7 AL NL 1500.00000 . 1500.00000 1485.78425 -.25199 292.63444 CU
  947. .25199 +Inf 1504.92126 +Inf 297.45669 BIN3
  948. 8 SI NL 250.00000 50.00000 250.00000 235.32871 -.48520 289.09812 CU
  949. .48520 300.00000 255.06073 +Inf 298.67206 BIN3
  950. \end{verbatim}
  951. \end{footnotesize}
  952. \end{landscape}
  953. \newpage
  954. \begin{landscape}
  955. \begin{footnotesize}
  956. \begin{verbatim}
  957. GLPK 4.42 - SENSITIVITY ANALYSIS REPORT Page 2
  958. Problem: PLAN
  959. Objective: VALUE = 296.2166065 (MINimum)
  960. No. Column name St Activity Obj coef Lower bound Activity Obj coef Obj value at Limiting
  961. Marginal Upper bound range range break point variable
  962. ------ ------------ -- ------------- ------------- ------------- ------------- ------------- ------------- ------------
  963. 1 BIN1 NL . .03000 . -28.82475 -.22362 288.90594 BIN4
  964. .25362 200.00000 33.88040 +Inf 304.80951 BIN4
  965. 2 BIN2 BS 665.34296 .08000 . 802.22222 .01722 254.44822 BIN1
  966. . 2500.00000 313.43066 .08863 301.95652 MN
  967. 3 BIN3 BS 490.25271 .17000 400.00000 788.61314 .15982 291.22807 MN
  968. . 800.00000 -347.42857 .17948 300.86548 BIN5
  969. 4 BIN4 BS 424.18773 .12000 100.00000 710.52632 .10899 291.54745 MN
  970. . 700.00000 -256.15524 .14651 307.46010 BIN1
  971. 5 BIN5 NL . .15000 . -201.78739 .13544 293.27940 BIN3
  972. .01456 1500.00000 58.79586 +Inf 297.07244 BIN3
  973. 6 ALUM BS 299.63899 .21000 . 358.26772 .18885 289.87879 AL
  974. . +Inf 112.40876 .22622 301.07527 MN
  975. 7 SILICON BS 120.57762 .38000 . 124.27093 .14828 268.27586 BIN5
  976. . +Inf 85.54745 .46667 306.66667 MN
  977. End of report
  978. \end{verbatim}
  979. \end{footnotesize}
  980. \end{landscape}
  981. \newpage
  982. \noindent
  983. {\it Generic information}
  984. {\tt No.} is the row or column ordinal number in the problem object.
  985. Rows are numbered from 1 to $m$, and columns are numbered from 1 to $n$,
  986. where $m$ and $n$ are, resp., the total number of rows and columns in
  987. the problem object.
  988. {\tt Row name} is the symbolic name assigned to the row. If the row has
  989. no name assigned, this field contains blanks.
  990. {\tt Column name} is the symbolic name assigned to the column. If the
  991. column has no name assigned, this field contains blanks.
  992. {\tt St} is the status of the row or column in the optimal solution:
  993. {\tt BS} --- non-active constraint (row), basic column;
  994. {\tt NL} --- inequality constraint having its lower right-hand side
  995. active (row), non-basic column having its lower bound active;
  996. {\tt NU} --- inequality constraint having its upper right-hand side
  997. active (row), non-basic column having its upper bound active;
  998. {\tt NS} --- active equality constraint (row), non-basic fixed column.
  999. {\tt NF} --- active free row, non-basic free (unbounded) column. (This
  1000. case means that the optimal solution is dual degenerate.)
  1001. {\tt Activity} is the (primal) value of the auxiliary variable (row) or
  1002. structural variable (column) in the optimal solution.
  1003. {\tt Slack} is the (primal) value of the row slack variable.
  1004. {\tt Obj coef} is the objective coefficient of the column (structural
  1005. variable).
  1006. {\tt Marginal} is the reduced cost (dual activity) of the auxiliary
  1007. variable (row) or structural variable (column).
  1008. {\tt Lower bound} is the lower right-hand side (row) or lower bound
  1009. (column). If the row or column has no lower bound, this field contains
  1010. {\tt -Inf}.
  1011. {\tt Upper bound} is the upper right-hand side (row) or upper bound
  1012. (column). If the row or column has no upper bound, this field contains
  1013. {\tt +Inf}.
  1014. \noindent
  1015. {\it Sensitivity analysis of active bounds}
  1016. The sensitivity analysis of active bounds is performed only for rows,
  1017. which are active constraints, and only for non-basic columns, because
  1018. inactive constraints and basic columns have no active bounds.
  1019. For every auxiliary (row) or structural (column) non-basic variable the
  1020. routine starts changing its active bound in both direction. The first
  1021. of the two lines in the report corresponds to decreasing, and the
  1022. second line corresponds to increasing of the active bound. Since the
  1023. variable being analyzed is non-basic, its activity, which is equal to
  1024. its active bound, also starts changing. This changing leads to changing
  1025. of basic (auxiliary and structural) variables, which depend on the
  1026. non-basic variable. The current basis remains primal feasible and
  1027. therefore optimal while values of all basic variables are primal
  1028. feasible, i.e. are within their bounds. Therefore, if some basic
  1029. variable called the {\it limiting variable} reaches its (lower or
  1030. upper) bound first, before any other basic variables, it thereby limits
  1031. further changing of the non-basic variable, because otherwise the
  1032. current basis would become primal infeasible. The point, at which this
  1033. happens, is called the {\it break point}. Note that there are two break
  1034. points: the lower break point, which corresponds to decreasing of the
  1035. non-basic variable, and the upper break point, which corresponds to
  1036. increasing of the non-basic variable.
  1037. In the analysis report values of the non-basic variable (i.e. of its
  1038. active bound) being analyzed at both lower and upper break points are
  1039. printed in the field `{\tt Activity range}'. Corresponding values of
  1040. the objective function are printed in the field `{\tt Obj value at
  1041. break point}', and symbolic names of corresponding limiting basic
  1042. variables are printed in the field `{\tt Limiting variable}'.
  1043. If the active bound can decrease or/and increase unlimitedly, the field
  1044. `{\tt Activity range}' contains {\tt -Inf} or/and {\tt +Inf}, resp.
  1045. For example (see the example report above), row SI is a double-sided
  1046. constraint, which is active on its lower bound (right-hand side), and
  1047. its activity in the optimal solution being equal to the lower bound is
  1048. 250. The activity range for this row is $[235.32871,255.06073]$. This
  1049. means that the basis remains optimal while the lower bound is
  1050. increasing up to 255.06073, and further increasing is limited by
  1051. (structural) variable BIN3. If the lower bound reaches this upper break
  1052. point, the objective value becomes equal to 298.67206.
  1053. Note that if the basis does not change, the objective function depends
  1054. on the non-basic variable linearly, and the per-unit change of the
  1055. objective function is the reduced cost (marginal value) of the
  1056. non-basic variable.
  1057. \noindent
  1058. {\it Sensitivity analysis of objective coefficients at non-basic
  1059. variables}
  1060. The sensitivity analysis of the objective coefficient at a non-basic
  1061. variable is quite simple, because in this case change in the objective
  1062. coefficient leads to equivalent change in the reduced cost (marginal
  1063. value).
  1064. For every auxiliary (row) or structural (column) non-basic variable the
  1065. routine starts changing its objective coefficient in both direction.
  1066. (Note that auxiliary variables are not included in the objective
  1067. function and therefore always have zero objective coefficients.) The
  1068. first of the two lines in the report corresponds to decreasing, and the
  1069. second line corresponds to increasing of the objective coefficient.
  1070. This changing leads to changing of the reduced cost of the non-basic
  1071. variable to be analyzed and does affect reduced costs of all other
  1072. non-basic variables. The current basis remains dual feasible and
  1073. therefore optimal while the reduced cost keeps its sign. Therefore, if
  1074. the reduced cost reaches zero, it limits further changing of the
  1075. objective coefficient (if only the non-basic variable is non-fixed).
  1076. In the analysis report minimal and maximal values of the objective
  1077. coefficient, on which the basis remains optimal, are printed in the
  1078. field `\verb|Obj coef range|'. If the objective coefficient can
  1079. decrease or/and increase unlimitedly, this field contains {\tt -Inf}
  1080. or/and {\tt +Inf}, resp.
  1081. For example (see the example report above), column BIN5 is non-basic
  1082. having its lower bound active. Its objective coefficient is 0.15, and
  1083. reduced cost in the optimal solution 0.01456. The column lower bound
  1084. remains active while the column reduced cost remains non-negative,
  1085. thus, minimal value of the objective coefficient, on which the current
  1086. basis still remains optimal, is $0.15-0.01456=0.13644$, that is
  1087. indicated in the field `\verb|Obj coef range|'.
  1088. \newpage
  1089. {\parskip=0pt
  1090. \noindent
  1091. {\it Sensitivity analysis of objective coefficients at basic variables}
  1092. \medskip
  1093. To perform sensitivity analysis for every auxiliary (row) or structural
  1094. (column) variable the routine starts changing its objective coefficient
  1095. in both direction. (Note that auxiliary variables are not included in
  1096. the objective function and therefore always have zero objective
  1097. coefficients.) The first of the two lines in the report corresponds to
  1098. decreasing, and the second line corresponds to increasing of the
  1099. objective coefficient. This changing leads to changing of reduced costs
  1100. of non-basic variables. The current basis remains dual feasible and
  1101. therefore optimal while reduced costs of all non-basic variables
  1102. (except fixed variables) keep their signs. Therefore, if the reduced
  1103. cost of some non-basic non-fixed variable called the {\it limiting
  1104. variable} reaches zero first, before reduced cost of any other
  1105. non-basic non-fixed variable, it thereby limits further changing of the
  1106. objective coefficient, because otherwise the current basis would become
  1107. dual infeasible (non-optimal). The point, at which this happens, is
  1108. called the {\it break point}. Note that there are two break points: the
  1109. lower break point, which corresponds to decreasing of the objective
  1110. coefficient, and the upper break point, which corresponds to increasing
  1111. of the objective coefficient. Let the objective coefficient reach its
  1112. limit value and continue changing a bit further in the same direction
  1113. that makes the current basis dual infeasible (non-optimal). Then the
  1114. reduced cost of the non-basic limiting variable becomes ``a bit'' dual
  1115. infeasible that forces the limiting variable to enter the basis
  1116. replacing there some basic variable, which leaves the basis to keep its
  1117. primal feasibility. It should be understood that if we change the
  1118. current basis in this way exactly at the break point, both the current
  1119. and adjacent bases will be optimal with the same objective value,
  1120. because at the break point the limiting variable has zero reduced cost.
  1121. On the other hand, in the adjacent basis the value of the limiting
  1122. variable changes, because there it becomes basic, that leads to
  1123. changing of the value of the basic variable being analyzed. Note that
  1124. on determining the adjacent basis the bounds of the analyzed basic
  1125. variable are ignored as if it were a free (unbounded) variable, so it
  1126. cannot leave the current basis.
  1127. In the analysis report lower and upper limits of the objective
  1128. coefficient at the basic variable being analyzed, when the basis
  1129. remains optimal, are printed in the field `{\tt Obj coef range}'.
  1130. Corresponding values of the objective function at both lower and upper
  1131. break points are printed in the field `{\tt Obj value at break point}',
  1132. symbolic names of corresponding non-basic limiting variables are
  1133. printed in the field `{\tt Limiting variable}', and values of the basic
  1134. variable, which it would take on in the adjacent bases (as was
  1135. explained above) are printed in the field `{\tt Activity range}'.
  1136. If the objective coefficient can increase or/and decrease unlimitedly,
  1137. the field `{\tt Obj coef range}' contains {\tt -Inf} and/or {\tt +Inf},
  1138. resp. It also may happen that no dual feasible adjacent basis exists
  1139. (i.e. on entering the basis the limiting variable can increase or
  1140. decrease unlimitedly), in which case the field `{\tt Activity range}'
  1141. contains {\tt -Inf} and/or {\tt +Inf}.
  1142. For example (see the example report above), structural variable
  1143. (column) BIN3 is basic, its optimal value is 490.25271, and its
  1144. objective coefficient is 0.17. The objective coefficient range for this
  1145. column is $[0.15982,0.17948]$. This means that the basis remains
  1146. optimal while the objective coefficient is decreasing down to 0.15982,
  1147. and further decreasing is limited by (auxiliary) variable MN. If we
  1148. make the objective coefficient a bit less than 0.15982, the limiting
  1149. variable MN will enter the basis, and in that adjacent basis the
  1150. structural variable BIN3 will take on new optimal value 788.61314. At
  1151. the lower break point, where the objective coefficient is exactly
  1152. 0.15982, the objective function takes on the value 291.22807 in both
  1153. the current and adjacent bases.
  1154. Note that if the basis does not change, the objective function depends
  1155. on the objective coefficient at the basic variable linearly, and the
  1156. per-unit change of the objective function is the value of the basic
  1157. variable.
  1158. }
  1159. %* eof *%