1 /* glpapi.h (application program interface) */
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
6 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
7 * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
8 * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
9 * E-mail: <mao@gnu.org>.
11 * GLPK is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * GLPK is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 * License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
23 ***********************************************************************/
28 #define GLP_PROB_DEFINED
29 typedef struct glp_prob glp_prob;
35 typedef struct GLPROW GLPROW;
36 typedef struct GLPCOL GLPCOL;
37 typedef struct GLPAIJ GLPAIJ;
39 #define GLP_PROB_MAGIC 0xD7D9D6C2
42 { /* LP/MIP problem object */
44 /* magic value used for debugging */
46 /* memory pool to store problem object components */
48 /* pointer to the search tree; set by the MIP solver when this
49 object is used in the tree as a core MIP object */
51 /* reserved for backward compatibility */
52 /*--------------------------------------------------------------*/
55 /* problem name (1 to 255 chars); NULL means no name is assigned
58 /* objective function name (1 to 255 chars); NULL means no name
59 is assigned to the objective function */
61 /* optimization direction flag (objective "sense"):
62 GLP_MIN - minimization
63 GLP_MAX - maximization */
65 /* constant term of the objective function ("shift") */
67 /* length of the array of rows (enlarged automatically) */
69 /* length of the array of columns (enlarged automatically) */
71 /* number of rows, 0 <= m <= m_max */
73 /* number of columns, 0 <= n <= n_max */
75 /* number of non-zero constraint coefficients, nnz >= 0 */
76 GLPROW **row; /* GLPROW *row[1+m_max]; */
77 /* row[i], 1 <= i <= m, is a pointer to i-th row */
78 GLPCOL **col; /* GLPCOL *col[1+n_max]; */
79 /* col[j], 1 <= j <= n, is a pointer to j-th column */
81 /* row index to find rows by their names; NULL means this index
84 /* column index to find columns by their names; NULL means this
85 index does not exist */
86 /*--------------------------------------------------------------*/
87 /* basis factorization (LP) */
89 /* the factorization is valid only if this flag is set */
90 int *head; /* int head[1+m_max]; */
91 /* basis header (valid only if the factorization is valid);
92 head[i] = k is the ordinal number of auxiliary (1 <= k <= m)
93 or structural (m+1 <= k <= m+n) variable which corresponds to
94 i-th basic variable xB[i], 1 <= i <= m */
96 /* basis factorization control parameters; may be NULL */
97 BFD *bfd; /* BFD bfd[1:m,1:m]; */
98 /* basis factorization driver; may be NULL */
99 /*--------------------------------------------------------------*/
100 /* basic solution (LP) */
102 /* primal basic solution status:
103 GLP_UNDEF - primal solution is undefined
104 GLP_FEAS - primal solution is feasible
105 GLP_INFEAS - primal solution is infeasible
106 GLP_NOFEAS - no primal feasible solution exists */
108 /* dual basic solution status:
109 GLP_UNDEF - dual solution is undefined
110 GLP_FEAS - dual solution is feasible
111 GLP_INFEAS - dual solution is infeasible
112 GLP_NOFEAS - no dual feasible solution exists */
114 /* objective function value */
116 /* simplex method iteration count; increased by one on performing
117 one simplex iteration */
119 /* ordinal number of some auxiliary or structural variable having
120 certain property, 0 <= some <= m+n */
121 /*--------------------------------------------------------------*/
122 /* interior-point solution (LP) */
124 /* interior-point solution status:
125 GLP_UNDEF - interior solution is undefined
126 GLP_OPT - interior solution is optimal
127 GLP_INFEAS - interior solution is infeasible
128 GLP_NOFEAS - no feasible solution exists */
130 /* objective function value */
131 /*--------------------------------------------------------------*/
132 /* integer solution (MIP) */
134 /* integer solution status:
135 GLP_UNDEF - integer solution is undefined
136 GLP_OPT - integer solution is optimal
137 GLP_FEAS - integer solution is feasible
138 GLP_NOFEAS - no integer solution exists */
140 /* objective function value */
144 { /* LP/MIP row (auxiliary variable) */
146 /* ordinal number (1 to m) assigned to this row */
148 /* row name (1 to 255 chars); NULL means no name is assigned to
151 /* pointer to corresponding node in the row index; NULL means
152 that either the row index does not exist or this row has no
154 #if 1 /* 20/IX-2008 */
156 unsigned char origin;
160 /* type of the auxiliary variable:
161 GLP_FR - free variable
162 GLP_LO - variable with lower bound
163 GLP_UP - variable with upper bound
164 GLP_DB - double-bounded variable
165 GLP_FX - fixed variable */
166 double lb; /* non-scaled */
167 /* lower bound; if the row has no lower bound, lb is zero */
168 double ub; /* non-scaled */
169 /* upper bound; if the row has no upper bound, ub is zero */
170 /* if the row type is GLP_FX, ub is equal to lb */
171 GLPAIJ *ptr; /* non-scaled */
172 /* pointer to doubly linked list of constraint coefficients which
173 are placed in this row */
175 /* diagonal element r[i,i] of scaling matrix R for this row;
176 if the scaling is not used, r[i,i] is 1 */
178 /* status of the auxiliary variable:
179 GLP_BS - basic variable
180 GLP_NL - non-basic variable on lower bound
181 GLP_NU - non-basic variable on upper bound
182 GLP_NF - non-basic free variable
183 GLP_NS - non-basic fixed variable */
185 /* if the auxiliary variable is basic, head[bind] refers to this
186 row, otherwise, bind is 0; this attribute is valid only if the
187 basis factorization is valid */
188 double prim; /* non-scaled */
189 /* primal value of the auxiliary variable in basic solution */
190 double dual; /* non-scaled */
191 /* dual value of the auxiliary variable in basic solution */
192 double pval; /* non-scaled */
193 /* primal value of the auxiliary variable in interior solution */
194 double dval; /* non-scaled */
195 /* dual value of the auxiliary variable in interior solution */
196 double mipx; /* non-scaled */
197 /* primal value of the auxiliary variable in integer solution */
201 { /* LP/MIP column (structural variable) */
203 /* ordinal number (1 to n) assigned to this column */
205 /* column name (1 to 255 chars); NULL means no name is assigned
208 /* pointer to corresponding node in the column index; NULL means
209 that either the column index does not exist or the column has
212 /* kind of the structural variable:
213 GLP_CV - continuous variable
214 GLP_IV - integer or binary variable */
216 /* type of the structural variable:
217 GLP_FR - free variable
218 GLP_LO - variable with lower bound
219 GLP_UP - variable with upper bound
220 GLP_DB - double-bounded variable
221 GLP_FX - fixed variable */
222 double lb; /* non-scaled */
223 /* lower bound; if the column has no lower bound, lb is zero */
224 double ub; /* non-scaled */
225 /* upper bound; if the column has no upper bound, ub is zero */
226 /* if the column type is GLP_FX, ub is equal to lb */
227 double coef; /* non-scaled */
228 /* objective coefficient at the structural variable */
229 GLPAIJ *ptr; /* non-scaled */
230 /* pointer to doubly linked list of constraint coefficients which
231 are placed in this column */
233 /* diagonal element s[j,j] of scaling matrix S for this column;
234 if the scaling is not used, s[j,j] is 1 */
236 /* status of the structural variable:
237 GLP_BS - basic variable
238 GLP_NL - non-basic variable on lower bound
239 GLP_NU - non-basic variable on upper bound
240 GLP_NF - non-basic free variable
241 GLP_NS - non-basic fixed variable */
243 /* if the structural variable is basic, head[bind] refers to
244 this column; otherwise, bind is 0; this attribute is valid only
245 if the basis factorization is valid */
246 double prim; /* non-scaled */
247 /* primal value of the structural variable in basic solution */
248 double dual; /* non-scaled */
249 /* dual value of the structural variable in basic solution */
250 double pval; /* non-scaled */
251 /* primal value of the structural variable in interior solution */
252 double dval; /* non-scaled */
253 /* dual value of the structural variable in interior solution */
254 double mipx; /* non-scaled */
255 /* primal value of the structural variable in integer solution */
259 { /* constraint coefficient a[i,j] */
261 /* pointer to row, where this coefficient is placed */
263 /* pointer to column, where this coefficient is placed */
265 /* numeric (non-zero) value of this coefficient */
267 /* pointer to previous coefficient in the same row */
269 /* pointer to next coefficient in the same row */
271 /* pointer to previous coefficient in the same column */
273 /* pointer to next coefficient in the same column */
276 void _glp_check_kkt(glp_prob *P, int sol, int cond, double *ae_max,
277 int *ae_ind, double *re_max, int *re_ind);
278 /* check feasibility and optimality conditions */
280 #define lpx_put_solution _glp_put_solution
281 void lpx_put_solution(glp_prob *lp, int inval, const int *p_stat,
282 const int *d_stat, const double *obj_val, const int r_stat[],
283 const double r_prim[], const double r_dual[], const int c_stat[],
284 const double c_prim[], const double c_dual[]);
285 /* store basic solution components */
287 #define lpx_put_mip_soln _glp_put_mip_soln
288 void lpx_put_mip_soln(LPX *lp, int i_stat, double row_mipx[],
290 /* store mixed integer solution components */
292 #if 1 /* 28/XI-2009 */
293 int _glp_analyze_row(glp_prob *P, int len, const int ind[],
294 const double val[], int type, double rhs, double eps, int *_piv,
295 double *_x, double *_dx, double *_y, double *_dy, double *_dz);
296 /* simulate one iteration of dual simplex method */
299 #if 1 /* 08/XII-2009 */
300 void _glp_mpl_init_rand(glp_tran *tran, int seed);
303 #define glp_skpgen _glp_skpgen
304 void glp_skpgen(int n, int r, int type, int v, int s, int a[],
306 /* Pisinger's 0-1 single knapsack problem generator */
308 #if 1 /* 28/V-2010 */
309 int _glp_intopt1(glp_prob *P, const glp_iocp *parm);