PageRenderTime 23ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

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