/farmR/src/glplpf.h

https://code.google.com/p/javawfm/ · C Header · 193 lines · 49 code · 15 blank · 129 comment · 0 complexity · 7108efb94ff6f7b025f1e30a85ee53b7 MD5 · raw file

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