lemon-project-template-glpk
diff deps/glpk/src/glplpf.h @ 9:33de93886c88
Import GLPK 4.47
author | Alpar Juttner <alpar@cs.elte.hu> |
---|---|
date | Sun, 06 Nov 2011 20:59:10 +0100 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/deps/glpk/src/glplpf.h Sun Nov 06 20:59:10 2011 +0100 1.3 @@ -0,0 +1,194 @@ 1.4 +/* glplpf.h (LP basis factorization, Schur complement version) */ 1.5 + 1.6 +/*********************************************************************** 1.7 +* This code is part of GLPK (GNU Linear Programming Kit). 1.8 +* 1.9 +* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 1.10 +* 2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics, 1.11 +* Moscow Aviation Institute, Moscow, Russia. All rights reserved. 1.12 +* E-mail: <mao@gnu.org>. 1.13 +* 1.14 +* GLPK is free software: you can redistribute it and/or modify it 1.15 +* under the terms of the GNU General Public License as published by 1.16 +* the Free Software Foundation, either version 3 of the License, or 1.17 +* (at your option) any later version. 1.18 +* 1.19 +* GLPK is distributed in the hope that it will be useful, but WITHOUT 1.20 +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 1.21 +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 1.22 +* License for more details. 1.23 +* 1.24 +* You should have received a copy of the GNU General Public License 1.25 +* along with GLPK. If not, see <http://www.gnu.org/licenses/>. 1.26 +***********************************************************************/ 1.27 + 1.28 +#ifndef GLPLPF_H 1.29 +#define GLPLPF_H 1.30 + 1.31 +#include "glpscf.h" 1.32 +#include "glpluf.h" 1.33 + 1.34 +/*********************************************************************** 1.35 +* The structure LPF defines the factorization of the basis mxm matrix 1.36 +* B, where m is the number of rows in corresponding problem instance. 1.37 +* 1.38 +* This factorization is the following septet: 1.39 +* 1.40 +* [B] = (L0, U0, R, S, C, P, Q), (1) 1.41 +* 1.42 +* and is based on the following main equality: 1.43 +* 1.44 +* ( B F^) ( B0 F ) ( L0 0 ) ( U0 R ) 1.45 +* ( ) = P ( ) Q = P ( ) ( ) Q, (2) 1.46 +* ( G^ H^) ( G H ) ( S I ) ( 0 C ) 1.47 +* 1.48 +* where: 1.49 +* 1.50 +* B is the current basis matrix (not stored); 1.51 +* 1.52 +* F^, G^, H^ are some additional matrices (not stored); 1.53 +* 1.54 +* B0 is some initial basis matrix (not stored); 1.55 +* 1.56 +* F, G, H are some additional matrices (not stored); 1.57 +* 1.58 +* P, Q are permutation matrices (stored in both row- and column-like 1.59 +* formats); 1.60 +* 1.61 +* L0, U0 are some matrices that defines a factorization of the initial 1.62 +* basis matrix B0 = L0 * U0 (stored in an invertable form); 1.63 +* 1.64 +* R is a matrix defined from L0 * R = F, so R = inv(L0) * F (stored in 1.65 +* a column-wise sparse format); 1.66 +* 1.67 +* S is a matrix defined from S * U0 = G, so S = G * inv(U0) (stored in 1.68 +* a row-wise sparse format); 1.69 +* 1.70 +* C is the Schur complement for matrix (B0 F G H). It is defined from 1.71 +* S * R + C = H, so C = H - S * R = H - G * inv(U0) * inv(L0) * F = 1.72 +* = H - G * inv(B0) * F. Matrix C is stored in an invertable form. 1.73 +* 1.74 +* REFERENCES 1.75 +* 1.76 +* 1. M.A.Saunders, "LUSOL: A basis package for constrained optimiza- 1.77 +* tion," SCCM, Stanford University, 2006. 1.78 +* 1.79 +* 2. M.A.Saunders, "Notes 5: Basis Updates," CME 318, Stanford Univer- 1.80 +* sity, Spring 2006. 1.81 +* 1.82 +* 3. M.A.Saunders, "Notes 6: LUSOL---a Basis Factorization Package," 1.83 +* ibid. */ 1.84 + 1.85 +typedef struct LPF LPF; 1.86 + 1.87 +struct LPF 1.88 +{ /* LP basis factorization */ 1.89 + int valid; 1.90 + /* the factorization is valid only if this flag is set */ 1.91 + /*--------------------------------------------------------------*/ 1.92 + /* initial basis matrix B0 */ 1.93 + int m0_max; 1.94 + /* maximal value of m0 (increased automatically, if necessary) */ 1.95 + int m0; 1.96 + /* the order of B0 */ 1.97 + LUF *luf; 1.98 + /* LU-factorization of B0 */ 1.99 + /*--------------------------------------------------------------*/ 1.100 + /* current basis matrix B */ 1.101 + int m; 1.102 + /* the order of B */ 1.103 + double *B; /* double B[1+m*m]; */ 1.104 + /* B in dense format stored by rows and used only for debugging; 1.105 + normally this array is not allocated */ 1.106 + /*--------------------------------------------------------------*/ 1.107 + /* augmented matrix (B0 F G H) of the order m0+n */ 1.108 + int n_max; 1.109 + /* maximal number of additional rows and columns */ 1.110 + int n; 1.111 + /* current number of additional rows and columns */ 1.112 + /*--------------------------------------------------------------*/ 1.113 + /* m0xn matrix R in column-wise format */ 1.114 + int *R_ptr; /* int R_ptr[1+n_max]; */ 1.115 + /* R_ptr[j], 1 <= j <= n, is a pointer to j-th column */ 1.116 + int *R_len; /* int R_len[1+n_max]; */ 1.117 + /* R_len[j], 1 <= j <= n, is the length of j-th column */ 1.118 + /*--------------------------------------------------------------*/ 1.119 + /* nxm0 matrix S in row-wise format */ 1.120 + int *S_ptr; /* int S_ptr[1+n_max]; */ 1.121 + /* S_ptr[i], 1 <= i <= n, is a pointer to i-th row */ 1.122 + int *S_len; /* int S_len[1+n_max]; */ 1.123 + /* S_len[i], 1 <= i <= n, is the length of i-th row */ 1.124 + /*--------------------------------------------------------------*/ 1.125 + /* Schur complement C of the order n */ 1.126 + SCF *scf; /* SCF scf[1:n_max]; */ 1.127 + /* factorization of the Schur complement */ 1.128 + /*--------------------------------------------------------------*/ 1.129 + /* matrix P of the order m0+n */ 1.130 + int *P_row; /* int P_row[1+m0_max+n_max]; */ 1.131 + /* P_row[i] = j means that P[i,j] = 1 */ 1.132 + int *P_col; /* int P_col[1+m0_max+n_max]; */ 1.133 + /* P_col[j] = i means that P[i,j] = 1 */ 1.134 + /*--------------------------------------------------------------*/ 1.135 + /* matrix Q of the order m0+n */ 1.136 + int *Q_row; /* int Q_row[1+m0_max+n_max]; */ 1.137 + /* Q_row[i] = j means that Q[i,j] = 1 */ 1.138 + int *Q_col; /* int Q_col[1+m0_max+n_max]; */ 1.139 + /* Q_col[j] = i means that Q[i,j] = 1 */ 1.140 + /*--------------------------------------------------------------*/ 1.141 + /* Sparse Vector Area (SVA) is a set of locations intended to 1.142 + store sparse vectors which represent columns of matrix R and 1.143 + rows of matrix S; each location is a doublet (ind, val), where 1.144 + ind is an index, val is a numerical value of a sparse vector 1.145 + element; in the whole each sparse vector is a set of adjacent 1.146 + locations defined by a pointer to its first element and its 1.147 + length, i.e. the number of its elements */ 1.148 + int v_size; 1.149 + /* the SVA size, in locations; locations are numbered by integers 1.150 + 1, 2, ..., v_size, and location 0 is not used */ 1.151 + int v_ptr; 1.152 + /* pointer to the first available location */ 1.153 + int *v_ind; /* int v_ind[1+v_size]; */ 1.154 + /* v_ind[k], 1 <= k <= v_size, is the index field of location k */ 1.155 + double *v_val; /* double v_val[1+v_size]; */ 1.156 + /* v_val[k], 1 <= k <= v_size, is the value field of location k */ 1.157 + /*--------------------------------------------------------------*/ 1.158 + double *work1; /* double work1[1+m0+n_max]; */ 1.159 + /* working array */ 1.160 + double *work2; /* double work2[1+m0+n_max]; */ 1.161 + /* working array */ 1.162 +}; 1.163 + 1.164 +/* return codes: */ 1.165 +#define LPF_ESING 1 /* singular matrix */ 1.166 +#define LPF_ECOND 2 /* ill-conditioned matrix */ 1.167 +#define LPF_ELIMIT 3 /* update limit reached */ 1.168 + 1.169 +#define lpf_create_it _glp_lpf_create_it 1.170 +LPF *lpf_create_it(void); 1.171 +/* create LP basis factorization */ 1.172 + 1.173 +#define lpf_factorize _glp_lpf_factorize 1.174 +int lpf_factorize(LPF *lpf, int m, const int bh[], int (*col) 1.175 + (void *info, int j, int ind[], double val[]), void *info); 1.176 +/* compute LP basis factorization */ 1.177 + 1.178 +#define lpf_ftran _glp_lpf_ftran 1.179 +void lpf_ftran(LPF *lpf, double x[]); 1.180 +/* perform forward transformation (solve system B*x = b) */ 1.181 + 1.182 +#define lpf_btran _glp_lpf_btran 1.183 +void lpf_btran(LPF *lpf, double x[]); 1.184 +/* perform backward transformation (solve system B'*x = b) */ 1.185 + 1.186 +#define lpf_update_it _glp_lpf_update_it 1.187 +int lpf_update_it(LPF *lpf, int j, int bh, int len, const int ind[], 1.188 + const double val[]); 1.189 +/* update LP basis factorization */ 1.190 + 1.191 +#define lpf_delete_it _glp_lpf_delete_it 1.192 +void lpf_delete_it(LPF *lpf); 1.193 +/* delete LP basis factorization */ 1.194 + 1.195 +#endif 1.196 + 1.197 +/* eof */