lemon-project-template-glpk

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