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.

216 lines
8.1 KiB

  1. /* glplpf.h (LP basis factorization, Schur complement version) */
  2. /***********************************************************************
  3. * This code is part of GLPK (GNU Linear Programming Kit).
  4. *
  5. * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  6. * 2009, 2010, 2011, 2013 Andrew Makhorin, Department for Applied
  7. * Informatics, Moscow Aviation Institute, Moscow, Russia. All rights
  8. * reserved. E-mail: <mao@gnu.org>.
  9. *
  10. * GLPK is free software: you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * GLPK is distributed in the hope that it will be useful, but WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  18. * License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  22. ***********************************************************************/
  23. #ifndef GLPLPF_H
  24. #define GLPLPF_H
  25. #if 0 /* 11/VIII-2013 */
  26. #include "glpscf.h"
  27. #else
  28. #include "ifu.h"
  29. #endif
  30. #if 0 /* 06/VI-2013 */
  31. #include "glpluf.h"
  32. #else
  33. #include "lufint.h"
  34. #endif
  35. /***********************************************************************
  36. * The structure LPF defines the factorization of the basis mxm matrix
  37. * B, where m is the number of rows in corresponding problem instance.
  38. *
  39. * This factorization is the following septet:
  40. *
  41. * [B] = (L0, U0, R, S, C, P, Q), (1)
  42. *
  43. * and is based on the following main equality:
  44. *
  45. * ( B F^) ( B0 F ) ( L0 0 ) ( U0 R )
  46. * ( ) = P ( ) Q = P ( ) ( ) Q, (2)
  47. * ( G^ H^) ( G H ) ( S I ) ( 0 C )
  48. *
  49. * where:
  50. *
  51. * B is the current basis matrix (not stored);
  52. *
  53. * F^, G^, H^ are some additional matrices (not stored);
  54. *
  55. * B0 is some initial basis matrix (not stored);
  56. *
  57. * F, G, H are some additional matrices (not stored);
  58. *
  59. * P, Q are permutation matrices (stored in both row- and column-like
  60. * formats);
  61. *
  62. * L0, U0 are some matrices that defines a factorization of the initial
  63. * basis matrix B0 = L0 * U0 (stored in an invertable form);
  64. *
  65. * R is a matrix defined from L0 * R = F, so R = inv(L0) * F (stored in
  66. * a column-wise sparse format);
  67. *
  68. * S is a matrix defined from S * U0 = G, so S = G * inv(U0) (stored in
  69. * a row-wise sparse format);
  70. *
  71. * C is the Schur complement for matrix (B0 F G H). It is defined from
  72. * S * R + C = H, so C = H - S * R = H - G * inv(U0) * inv(L0) * F =
  73. * = H - G * inv(B0) * F. Matrix C is stored in an invertable form.
  74. *
  75. * REFERENCES
  76. *
  77. * 1. M.A.Saunders, "LUSOL: A basis package for constrained optimiza-
  78. * tion," SCCM, Stanford University, 2006.
  79. *
  80. * 2. M.A.Saunders, "Notes 5: Basis Updates," CME 318, Stanford Univer-
  81. * sity, Spring 2006.
  82. *
  83. * 3. M.A.Saunders, "Notes 6: LUSOL---a Basis Factorization Package,"
  84. * ibid. */
  85. typedef struct LPF LPF;
  86. struct LPF
  87. { /* LP basis factorization */
  88. int valid;
  89. /* the factorization is valid only if this flag is set */
  90. /*--------------------------------------------------------------*/
  91. /* initial basis matrix B0 */
  92. int m0_max;
  93. /* maximal value of m0 (increased automatically, if necessary) */
  94. int m0;
  95. /* the order of B0 */
  96. #if 0 /* 06/VI-2013 */
  97. LUF *luf;
  98. #else
  99. LUFINT *lufint;
  100. #endif
  101. /* LU-factorization of B0 */
  102. /*--------------------------------------------------------------*/
  103. /* current basis matrix B */
  104. int m;
  105. /* the order of B */
  106. double *B; /* double B[1+m*m]; */
  107. /* B in dense format stored by rows and used only for debugging;
  108. normally this array is not allocated */
  109. /*--------------------------------------------------------------*/
  110. /* augmented matrix (B0 F G H) of the order m0+n */
  111. int n_max;
  112. /* maximal number of additional rows and columns */
  113. int n;
  114. /* current number of additional rows and columns */
  115. /*--------------------------------------------------------------*/
  116. /* m0xn matrix R in column-wise format */
  117. int *R_ptr; /* int R_ptr[1+n_max]; */
  118. /* R_ptr[j], 1 <= j <= n, is a pointer to j-th column */
  119. int *R_len; /* int R_len[1+n_max]; */
  120. /* R_len[j], 1 <= j <= n, is the length of j-th column */
  121. /*--------------------------------------------------------------*/
  122. /* nxm0 matrix S in row-wise format */
  123. int *S_ptr; /* int S_ptr[1+n_max]; */
  124. /* S_ptr[i], 1 <= i <= n, is a pointer to i-th row */
  125. int *S_len; /* int S_len[1+n_max]; */
  126. /* S_len[i], 1 <= i <= n, is the length of i-th row */
  127. /*--------------------------------------------------------------*/
  128. /* Schur complement C of the order n */
  129. #if 0 /* 11/VIII-2013 */
  130. SCF *scf; /* SCF scf[1:n_max]; */
  131. /* factorization of the Schur complement */
  132. #else
  133. IFU ifu;
  134. /* IFU-factorization of the Schur complement */
  135. int t_opt;
  136. /* type of transformation used to restore triangular structure of
  137. matrix U: */
  138. #define SCF_TBG 1 /* Bartels-Golub elimination */
  139. #define SCF_TGR 2 /* Givens plane rotations */
  140. #endif
  141. /*--------------------------------------------------------------*/
  142. /* matrix P of the order m0+n */
  143. int *P_row; /* int P_row[1+m0_max+n_max]; */
  144. /* P_row[i] = j means that P[i,j] = 1 */
  145. int *P_col; /* int P_col[1+m0_max+n_max]; */
  146. /* P_col[j] = i means that P[i,j] = 1 */
  147. /*--------------------------------------------------------------*/
  148. /* matrix Q of the order m0+n */
  149. int *Q_row; /* int Q_row[1+m0_max+n_max]; */
  150. /* Q_row[i] = j means that Q[i,j] = 1 */
  151. int *Q_col; /* int Q_col[1+m0_max+n_max]; */
  152. /* Q_col[j] = i means that Q[i,j] = 1 */
  153. /*--------------------------------------------------------------*/
  154. /* Sparse Vector Area (SVA) is a set of locations intended to
  155. store sparse vectors which represent columns of matrix R and
  156. rows of matrix S; each location is a doublet (ind, val), where
  157. ind is an index, val is a numerical value of a sparse vector
  158. element; in the whole each sparse vector is a set of adjacent
  159. locations defined by a pointer to its first element and its
  160. length, i.e. the number of its elements */
  161. int v_size;
  162. /* the SVA size, in locations; locations are numbered by integers
  163. 1, 2, ..., v_size, and location 0 is not used */
  164. int v_ptr;
  165. /* pointer to the first available location */
  166. int *v_ind; /* int v_ind[1+v_size]; */
  167. /* v_ind[k], 1 <= k <= v_size, is the index field of location k */
  168. double *v_val; /* double v_val[1+v_size]; */
  169. /* v_val[k], 1 <= k <= v_size, is the value field of location k */
  170. /*--------------------------------------------------------------*/
  171. double *work1; /* double work1[1+m0+n_max]; */
  172. /* working array */
  173. double *work2; /* double work2[1+m0+n_max]; */
  174. /* working array */
  175. };
  176. /* return codes: */
  177. #define LPF_ESING 1 /* singular matrix */
  178. #define LPF_ECOND 2 /* ill-conditioned matrix */
  179. #define LPF_ELIMIT 3 /* update limit reached */
  180. #define lpf_create_it _glp_lpf_create_it
  181. LPF *lpf_create_it(void);
  182. /* create LP basis factorization */
  183. #define lpf_factorize _glp_lpf_factorize
  184. int lpf_factorize(LPF *lpf, int m, const int bh[], int (*col)
  185. (void *info, int j, int ind[], double val[]), void *info);
  186. /* compute LP basis factorization */
  187. #define lpf_ftran _glp_lpf_ftran
  188. void lpf_ftran(LPF *lpf, double x[]);
  189. /* perform forward transformation (solve system B*x = b) */
  190. #define lpf_btran _glp_lpf_btran
  191. void lpf_btran(LPF *lpf, double x[]);
  192. /* perform backward transformation (solve system B'*x = b) */
  193. #define lpf_update_it _glp_lpf_update_it
  194. int lpf_update_it(LPF *lpf, int j, int bh, int len, const int ind[],
  195. const double val[]);
  196. /* update LP basis factorization */
  197. #define lpf_delete_it _glp_lpf_delete_it
  198. void lpf_delete_it(LPF *lpf);
  199. /* delete LP basis factorization */
  200. #endif
  201. /* eof */