glpscf.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* glpscf.h (Schur complement factorization) */
  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 GLPSCF_H
  24. #define GLPSCF_H
  25. /***********************************************************************
  26. * The structure SCF defines the following factorization of a square
  27. * nxn matrix C (which is the Schur complement):
  28. *
  29. * F * C = U * P,
  30. *
  31. * where F is a square transforming matrix, U is an upper triangular
  32. * matrix, P is a permutation matrix.
  33. *
  34. * It is assumed that matrix C is small and dense, so matrices F and U
  35. * are stored in the dense format by rows as follows:
  36. *
  37. * 1 n n_max 1 n n_max
  38. * 1 * * * * * * x x x x 1 * * * * * * x x x x
  39. * * * * * * * x x x x . * * * * * x x x x
  40. * * * * * * * x x x x . . * * * * x x x x
  41. * * * * * * * x x x x . . . * * * x x x x
  42. * * * * * * * x x x x . . . . * * x x x x
  43. * n * * * * * * x x x x n . . . . . * x x x x
  44. * x x x x x x x x x x . . . . . . x x x x
  45. * x x x x x x x x x x . . . . . . . x x x
  46. * x x x x x x x x x x . . . . . . . . x x
  47. * n_max x x x x x x x x x x n_max . . . . . . . . . x
  48. *
  49. * matrix F matrix U
  50. *
  51. * where '*' are matrix elements, 'x' are reserved locations.
  52. *
  53. * Permutation matrix P is stored in row-like format.
  54. *
  55. * Matrix C normally is not stored.
  56. *
  57. * REFERENCES
  58. *
  59. * 1. M.A.Saunders, "LUSOL: A basis package for constrained optimiza-
  60. * tion," SCCM, Stanford University, 2006.
  61. *
  62. * 2. M.A.Saunders, "Notes 5: Basis Updates," CME 318, Stanford Univer-
  63. * sity, Spring 2006.
  64. *
  65. * 3. M.A.Saunders, "Notes 6: LUSOL---a Basis Factorization Package,"
  66. * ibid. */
  67. typedef struct SCF SCF;
  68. struct SCF
  69. { /* Schur complement factorization */
  70. int n_max;
  71. /* maximal order of matrices C, F, U, P; n_max >= 1 */
  72. int n;
  73. /* current order of matrices C, F, U, P; n >= 0 */
  74. double *f; /* double f[1+n_max*n_max]; */
  75. /* matrix F stored by rows */
  76. double *u; /* double u[1+n_max*(n_max+1)/2]; */
  77. /* upper triangle of matrix U stored by rows */
  78. int *p; /* int p[1+n_max]; */
  79. /* matrix P; p[i] = j means that P[i,j] = 1 */
  80. int t_opt;
  81. /* type of transformation used to restore triangular structure of
  82. matrix U: */
  83. #define SCF_TBG 1 /* Bartels-Golub elimination */
  84. #define SCF_TGR 2 /* Givens plane rotation */
  85. int rank;
  86. /* estimated rank of matrices C and U */
  87. double *c; /* double c[1+n_max*n_max]; */
  88. /* matrix C stored in the same format as matrix F and used only
  89. for debugging; normally this array is not allocated */
  90. double *w; /* double w[1+n_max]; */
  91. /* working array */
  92. };
  93. /* return codes: */
  94. #define SCF_ESING 1 /* singular matrix */
  95. #define SCF_ELIMIT 2 /* update limit reached */
  96. #define scf_create_it _glp_scf_create_it
  97. SCF *scf_create_it(int n_max);
  98. /* create Schur complement factorization */
  99. #define scf_update_exp _glp_scf_update_exp
  100. int scf_update_exp(SCF *scf, const double x[], const double y[],
  101. double z);
  102. /* update factorization on expanding C */
  103. #define scf_solve_it _glp_scf_solve_it
  104. void scf_solve_it(SCF *scf, int tr, double x[]);
  105. /* solve either system C * x = b or C' * x = b */
  106. #define scf_reset_it _glp_scf_reset_it
  107. void scf_reset_it(SCF *scf);
  108. /* reset factorization for empty matrix C */
  109. #define scf_delete_it _glp_scf_delete_it
  110. void scf_delete_it(SCF *scf);
  111. /* delete Schur complement factorization */
  112. #endif
  113. /* eof */