00001 /* glpinv.h */ 00002 00003 /*---------------------------------------------------------------------- 00004 -- Copyright (C) 2000, 2001, 2002, 2003 Andrew Makhorin, Department 00005 -- for Applied Informatics, Moscow Aviation Institute, Moscow, Russia. 00006 -- All rights reserved. E-mail: <mao@mai2.rcnet.ru>. 00007 -- 00008 -- This file is a part of GLPK (GNU Linear Programming Kit). 00009 -- 00010 -- GLPK is free software; you can redistribute it and/or modify it 00011 -- under the terms of the GNU General Public License as published by 00012 -- the Free Software Foundation; either version 2, or (at your option) 00013 -- any later version. 00014 -- 00015 -- GLPK is distributed in the hope that it will be useful, but WITHOUT 00016 -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00017 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 00018 -- License for more details. 00019 -- 00020 -- You should have received a copy of the GNU General Public License 00021 -- along with GLPK; see the file COPYING. If not, write to the Free 00022 -- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00023 -- 02111-1307, USA. 00024 ----------------------------------------------------------------------*/ 00025 00026 /* 00027 @(#)glpinv.h 1.3 06/22/04 00028 svn/cvs: $Id: glpinv.h 71 2006-06-09 04:21:15Z andreasw $ 00029 */ 00030 00031 00032 #ifndef _GLPINV_H 00033 #define _GLPINV_H 00034 00035 #include "glpluf.h" 00036 00037 #define inv_create glp_inv_create 00038 #define inv_decomp glp_inv_decomp 00039 #define inv_h_solve glp_inv_h_solve 00040 #define inv_ftran glp_inv_ftran 00041 #define inv_btran glp_inv_btran 00042 #define inv_update glp_inv_update 00043 #define inv_delete glp_inv_delete 00044 00045 /*---------------------------------------------------------------------- 00046 -- The structure INV defines an invertable form of the basis matrix B, 00047 -- which is based on LU-factorization and is the following sextet: 00048 -- 00049 -- [B] = (F, H, V, P0, P, Q), (1) 00050 -- 00051 -- where F, H, and V are such matrices that 00052 -- 00053 -- B = F * H * V, (2) 00054 -- 00055 -- and P0, P, and Q are such permutation matrices that the matrix 00056 -- 00057 -- L = P0 * F * inv(P0) (3) 00058 -- 00059 -- is lower triangular with unity diagonal, and the matrix 00060 -- 00061 -- U = P * V * Q (4) 00062 -- 00063 -- is upper triangular. All the matrices have the same order m, which 00064 -- is the order of the basis matrix B. 00065 -- 00066 -- The matrices F, V, P, and Q are stored in the structure LUF (see the 00067 -- section GLPLUF), which is a member of the structure INV. 00068 -- 00069 -- The matrix H is stored in the form of eta file using row-like format 00070 -- as follows: 00071 -- 00072 -- H = H[1] * H[2] * ... * H[nfs], (5) 00073 -- 00074 -- where H[k], k = 1, 2, ..., nfs, is a row-like factor, which differs 00075 -- from the unity matrix only by one row, nfs is current number of row- 00076 -- like factors. After the factorization has been built for some given 00077 -- basis matrix B the matrix H has no factors and thus it is the unity 00078 -- matrix. Then each time when the factorization is recomputed for an 00079 -- adjacent basis matrix, the next factor H[k], k = 1, 2, ... is built 00080 -- and added to the end of the eta file H. 00081 -- 00082 -- Being sparse vectors non-trivial rows of the factors H[k] are stored 00083 -- in the right part of the sparse vector area (SVA) in the same manner 00084 -- as rows and columns of the matrix F. 00085 -- 00086 -- For more details see the program documentation. */ 00087 00088 typedef struct INV INV; 00089 00090 struct INV 00091 { /* invertable (factorized) form of the basis matrix */ 00092 int m; 00093 /* order of the matrices B, F, H, V, P0, P, Q */ 00094 int valid; 00095 /* if this flag is not set, the invertable form is invalid and 00096 can't be updated nor used in ftran and btran operations */ 00097 LUF *luf; 00098 /* LU-factorization (holds the matrices F, V, P, Q) */ 00099 /*--------------------------------------------------------------*/ 00100 /* matrix H in the form of eta file */ 00101 int hh_max; 00102 /* maximal number of row-like factors (that limits maximal number 00103 of updates of the factorization) */ 00104 int hh_nfs; 00105 /* current number of row-like factors (0 <= hh_nfs <= hh_max) */ 00106 int *hh_ndx; /* int hh_ndx[1+hh_max]; */ 00107 /* hh_ndx[0] is not used; 00108 hh_ndx[k], k = 1, ..., nfs, is number of a non-trivial row of 00109 the factor H[k] */ 00110 int *hh_ptr; /* int hh_ptr[1+hh_max]; */ 00111 /* hh_ptr[0] is not used; 00112 hh_ptr[k], k = 1, ..., nfs, is a pointer to the first element 00113 of the non-trivial row of the factor H[k] in the sparse vector 00114 area */ 00115 int *hh_len; /* int hh_len[1+hh_max]; */ 00116 /* hh_len[0] is not used; 00117 hh_len[k], k = 1, ..., nfs, is total number of elements in the 00118 non-trivial row of the factor H[k] */ 00119 /*--------------------------------------------------------------*/ 00120 /* matrix P0 */ 00121 int *p0_row; /* int p0_row[1+n]; */ 00122 /* p0_row[0] is not used; p0_row[i] = j means that p0[i,j] = 1 */ 00123 int *p0_col; /* int p0_col[1+n]; */ 00124 /* p0_col[0] is not used; p0_col[j] = i means that p0[i,j] = 1 */ 00125 /* if i-th row or column of the matrix F corresponds to i'-th row 00126 or column of the matrix L = P0*F*inv(P0), then p0_row[i'] = i 00127 and p0_col[i] = i' */ 00128 /*--------------------------------------------------------------*/ 00129 /* partially transformed column is inv(F*H)*B[j], where B[j] is a 00130 new column, which will replace the existing j-th column of the 00131 basis matrix */ 00132 int cc_len; 00133 /* number of (non-zero) elements in the partially transformed 00134 column; if cc_len < 0, the column has been not prepared yet */ 00135 int *cc_ndx; /* int cc_ndx[1+m]; */ 00136 /* cc_ndx[0] is not used; 00137 cc_ndx[k], k = 1, ..., cc_len, is a row index of the partially 00138 transformed column element */ 00139 double *cc_val; /* double cc_val[1+m]; */ 00140 /* cc_val[0] is not used; 00141 cc_val[k], k = 1, ..., cc_len, is a numerical (non-zero) value 00142 of the column element */ 00143 /*--------------------------------------------------------------*/ 00144 /* control parameters */ 00145 double upd_tol; 00146 #if 0 00147 /* update tolerance; if on updating the factorization absolute 00148 value of some diagonal element of the matrix U = P*V*Q is less 00149 than upd_tol, the factorization is considered as inaccurate */ 00150 #else 00151 /* update tolerance; if after the factorization has been updated 00152 absolute value of some diagonal element u[k,k] of the matrix 00153 U = P*V*Q is less than upd_tol * max(|u[k,*]|, |u[*,k]|), the 00154 factorization is considered as inaccurate */ 00155 #endif 00156 /*--------------------------------------------------------------*/ 00157 /* some statistics */ 00158 int nnz_h; 00159 /* current number of non-zeros in all factors of the matrix H */ 00160 double min_vrratio ; 00161 /* minimum value of u[k,k]/(upd_tol)*max(|u[k,*]|, |u[*,k]|) since 00162 last pivot. */ 00163 }; 00164 00165 INV *inv_create(int m, int max_upd); 00166 /* create factorization of the basis matrix */ 00167 00168 int inv_decomp(INV *inv, 00169 void *info, int (*col)(void *info, int j, int rn[], double bj[])); 00170 /* compute factorization of the basis matrix */ 00171 00172 void inv_h_solve(INV *inv, int tr, double x[]); 00173 /* solve system H*x = b or H'*x = b */ 00174 00175 void inv_ftran(INV *inv, double x[], int save); 00176 /* perform forward transformation (FTRAN) */ 00177 00178 void inv_btran(INV *inv, double x[]); 00179 /* perform backward transformation (BTRAN) */ 00180 00181 int inv_update(INV *inv, int j); 00182 /* update factorization for adjacent basis matrix */ 00183 00184 void inv_delete(INV *inv); 00185 /* delete factorization of the basis matrix */ 00186 00187 #endif 00188 00189 /* eof */