glpfhv.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* glpfhv.h (LP basis factorization, FHV eta file 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 Andrew Makhorin, Department for Applied Informatics,
  7. * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  8. * 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 GLPFHV_H
  24. #define GLPFHV_H
  25. #include "glpluf.h"
  26. /***********************************************************************
  27. * The structure FHV 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 sextet:
  31. *
  32. * [B] = (F, H, V, P0, P, Q), (1)
  33. *
  34. * where F, H, and V are such matrices that
  35. *
  36. * B = F * H * V, (2)
  37. *
  38. * and P0, P, and Q are such permutation matrices that the matrix
  39. *
  40. * L = P0 * F * inv(P0) (3)
  41. *
  42. * is lower triangular with unity diagonal, and the matrix
  43. *
  44. * U = P * V * Q (4)
  45. *
  46. * is upper triangular. All the matrices have the same order m, which
  47. * is the order of the basis matrix B.
  48. *
  49. * The matrices F, V, P, and Q are stored in the structure LUF (see the
  50. * module GLPLUF), which is a member of the structure FHV.
  51. *
  52. * The matrix H is stored in the form of eta file using row-like format
  53. * as follows:
  54. *
  55. * H = H[1] * H[2] * ... * H[nfs], (5)
  56. *
  57. * where H[k], k = 1, 2, ..., nfs, is a row-like factor, which differs
  58. * from the unity matrix only by one row, nfs is current number of row-
  59. * like factors. After the factorization has been built for some given
  60. * basis matrix B the matrix H has no factors and thus it is the unity
  61. * matrix. Then each time when the factorization is recomputed for an
  62. * adjacent basis matrix, the next factor H[k], k = 1, 2, ... is built
  63. * and added to the end of the eta file H.
  64. *
  65. * Being sparse vectors non-trivial rows of the factors H[k] are stored
  66. * in the right part of the sparse vector area (SVA) in the same manner
  67. * as rows and columns of the matrix F.
  68. *
  69. * For more details see the program documentation. */
  70. typedef struct FHV FHV;
  71. struct FHV
  72. { /* LP basis factorization */
  73. int m_max;
  74. /* maximal value of m (increased automatically, if necessary) */
  75. int m;
  76. /* the order of matrices B, F, H, V, P0, P, Q */
  77. int valid;
  78. /* the factorization is valid only if this flag is set */
  79. LUF *luf;
  80. /* LU-factorization (contains the matrices F, V, P, Q) */
  81. /*--------------------------------------------------------------*/
  82. /* matrix H in the form of eta file */
  83. int hh_max;
  84. /* maximal number of row-like factors (which limits the number of
  85. updates of the factorization) */
  86. int hh_nfs;
  87. /* current number of row-like factors (0 <= hh_nfs <= hh_max) */
  88. int *hh_ind; /* int hh_ind[1+hh_max]; */
  89. /* hh_ind[k], k = 1, ..., nfs, is the number of a non-trivial row
  90. of factor H[k] */
  91. int *hh_ptr; /* int hh_ptr[1+hh_max]; */
  92. /* hh_ptr[k], k = 1, ..., nfs, is a pointer to the first element
  93. of the non-trivial row of factor H[k] in the SVA */
  94. int *hh_len; /* int hh_len[1+hh_max]; */
  95. /* hh_len[k], k = 1, ..., nfs, is the number of non-zero elements
  96. in the non-trivial row of factor H[k] */
  97. /*--------------------------------------------------------------*/
  98. /* matrix P0 */
  99. int *p0_row; /* int p0_row[1+m_max]; */
  100. /* p0_row[i] = j means that p0[i,j] = 1 */
  101. int *p0_col; /* int p0_col[1+m_max]; */
  102. /* p0_col[j] = i means that p0[i,j] = 1 */
  103. /* if i-th row or column of the matrix F corresponds to i'-th row
  104. or column of the matrix L = P0*F*inv(P0), then p0_row[i'] = i
  105. and p0_col[i] = i' */
  106. /*--------------------------------------------------------------*/
  107. /* working arrays */
  108. int *cc_ind; /* int cc_ind[1+m_max]; */
  109. /* integer working array */
  110. double *cc_val; /* double cc_val[1+m_max]; */
  111. /* floating-point working array */
  112. /*--------------------------------------------------------------*/
  113. /* control parameters */
  114. double upd_tol;
  115. /* update tolerance; if after updating the factorization absolute
  116. value of some diagonal element u[k,k] of matrix U = P*V*Q is
  117. less than upd_tol * max(|u[k,*]|, |u[*,k]|), the factorization
  118. is considered as inaccurate */
  119. /*--------------------------------------------------------------*/
  120. /* some statistics */
  121. int nnz_h;
  122. /* current number of non-zeros in all factors of matrix H */
  123. };
  124. /* return codes: */
  125. #define FHV_ESING 1 /* singular matrix */
  126. #define FHV_ECOND 2 /* ill-conditioned matrix */
  127. #define FHV_ECHECK 3 /* insufficient accuracy */
  128. #define FHV_ELIMIT 4 /* update limit reached */
  129. #define FHV_EROOM 5 /* SVA overflow */
  130. #define fhv_create_it _glp_fhv_create_it
  131. FHV *fhv_create_it(void);
  132. /* create LP basis factorization */
  133. #define fhv_factorize _glp_fhv_factorize
  134. int fhv_factorize(FHV *fhv, int m, int (*col)(void *info, int j,
  135. int ind[], double val[]), void *info);
  136. /* compute LP basis factorization */
  137. #define fhv_h_solve _glp_fhv_h_solve
  138. void fhv_h_solve(FHV *fhv, int tr, double x[]);
  139. /* solve system H*x = b or H'*x = b */
  140. #define fhv_ftran _glp_fhv_ftran
  141. void fhv_ftran(FHV *fhv, double x[]);
  142. /* perform forward transformation (solve system B*x = b) */
  143. #define fhv_btran _glp_fhv_btran
  144. void fhv_btran(FHV *fhv, double x[]);
  145. /* perform backward transformation (solve system B'*x = b) */
  146. #define fhv_update_it _glp_fhv_update_it
  147. int fhv_update_it(FHV *fhv, int j, int len, const int ind[],
  148. const double val[]);
  149. /* update LP basis factorization */
  150. #define fhv_delete_it _glp_fhv_delete_it
  151. void fhv_delete_it(FHV *fhv);
  152. /* delete LP basis factorization */
  153. #endif
  154. /* eof */