alpar@1: /* glplpf.h (LP basis factorization, Schur complement version) */ alpar@1: alpar@1: /*********************************************************************** alpar@1: * This code is part of GLPK (GNU Linear Programming Kit). alpar@1: * alpar@1: * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, alpar@1: * 2009, 2010 Andrew Makhorin, Department for Applied Informatics, alpar@1: * Moscow Aviation Institute, Moscow, Russia. All rights reserved. alpar@1: * E-mail: . alpar@1: * alpar@1: * GLPK is free software: you can redistribute it and/or modify it alpar@1: * under the terms of the GNU General Public License as published by alpar@1: * the Free Software Foundation, either version 3 of the License, or alpar@1: * (at your option) any later version. alpar@1: * alpar@1: * GLPK is distributed in the hope that it will be useful, but WITHOUT alpar@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY alpar@1: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public alpar@1: * License for more details. alpar@1: * alpar@1: * You should have received a copy of the GNU General Public License alpar@1: * along with GLPK. If not, see . alpar@1: ***********************************************************************/ alpar@1: alpar@1: #ifndef GLPLPF_H alpar@1: #define GLPLPF_H alpar@1: alpar@1: #include "glpscf.h" alpar@1: #include "glpluf.h" alpar@1: alpar@1: /*********************************************************************** alpar@1: * The structure LPF defines the factorization of the basis mxm matrix alpar@1: * B, where m is the number of rows in corresponding problem instance. alpar@1: * alpar@1: * This factorization is the following septet: alpar@1: * alpar@1: * [B] = (L0, U0, R, S, C, P, Q), (1) alpar@1: * alpar@1: * and is based on the following main equality: alpar@1: * alpar@1: * ( B F^) ( B0 F ) ( L0 0 ) ( U0 R ) alpar@1: * ( ) = P ( ) Q = P ( ) ( ) Q, (2) alpar@1: * ( G^ H^) ( G H ) ( S I ) ( 0 C ) alpar@1: * alpar@1: * where: alpar@1: * alpar@1: * B is the current basis matrix (not stored); alpar@1: * alpar@1: * F^, G^, H^ are some additional matrices (not stored); alpar@1: * alpar@1: * B0 is some initial basis matrix (not stored); alpar@1: * alpar@1: * F, G, H are some additional matrices (not stored); alpar@1: * alpar@1: * P, Q are permutation matrices (stored in both row- and column-like alpar@1: * formats); alpar@1: * alpar@1: * L0, U0 are some matrices that defines a factorization of the initial alpar@1: * basis matrix B0 = L0 * U0 (stored in an invertable form); alpar@1: * alpar@1: * R is a matrix defined from L0 * R = F, so R = inv(L0) * F (stored in alpar@1: * a column-wise sparse format); alpar@1: * alpar@1: * S is a matrix defined from S * U0 = G, so S = G * inv(U0) (stored in alpar@1: * a row-wise sparse format); alpar@1: * alpar@1: * C is the Schur complement for matrix (B0 F G H). It is defined from alpar@1: * S * R + C = H, so C = H - S * R = H - G * inv(U0) * inv(L0) * F = alpar@1: * = H - G * inv(B0) * F. Matrix C is stored in an invertable form. alpar@1: * alpar@1: * REFERENCES alpar@1: * alpar@1: * 1. M.A.Saunders, "LUSOL: A basis package for constrained optimiza- alpar@1: * tion," SCCM, Stanford University, 2006. alpar@1: * alpar@1: * 2. M.A.Saunders, "Notes 5: Basis Updates," CME 318, Stanford Univer- alpar@1: * sity, Spring 2006. alpar@1: * alpar@1: * 3. M.A.Saunders, "Notes 6: LUSOL---a Basis Factorization Package," alpar@1: * ibid. */ alpar@1: alpar@1: typedef struct LPF LPF; alpar@1: alpar@1: struct LPF alpar@1: { /* LP basis factorization */ alpar@1: int valid; alpar@1: /* the factorization is valid only if this flag is set */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: /* initial basis matrix B0 */ alpar@1: int m0_max; alpar@1: /* maximal value of m0 (increased automatically, if necessary) */ alpar@1: int m0; alpar@1: /* the order of B0 */ alpar@1: LUF *luf; alpar@1: /* LU-factorization of B0 */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: /* current basis matrix B */ alpar@1: int m; alpar@1: /* the order of B */ alpar@1: double *B; /* double B[1+m*m]; */ alpar@1: /* B in dense format stored by rows and used only for debugging; alpar@1: normally this array is not allocated */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: /* augmented matrix (B0 F G H) of the order m0+n */ alpar@1: int n_max; alpar@1: /* maximal number of additional rows and columns */ alpar@1: int n; alpar@1: /* current number of additional rows and columns */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: /* m0xn matrix R in column-wise format */ alpar@1: int *R_ptr; /* int R_ptr[1+n_max]; */ alpar@1: /* R_ptr[j], 1 <= j <= n, is a pointer to j-th column */ alpar@1: int *R_len; /* int R_len[1+n_max]; */ alpar@1: /* R_len[j], 1 <= j <= n, is the length of j-th column */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: /* nxm0 matrix S in row-wise format */ alpar@1: int *S_ptr; /* int S_ptr[1+n_max]; */ alpar@1: /* S_ptr[i], 1 <= i <= n, is a pointer to i-th row */ alpar@1: int *S_len; /* int S_len[1+n_max]; */ alpar@1: /* S_len[i], 1 <= i <= n, is the length of i-th row */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: /* Schur complement C of the order n */ alpar@1: SCF *scf; /* SCF scf[1:n_max]; */ alpar@1: /* factorization of the Schur complement */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: /* matrix P of the order m0+n */ alpar@1: int *P_row; /* int P_row[1+m0_max+n_max]; */ alpar@1: /* P_row[i] = j means that P[i,j] = 1 */ alpar@1: int *P_col; /* int P_col[1+m0_max+n_max]; */ alpar@1: /* P_col[j] = i means that P[i,j] = 1 */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: /* matrix Q of the order m0+n */ alpar@1: int *Q_row; /* int Q_row[1+m0_max+n_max]; */ alpar@1: /* Q_row[i] = j means that Q[i,j] = 1 */ alpar@1: int *Q_col; /* int Q_col[1+m0_max+n_max]; */ alpar@1: /* Q_col[j] = i means that Q[i,j] = 1 */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: /* Sparse Vector Area (SVA) is a set of locations intended to alpar@1: store sparse vectors which represent columns of matrix R and alpar@1: rows of matrix S; each location is a doublet (ind, val), where alpar@1: ind is an index, val is a numerical value of a sparse vector alpar@1: element; in the whole each sparse vector is a set of adjacent alpar@1: locations defined by a pointer to its first element and its alpar@1: length, i.e. the number of its elements */ alpar@1: int v_size; alpar@1: /* the SVA size, in locations; locations are numbered by integers alpar@1: 1, 2, ..., v_size, and location 0 is not used */ alpar@1: int v_ptr; alpar@1: /* pointer to the first available location */ alpar@1: int *v_ind; /* int v_ind[1+v_size]; */ alpar@1: /* v_ind[k], 1 <= k <= v_size, is the index field of location k */ alpar@1: double *v_val; /* double v_val[1+v_size]; */ alpar@1: /* v_val[k], 1 <= k <= v_size, is the value field of location k */ alpar@1: /*--------------------------------------------------------------*/ alpar@1: double *work1; /* double work1[1+m0+n_max]; */ alpar@1: /* working array */ alpar@1: double *work2; /* double work2[1+m0+n_max]; */ alpar@1: /* working array */ alpar@1: }; alpar@1: alpar@1: /* return codes: */ alpar@1: #define LPF_ESING 1 /* singular matrix */ alpar@1: #define LPF_ECOND 2 /* ill-conditioned matrix */ alpar@1: #define LPF_ELIMIT 3 /* update limit reached */ alpar@1: alpar@1: #define lpf_create_it _glp_lpf_create_it alpar@1: LPF *lpf_create_it(void); alpar@1: /* create LP basis factorization */ alpar@1: alpar@1: #define lpf_factorize _glp_lpf_factorize alpar@1: int lpf_factorize(LPF *lpf, int m, const int bh[], int (*col) alpar@1: (void *info, int j, int ind[], double val[]), void *info); alpar@1: /* compute LP basis factorization */ alpar@1: alpar@1: #define lpf_ftran _glp_lpf_ftran alpar@1: void lpf_ftran(LPF *lpf, double x[]); alpar@1: /* perform forward transformation (solve system B*x = b) */ alpar@1: alpar@1: #define lpf_btran _glp_lpf_btran alpar@1: void lpf_btran(LPF *lpf, double x[]); alpar@1: /* perform backward transformation (solve system B'*x = b) */ alpar@1: alpar@1: #define lpf_update_it _glp_lpf_update_it alpar@1: int lpf_update_it(LPF *lpf, int j, int bh, int len, const int ind[], alpar@1: const double val[]); alpar@1: /* update LP basis factorization */ alpar@1: alpar@1: #define lpf_delete_it _glp_lpf_delete_it alpar@1: void lpf_delete_it(LPF *lpf); alpar@1: /* delete LP basis factorization */ alpar@1: alpar@1: #endif alpar@1: alpar@1: /* eof */