Debian Codegraph @

external/glpk/glpapi11.c

raw symbols SCIP
1 /* glpapi11.c (utility routines) */cxx . . $ `<file>/external/glpk/glpapi11.c`/
2
3 /***********************************************************************
4 * This code is part of GLPK (GNU Linear Programming Kit).
5 *
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: <[email protected]>.
10 *
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.
15 *
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.
20 *
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 ***********************************************************************/
24
25 #include "glpapi.h"cxx . . $ `<file>/external/glpk/glpapi.h`/
26
27 int glp_print_solcxx . . $ glp_print_sol(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *P, const char *fname)
28 { /* write basic solution in printable format */
29 XFILEcxx . . $ XFILE# *fp;
30 GLPROWcxx . . $ GLPROW# *row;
31 GLPCOLcxx . . $ GLPCOL# *col;
32 int i, j, t, ae_ind, re_ind, ret;
33 double ae_max, re_max;
34 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing basic solution to `%s'...\n", fname);
35 fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w");
36 if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
37 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
38 ret = 1;
39 goto done;
40 }
41 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s\n", "Problem:",
42 P->namecxx . . $ glp_prob#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : P->namecxx . . $ glp_prob#name.);
43 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%d\n", "Rows:", P->mcxx . . $ glp_prob#m.);
44 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%d\n", "Columns:", P->ncxx . . $ glp_prob#n.);
45 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%d\n", "Non-zeros:", P->nnzcxx . . $ glp_prob#nnz.);
46 t = glp_get_statuscxx . . $ glp_get_status(317ecc1aeadfe2b7).(P);
47 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s\n", "Status:",
48 t == GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`! ? "OPTIMAL" :
49 t == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`! ? "FEASIBLE" :
50 t == GLP_INFEAScxx . . $ `external/glpk/glpk.h:87:9`! ? "INFEASIBLE (INTERMEDIATE)" :
51 t == GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`! ? "INFEASIBLE (FINAL)" :
52 t == GLP_UNBNDcxx . . $ `external/glpk/glpk.h:90:9`! ? "UNBOUNDED" :
53 t == GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`! ? "UNDEFINED" : "???");
54 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s%s%.10g (%s)\n", "Objective:",
55 P->objcxx . . $ glp_prob#obj. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : P->objcxx . . $ glp_prob#obj.,
56 P->objcxx . . $ glp_prob#obj. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : " = ", P->obj_valcxx . . $ glp_prob#obj_val.,
57 P->dircxx . . $ glp_prob#dir. == GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`! ? "MINimum" :
58 P->dircxx . . $ glp_prob#dir. == GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`! ? "MAXimum" : "???");
59 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
60 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " No. Row name St Activity Lower bound "
61 " Upper bound Marginal\n");
62 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "------ ------------ -- ------------- ------------- "
63 "------------- -------------\n");
64 for (i = 1; i <= P->mcxx . . $ glp_prob#m.; i++)
65 { row = P->rowcxx . . $ glp_prob#row.[i];
66 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6d ", i);
67 if (row->namecxx . . $ GLPROW#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || strlencxx . . $ strlen(751346f8406fd082).(row->namecxx . . $ GLPROW#name.) <= 12)
68 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s ", row->namecxx . . $ GLPROW#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : row->namecxx . . $ GLPROW#name.);
69 else
70 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s\n%20s", row->namecxx . . $ GLPROW#name., "");
71 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s ",
72 row->statcxx . . $ GLPROW#stat. == GLP_BScxx . . $ `external/glpk/glpk.h:66:9`! ? "B " :
73 row->statcxx . . $ GLPROW#stat. == GLP_NLcxx . . $ `external/glpk/glpk.h:67:9`! ? "NL" :
74 row->statcxx . . $ GLPROW#stat. == GLP_NUcxx . . $ `external/glpk/glpk.h:68:9`! ? "NU" :
75 row->statcxx . . $ GLPROW#stat. == GLP_NFcxx . . $ `external/glpk/glpk.h:69:9`! ? "NF" :
76 row->statcxx . . $ GLPROW#stat. == GLP_NScxx . . $ `external/glpk/glpk.h:70:9`! ? "NS" : "??");
77 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ",
78 fabs(row->primcxx . . $ GLPROW#prim.) <= 1e-9 ? 0.0 : row->primcxx . . $ GLPROW#prim.);
79 if (row->typecxx . . $ GLPROW#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! || row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! ||
80 row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!)
81 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", row->lbcxx . . $ GLPROW#lb.);
82 else
83 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", "");
84 if (row->typecxx . . $ GLPROW#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!)
85 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", row->ubcxx . . $ GLPROW#ub.);
86 else
87 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`! ? "=" : "");
88 if (row->statcxx . . $ GLPROW#stat. != GLP_BScxx . . $ `external/glpk/glpk.h:66:9`!)
89 { if (fabs(row->dualcxx . . $ GLPROW#dual.) <= 1e-9)
90 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s", "< eps");
91 else
92 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", row->dualcxx . . $ GLPROW#dual.);
93 }
94 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
95 }
96 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
97 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " No. Column name St Activity Lower bound "
98 " Upper bound Marginal\n");
99 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "------ ------------ -- ------------- ------------- "
100 "------------- -------------\n");
101 for (j = 1; j <= P->ncxx . . $ glp_prob#n.; j++)
102 { col = P->colcxx . . $ glp_prob#col.[j];
103 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6d ", j);
104 if (col->namecxx . . $ GLPCOL#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || strlencxx . . $ strlen(751346f8406fd082).(col->namecxx . . $ GLPCOL#name.) <= 12)
105 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s ", col->namecxx . . $ GLPCOL#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : col->namecxx . . $ GLPCOL#name.);
106 else
107 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s\n%20s", col->namecxx . . $ GLPCOL#name., "");
108 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s ",
109 col->statcxx . . $ GLPCOL#stat. == GLP_BScxx . . $ `external/glpk/glpk.h:66:9`! ? "B " :
110 col->statcxx . . $ GLPCOL#stat. == GLP_NLcxx . . $ `external/glpk/glpk.h:67:9`! ? "NL" :
111 col->statcxx . . $ GLPCOL#stat. == GLP_NUcxx . . $ `external/glpk/glpk.h:68:9`! ? "NU" :
112 col->statcxx . . $ GLPCOL#stat. == GLP_NFcxx . . $ `external/glpk/glpk.h:69:9`! ? "NF" :
113 col->statcxx . . $ GLPCOL#stat. == GLP_NScxx . . $ `external/glpk/glpk.h:70:9`! ? "NS" : "??");
114 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ",
115 fabs(col->primcxx . . $ GLPCOL#prim.) <= 1e-9 ? 0.0 : col->primcxx . . $ GLPCOL#prim.);
116 if (col->typecxx . . $ GLPCOL#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! || col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! ||
117 col->typecxx . . $ GLPCOL#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!)
118 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", col->lbcxx . . $ GLPCOL#lb.);
119 else
120 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", "");
121 if (col->typecxx . . $ GLPCOL#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!)
122 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", col->ubcxx . . $ GLPCOL#ub.);
123 else
124 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", col->typecxx . . $ GLPCOL#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`! ? "=" : "");
125 if (col->statcxx . . $ GLPCOL#stat. != GLP_BScxx . . $ `external/glpk/glpk.h:66:9`!)
126 { if (fabs(col->dualcxx . . $ GLPCOL#dual.) <= 1e-9)
127 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s", "< eps");
128 else
129 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", col->dualcxx . . $ GLPCOL#dual.);
130 }
131 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
132 }
133 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
134 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "Karush-Kuhn-Tucker optimality conditions:\n");
135 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
136 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_SOLcxx . . $ `external/glpk/glpk.h:80:9`!, GLP_KKT_PEcxx . . $ `external/glpk/glpk.h:260:9`!, &ae_max, &ae_ind, &re_max,
137 &re_ind);
138 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.PE: max.abs.err = %.2e on row %d\n",
139 ae_max, ae_ind);
140 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on row %d\n",
141 re_max, re_ind);
142 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
143 re_max <= 1e-9 ? "High quality" :
144 re_max <= 1e-6 ? "Medium quality" :
145 re_max <= 1e-3 ? "Low quality" : "PRIMAL SOLUTION IS WRONG");
146 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
147 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_SOLcxx . . $ `external/glpk/glpk.h:80:9`!, GLP_KKT_PBcxx . . $ `external/glpk/glpk.h:261:9`!, &ae_max, &ae_ind, &re_max,
148 &re_ind);
149 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.PB: max.abs.err = %.2e on %s %d\n",
150 ae_max, ae_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
151 ae_ind <= P->mcxx . . $ glp_prob#m. ? ae_ind : ae_ind - P->mcxx . . $ glp_prob#m.);
152 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on %s %d\n",
153 re_max, re_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
154 re_ind <= P->mcxx . . $ glp_prob#m. ? re_ind : re_ind - P->mcxx . . $ glp_prob#m.);
155 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
156 re_max <= 1e-9 ? "High quality" :
157 re_max <= 1e-6 ? "Medium quality" :
158 re_max <= 1e-3 ? "Low quality" : "PRIMAL SOLUTION IS INFEASIBL"
159 "E");
160 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
161 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_SOLcxx . . $ `external/glpk/glpk.h:80:9`!, GLP_KKT_DEcxx . . $ `external/glpk/glpk.h:262:9`!, &ae_max, &ae_ind, &re_max,
162 &re_ind);
163 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.DE: max.abs.err = %.2e on column %d\n",
164 ae_max, ae_ind == 0 ? 0 : ae_ind - P->mcxx . . $ glp_prob#m.);
165 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on column %d\n",
166 re_max, re_ind == 0 ? 0 : re_ind - P->mcxx . . $ glp_prob#m.);
167 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
168 re_max <= 1e-9 ? "High quality" :
169 re_max <= 1e-6 ? "Medium quality" :
170 re_max <= 1e-3 ? "Low quality" : "DUAL SOLUTION IS WRONG");
171 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
172 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_SOLcxx . . $ `external/glpk/glpk.h:80:9`!, GLP_KKT_DBcxx . . $ `external/glpk/glpk.h:263:9`!, &ae_max, &ae_ind, &re_max,
173 &re_ind);
174 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.DB: max.abs.err = %.2e on %s %d\n",
175 ae_max, ae_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
176 ae_ind <= P->mcxx . . $ glp_prob#m. ? ae_ind : ae_ind - P->mcxx . . $ glp_prob#m.);
177 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on %s %d\n",
178 re_max, re_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
179 re_ind <= P->mcxx . . $ glp_prob#m. ? re_ind : re_ind - P->mcxx . . $ glp_prob#m.);
180 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
181 re_max <= 1e-9 ? "High quality" :
182 re_max <= 1e-6 ? "Medium quality" :
183 re_max <= 1e-3 ? "Low quality" : "DUAL SOLUTION IS INFEASIBLE")
184 ;
185 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
186 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "End of output\n");
187 xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp);
188 if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp))
189 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
190 ret = 1;
191 goto done;
192 }
193 ret = 0;
194 done: if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(fp);
195 return ret;
196 }
197
198 /***********************************************************************
199 * NAME
200 *
201 * glp_read_sol - read basic solution from text file
202 *
203 * SYNOPSIS
204 *
205 * int glp_read_sol(glp_prob *lp, const char *fname);
206 *
207 * DESCRIPTION
208 *
209 * The routine glp_read_sol reads basic solution from a text file whose
210 * name is specified by the parameter fname into the problem object.
211 *
212 * For the file format see description of the routine glp_write_sol.
213 *
214 * RETURNS
215 *
216 * On success the routine returns zero, otherwise non-zero. */
217
218 int glp_read_solcxx . . $ glp_read_sol(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *lp, const char *fname)
219 { glp_datacxx . . $ glp_data# *data;
220 jmp_bufcxx . . $ jmp_buf# jump;
221 int i, j, k, ret = 0;
222 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Reading basic solution from `%s'...\n", fname);
223 data = glp_sdf_open_filecxx . . $ glp_sdf_open_file(48b6cd6ae4c46f0f).(fname);
224 if (data == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
225 { ret = 1;
226 goto done;
227 }
228 if (setjmpcxx . . $ `<external>/4367339001007250937/setjmp.h:49:9`!(jump))
229 { ret = 1;
230 goto done;
231 }
232 glp_sdf_set_jumpcxx . . $ glp_sdf_set_jump(b0c068eebba1df51).(data, jump);
233 /* number of rows, number of columns */
234 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
235 if (k != lp->mcxx . . $ glp_prob#m.)
236 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "wrong number of rows\n");
237 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
238 if (k != lp->ncxx . . $ glp_prob#n.)
239 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "wrong number of columns\n");
240 /* primal status, dual status, objective value */
241 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
242 if (!(k == GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`! || k == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`! || k == GLP_INFEAScxx . . $ `external/glpk/glpk.h:87:9`! ||
243 k == GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!))
244 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "invalid primal status\n");
245 lp->pbs_statcxx . . $ glp_prob#pbs_stat. = k;
246 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
247 if (!(k == GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`! || k == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`! || k == GLP_INFEAScxx . . $ `external/glpk/glpk.h:87:9`! ||
248 k == GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!))
249 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "invalid dual status\n");
250 lp->dbs_statcxx . . $ glp_prob#dbs_stat. = k;
251 lp->obj_valcxx . . $ glp_prob#obj_val. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
252 /* rows (auxiliary variables) */
253 for (i = 1; i <= lp->mcxx . . $ glp_prob#m.; i++)
254 { GLPROWcxx . . $ GLPROW# *row = lp->rowcxx . . $ glp_prob#row.[i];
255 /* status, primal value, dual value */
256 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
257 if (!(k == GLP_BScxx . . $ `external/glpk/glpk.h:66:9`! || k == GLP_NLcxx . . $ `external/glpk/glpk.h:67:9`! || k == GLP_NUcxx . . $ `external/glpk/glpk.h:68:9`! ||
258 k == GLP_NFcxx . . $ `external/glpk/glpk.h:69:9`! || k == GLP_NScxx . . $ `external/glpk/glpk.h:70:9`!))
259 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "invalid row status\n");
260 glp_set_row_statcxx . . $ glp_set_row_stat(b083f42914639ad0).(lp, i, k);
261 row->primcxx . . $ GLPROW#prim. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
262 row->dualcxx . . $ GLPROW#dual. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
263 }
264 /* columns (structural variables) */
265 for (j = 1; j <= lp->ncxx . . $ glp_prob#n.; j++)
266 { GLPCOLcxx . . $ GLPCOL# *col = lp->colcxx . . $ glp_prob#col.[j];
267 /* status, primal value, dual value */
268 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
269 if (!(k == GLP_BScxx . . $ `external/glpk/glpk.h:66:9`! || k == GLP_NLcxx . . $ `external/glpk/glpk.h:67:9`! || k == GLP_NUcxx . . $ `external/glpk/glpk.h:68:9`! ||
270 k == GLP_NFcxx . . $ `external/glpk/glpk.h:69:9`! || k == GLP_NScxx . . $ `external/glpk/glpk.h:70:9`!))
271 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "invalid column status\n");
272 glp_set_col_statcxx . . $ glp_set_col_stat(b083f42914639ad0).(lp, j, k);
273 col->primcxx . . $ GLPCOL#prim. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
274 col->dualcxx . . $ GLPCOL#dual. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
275 }
276 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were read\n", glp_sdf_linecxx . . $ glp_sdf_line(d55aa0a7098b3be0).(data));
277 done: if (ret) lp->pbs_statcxx . . $ glp_prob#pbs_stat. = lp->dbs_statcxx . . $ glp_prob#dbs_stat. = GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`!;
278 if (data != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) glp_sdf_close_filecxx . . $ glp_sdf_close_file(eb8f982ad4273b27).(data);
279 return ret;
280 }
281
282 /***********************************************************************
283 * NAME
284 *
285 * glp_write_sol - write basic solution to text file
286 *
287 * SYNOPSIS
288 *
289 * int glp_write_sol(glp_prob *lp, const char *fname);
290 *
291 * DESCRIPTION
292 *
293 * The routine glp_write_sol writes the current basic solution to a
294 * text file whose name is specified by the parameter fname. This file
295 * can be read back with the routine glp_read_sol.
296 *
297 * RETURNS
298 *
299 * On success the routine returns zero, otherwise non-zero.
300 *
301 * FILE FORMAT
302 *
303 * The file created by the routine glp_write_sol is a plain text file,
304 * which contains the following information:
305 *
306 * m n
307 * p_stat d_stat obj_val
308 * r_stat[1] r_prim[1] r_dual[1]
309 * . . .
310 * r_stat[m] r_prim[m] r_dual[m]
311 * c_stat[1] c_prim[1] c_dual[1]
312 * . . .
313 * c_stat[n] c_prim[n] c_dual[n]
314 *
315 * where:
316 * m is the number of rows (auxiliary variables);
317 * n is the number of columns (structural variables);
318 * p_stat is the primal status of the basic solution (GLP_UNDEF = 1,
319 * GLP_FEAS = 2, GLP_INFEAS = 3, or GLP_NOFEAS = 4);
320 * d_stat is the dual status of the basic solution (GLP_UNDEF = 1,
321 * GLP_FEAS = 2, GLP_INFEAS = 3, or GLP_NOFEAS = 4);
322 * obj_val is the objective value;
323 * r_stat[i], i = 1,...,m, is the status of i-th row (GLP_BS = 1,
324 * GLP_NL = 2, GLP_NU = 3, GLP_NF = 4, or GLP_NS = 5);
325 * r_prim[i], i = 1,...,m, is the primal value of i-th row;
326 * r_dual[i], i = 1,...,m, is the dual value of i-th row;
327 * c_stat[j], j = 1,...,n, is the status of j-th column (GLP_BS = 1,
328 * GLP_NL = 2, GLP_NU = 3, GLP_NF = 4, or GLP_NS = 5);
329 * c_prim[j], j = 1,...,n, is the primal value of j-th column;
330 * c_dual[j], j = 1,...,n, is the dual value of j-th column. */
331
332 int glp_write_solcxx . . $ glp_write_sol(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *lp, const char *fname)
333 { XFILEcxx . . $ XFILE# *fp;
334 int i, j, ret = 0;
335 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing basic solution to `%s'...\n", fname);
336 fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w");
337 if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
338 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
339 ret = 1;
340 goto done;
341 }
342 /* number of rows, number of columns */
343 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%d %d\n", lp->mcxx . . $ glp_prob#m., lp->ncxx . . $ glp_prob#n.);
344 /* primal status, dual status, objective value */
345 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%d %d %.*g\n", lp->pbs_statcxx . . $ glp_prob#pbs_stat., lp->dbs_statcxx . . $ glp_prob#dbs_stat., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!,
346 lp->obj_valcxx . . $ glp_prob#obj_val.);
347 /* rows (auxiliary variables) */
348 for (i = 1; i <= lp->mcxx . . $ glp_prob#m.; i++)
349 { GLPROWcxx . . $ GLPROW# *row = lp->rowcxx . . $ glp_prob#row.[i];
350 /* status, primal value, dual value */
351 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%d %.*g %.*g\n", row->statcxx . . $ GLPROW#stat., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, row->primcxx . . $ GLPROW#prim.,
352 DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, row->dualcxx . . $ GLPROW#dual.);
353 }
354 /* columns (structural variables) */
355 for (j = 1; j <= lp->ncxx . . $ glp_prob#n.; j++)
356 { GLPCOLcxx . . $ GLPCOL# *col = lp->colcxx . . $ glp_prob#col.[j];
357 /* status, primal value, dual value */
358 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%d %.*g %.*g\n", col->statcxx . . $ GLPCOL#stat., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, col->primcxx . . $ GLPCOL#prim.,
359 DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, col->dualcxx . . $ GLPCOL#dual.);
360 }
361 xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp);
362 if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp))
363 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
364 ret = 1;
365 goto done;
366 }
367 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were written\n", 2 + lp->mcxx . . $ glp_prob#m. + lp->ncxx . . $ glp_prob#n.);
368 done: if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(fp);
369 return ret;
370 }
371
372 /**********************************************************************/
373
374 static char *formatcxx . . $ format(d522f30c0e54ce90).(char buf[13+1], double x)
375 { /* format floating-point number in MPS/360-like style */
376 if (x == -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!)
377 strcpycxx . . $ strcpy(b7b3a83273496486).(buf, " -Inf");
378 else if (x == +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!)
379 strcpycxx . . $ strcpy(b7b3a83273496486).(buf, " +Inf");
380 else if (fabs(x) <= 999999.99998)
381 { sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf, "%13.5f", x);
382 #if 1
383 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buf, " 0.00000") == 0 ||
384 strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buf, " -0.00000") == 0)
385 strcpycxx . . $ strcpy(b7b3a83273496486).(buf, " . ");
386 else if (memcmpcxx . . $ memcmp(36f949851efa3055).(buf, " 0.", 8) == 0)
387 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, " .", 8);
388 else if (memcmpcxx . . $ memcmp(36f949851efa3055).(buf, " -0.", 8) == 0)
389 memcpycxx . . $ memcpy(cc817cb175f282d).(buf, " -.", 8);
390 #endif
391 }
392 else
393 sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf, "%13.6g", x);
394 return buf;
395 }
396
397 int glp_print_rangescxx . . $ glp_print_ranges(5820a35160249772).(glp_probcxx . . $ glp_prob# *P, int len, const int list[],
398 int flags, const char *fname)
399 { /* print sensitivity analysis report */
400 XFILEcxx . . $ XFILE# *fp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
401 GLPROWcxx . . $ GLPROW# *row;
402 GLPCOLcxx . . $ GLPCOL# *col;
403 int m, n, pass, k, t, numb, type, stat, var1, var2, count, page,
404 ret;
405 double lb, ub, slack, coef, prim, dual, value1, value2, coef1,
406 coef2, obj1, obj2;
407 const char *name, *limit;
408 char buf[13+1];
409 /* sanity checks */
410 if (P == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || P->magiccxx . . $ glp_prob#magic. != GLP_PROB_MAGICcxx . . $ `external/glpk/glpapi.h:39:9`!)
411 xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_print_ranges: P = %p; invalid problem object\n",
412 P);
413 m = P->mcxx . . $ glp_prob#m., n = P->ncxx . . $ glp_prob#n.;
414 if (len < 0)
415 xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_print_ranges: len = %d; invalid list length\n",
416 len);
417 if (len > 0)
418 { if (list == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
419 xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_print_ranges: list = %p: invalid parameter\n",
420 list);
421 for (t = 1; t <= len; t++)
422 { k = list[t];
423 if (!(1 <= k && k <= m+n))
424 xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_print_ranges: list[%d] = %d; row/column numb"
425 "er out of range\n", t, k);
426 }
427 }
428 if (flags != 0)
429 xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_print_ranges: flags = %d; invalid parameter\n",
430 flags);
431 if (fname == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
432 xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_print_ranges: fname = %p; invalid parameter\n",
433 fname);
434 if (glp_get_statuscxx . . $ glp_get_status(317ecc1aeadfe2b7).(P) != GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`!)
435 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("glp_print_ranges: optimal basic solution required\n");
436 ret = 1;
437 goto done;
438 }
439 if (!glp_bf_existscxx . . $ glp_bf_exists(317ecc1aeadfe2b7).(P))
440 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("glp_print_ranges: basis factorization required\n");
441 ret = 2;
442 goto done;
443 }
444 /* start reporting */
445 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write sensitivity analysis report to `%s'...\n", fname);
446 fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w");
447 if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
448 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
449 ret = 3;
450 goto done;
451 }
452 page = count = 0;
453 for (pass = 1; pass <= 2; pass++)
454 for (t = 1; t <= (len == 0 ? m+n : len); t++)
455 { if (t == 1) count = 0;
456 k = (len == 0 ? t : list[t]);
457 if (pass == 1 && k > m || pass == 2 && k <= m)
458 continue;
459 if (count == 0)
460 { xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "GLPK %-4s - SENSITIVITY ANALYSIS REPORT%73sPa"
461 "ge%4d\n", glp_versioncxx . . $ glp_version(33a1f659e94feb42).(), "", ++page);
462 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
463 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s\n", "Problem:",
464 P->namecxx . . $ glp_prob#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : P->namecxx . . $ glp_prob#name.);
465 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s%s%.10g (%s)\n", "Objective:",
466 P->objcxx . . $ glp_prob#obj. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : P->objcxx . . $ glp_prob#obj.,
467 P->objcxx . . $ glp_prob#obj. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : " = ", P->obj_valcxx . . $ glp_prob#obj_val.,
468 P->dircxx . . $ glp_prob#dir. == GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`! ? "MINimum" :
469 P->dircxx . . $ glp_prob#dir. == GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`! ? "MAXimum" : "???");
470 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
471 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6s %-12s %2s %13s %13s %13s %13s %13s %13s "
472 "%s\n", "No.", pass == 1 ? "Row name" : "Column name",
473 "St", "Activity", pass == 1 ? "Slack" : "Obj coef",
474 "Lower bound", "Activity", "Obj coef", "Obj value at",
475 "Limiting");
476 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6s %-12s %2s %13s %13s %13s %13s %13s %13s "
477 "%s\n", "", "", "", "", "Marginal", "Upper bound",
478 "range", "range", "break point", "variable");
479 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "------ ------------ -- ------------- --------"
480 "----- ------------- ------------- ------------- ------"
481 "------- ------------\n");
482 }
483 if (pass == 1)
484 { numb = k;
485 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(1 <= numb && numb <= m);
486 row = P->rowcxx . . $ glp_prob#row.[numb];
487 name = row->namecxx . . $ GLPROW#name.;
488 type = row->typecxx . . $ GLPROW#type.;
489 lb = glp_get_row_lbcxx . . $ glp_get_row_lb(68c5770eb0f32231).(P, numb);
490 ub = glp_get_row_ubcxx . . $ glp_get_row_ub(68c5770eb0f32231).(P, numb);
491 coef = 0.0;
492 stat = row->statcxx . . $ GLPROW#stat.;
493 prim = row->primcxx . . $ GLPROW#prim.;
494 if (type == GLP_FRcxx . . $ `external/glpk/glpk.h:59:9`!)
495 slack = - prim;
496 else if (type == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`!)
497 slack = lb - prim;
498 else if (type == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || type == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! || type == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!)
499 slack = ub - prim;
500 dual = row->dualcxx . . $ GLPROW#dual.;
501 }
502 else
503 { numb = k - m;
504 xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(1 <= numb && numb <= n);
505 col = P->colcxx . . $ glp_prob#col.[numb];
506 name = col->namecxx . . $ GLPCOL#name.;
507 lb = glp_get_col_lbcxx . . $ glp_get_col_lb(68c5770eb0f32231).(P, numb);
508 ub = glp_get_col_ubcxx . . $ glp_get_col_ub(68c5770eb0f32231).(P, numb);
509 coef = col->coefcxx . . $ GLPCOL#coef.;
510 stat = col->statcxx . . $ GLPCOL#stat.;
511 prim = col->primcxx . . $ GLPCOL#prim.;
512 slack = 0.0;
513 dual = col->dualcxx . . $ GLPCOL#dual.;
514 }
515 if (stat != GLP_BScxx . . $ `external/glpk/glpk.h:66:9`!)
516 { glp_analyze_boundcxx . . $ glp_analyze_bound(457978f5f62a4d0e).(P, k, &value1, &var1, &value2, &var2);
517 if (stat == GLP_NFcxx . . $ `external/glpk/glpk.h:69:9`!)
518 coef1 = coef2 = coef;
519 else if (stat == GLP_NScxx . . $ `external/glpk/glpk.h:70:9`!)
520 coef1 = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!, coef2 = +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
521 else if (stat == GLP_NLcxx . . $ `external/glpk/glpk.h:67:9`! && P->dircxx . . $ glp_prob#dir. == GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`! ||
522 stat == GLP_NUcxx . . $ `external/glpk/glpk.h:68:9`! && P->dircxx . . $ glp_prob#dir. == GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`!)
523 coef1 = coef - dual, coef2 = +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
524 else
525 coef1 = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!, coef2 = coef - dual;
526 if (value1 == -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!)
527 { if (dual < -1e-9)
528 obj1 = +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
529 else if (dual > +1e-9)
530 obj1 = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
531 else
532 obj1 = P->obj_valcxx . . $ glp_prob#obj_val.;
533 }
534 else
535 obj1 = P->obj_valcxx . . $ glp_prob#obj_val. + dual * (value1 - prim);
536 if (value2 == +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!)
537 { if (dual < -1e-9)
538 obj2 = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
539 else if (dual > +1e-9)
540 obj2 = +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
541 else
542 obj2 = P->obj_valcxx . . $ glp_prob#obj_val.;
543 }
544 else
545 obj2 = P->obj_valcxx . . $ glp_prob#obj_val. + dual * (value2 - prim);
546 }
547 else
548 { glp_analyze_coefcxx . . $ glp_analyze_coef(3fcab2195889572).(P, k, &coef1, &var1, &value1, &coef2,
549 &var2, &value2);
550 if (coef1 == -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!)
551 { if (prim < -1e-9)
552 obj1 = +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
553 else if (prim > +1e-9)
554 obj1 = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
555 else
556 obj1 = P->obj_valcxx . . $ glp_prob#obj_val.;
557 }
558 else
559 obj1 = P->obj_valcxx . . $ glp_prob#obj_val. + (coef1 - coef) * prim;
560 if (coef2 == +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!)
561 { if (prim < -1e-9)
562 obj2 = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
563 else if (prim > +1e-9)
564 obj2 = +DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
565 else
566 obj2 = P->obj_valcxx . . $ glp_prob#obj_val.;
567 }
568 else
569 obj2 = P->obj_valcxx . . $ glp_prob#obj_val. + (coef2 - coef) * prim;
570 }
571 /*** first line ***/
572 /* row/column number */
573 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6d", numb);
574 /* row/column name */
575 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %-12.12s", name == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : name);
576 if (name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && strlencxx . . $ strlen(751346f8406fd082).(name) > 12)
577 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s\n%6s %12s", name+12, "", "");
578 /* row/column status */
579 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %2s",
580 stat == GLP_BScxx . . $ `external/glpk/glpk.h:66:9`! ? "BS" : stat == GLP_NLcxx . . $ `external/glpk/glpk.h:67:9`! ? "NL" :
581 stat == GLP_NUcxx . . $ `external/glpk/glpk.h:68:9`! ? "NU" : stat == GLP_NFcxx . . $ `external/glpk/glpk.h:69:9`! ? "NF" :
582 stat == GLP_NScxx . . $ `external/glpk/glpk.h:70:9`! ? "NS" : "??");
583 /* row/column activity */
584 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, prim));
585 /* row slack, column objective coefficient */
586 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, k <= m ? slack : coef));
587 /* row/column lower bound */
588 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, lb));
589 /* row/column activity range */
590 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, value1));
591 /* row/column objective coefficient range */
592 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, coef1));
593 /* objective value at break point */
594 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, obj1));
595 /* limiting variable name */
596 if (var1 != 0)
597 { if (var1 <= m)
598 limit = glp_get_row_namecxx . . $ glp_get_row_name(d11e5f1cd3184808).(P, var1);
599 else
600 limit = glp_get_col_namecxx . . $ glp_get_col_name(d11e5f1cd3184808).(P, var1 - m);
601 if (limit != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
602 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", limit);
603 }
604 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
605 /*** second line ***/
606 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6s %-12s %2s %13s", "", "", "", "");
607 /* row/column reduced cost */
608 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, dual));
609 /* row/column upper bound */
610 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, ub));
611 /* row/column activity range */
612 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, value2));
613 /* row/column objective coefficient range */
614 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, coef2));
615 /* objective value at break point */
616 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", formatcxx . . $ format(d522f30c0e54ce90).(buf, obj2));
617 /* limiting variable name */
618 if (var2 != 0)
619 { if (var2 <= m)
620 limit = glp_get_row_namecxx . . $ glp_get_row_name(d11e5f1cd3184808).(P, var2);
621 else
622 limit = glp_get_col_namecxx . . $ glp_get_col_name(d11e5f1cd3184808).(P, var2 - m);
623 if (limit != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
624 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " %s", limit);
625 }
626 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
627 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
628 /* print 10 items per page */
629 count = (count + 1) % 10;
630 }
631 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "End of report\n");
632 xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp);
633 if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp))
634 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
635 ret = 4;
636 goto done;
637 }
638 ret = 0;
639 done: if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(fp);
640 return ret;
641 }
642
643 /**********************************************************************/
644
645 int glp_print_iptcxx . . $ glp_print_ipt(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *P, const char *fname)
646 { /* write interior-point solution in printable format */
647 XFILEcxx . . $ XFILE# *fp;
648 GLPROWcxx . . $ GLPROW# *row;
649 GLPCOLcxx . . $ GLPCOL# *col;
650 int i, j, t, ae_ind, re_ind, ret;
651 double ae_max, re_max;
652 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing interior-point solution to `%s'...\n", fname);
653 fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w");
654 if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
655 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
656 ret = 1;
657 goto done;
658 }
659 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s\n", "Problem:",
660 P->namecxx . . $ glp_prob#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : P->namecxx . . $ glp_prob#name.);
661 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%d\n", "Rows:", P->mcxx . . $ glp_prob#m.);
662 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%d\n", "Columns:", P->ncxx . . $ glp_prob#n.);
663 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%d\n", "Non-zeros:", P->nnzcxx . . $ glp_prob#nnz.);
664 t = glp_ipt_statuscxx . . $ glp_ipt_status(317ecc1aeadfe2b7).(P);
665 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s\n", "Status:",
666 t == GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`! ? "OPTIMAL" :
667 t == GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`! ? "UNDEFINED" :
668 t == GLP_INFEAScxx . . $ `external/glpk/glpk.h:87:9`! ? "INFEASIBLE (INTERMEDIATE)" :
669 t == GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`! ? "INFEASIBLE (FINAL)" : "???");
670 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s%s%.10g (%s)\n", "Objective:",
671 P->objcxx . . $ glp_prob#obj. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : P->objcxx . . $ glp_prob#obj.,
672 P->objcxx . . $ glp_prob#obj. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : " = ", P->ipt_objcxx . . $ glp_prob#ipt_obj.,
673 P->dircxx . . $ glp_prob#dir. == GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`! ? "MINimum" :
674 P->dircxx . . $ glp_prob#dir. == GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`! ? "MAXimum" : "???");
675 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
676 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " No. Row name Activity Lower bound "
677 " Upper bound Marginal\n");
678 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "------ ------------ ------------- ------------- "
679 "------------- -------------\n");
680 for (i = 1; i <= P->mcxx . . $ glp_prob#m.; i++)
681 { row = P->rowcxx . . $ glp_prob#row.[i];
682 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6d ", i);
683 if (row->namecxx . . $ GLPROW#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || strlencxx . . $ strlen(751346f8406fd082).(row->namecxx . . $ GLPROW#name.) <= 12)
684 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s ", row->namecxx . . $ GLPROW#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : row->namecxx . . $ GLPROW#name.);
685 else
686 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s\n%20s", row->namecxx . . $ GLPROW#name., "");
687 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%3s", "");
688 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ",
689 fabs(row->pvalcxx . . $ GLPROW#pval.) <= 1e-9 ? 0.0 : row->pvalcxx . . $ GLPROW#pval.);
690 if (row->typecxx . . $ GLPROW#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! || row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! ||
691 row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!)
692 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", row->lbcxx . . $ GLPROW#lb.);
693 else
694 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", "");
695 if (row->typecxx . . $ GLPROW#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!)
696 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", row->ubcxx . . $ GLPROW#ub.);
697 else
698 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`! ? "=" : "");
699 if (fabs(row->dvalcxx . . $ GLPROW#dval.) <= 1e-9)
700 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s", "< eps");
701 else
702 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", row->dvalcxx . . $ GLPROW#dval.);
703 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
704 }
705 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
706 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " No. Column name Activity Lower bound "
707 " Upper bound Marginal\n");
708 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "------ ------------ ------------- ------------- "
709 "------------- -------------\n");
710 for (j = 1; j <= P->ncxx . . $ glp_prob#n.; j++)
711 { col = P->colcxx . . $ glp_prob#col.[j];
712 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6d ", j);
713 if (col->namecxx . . $ GLPCOL#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || strlencxx . . $ strlen(751346f8406fd082).(col->namecxx . . $ GLPCOL#name.) <= 12)
714 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s ", col->namecxx . . $ GLPCOL#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : col->namecxx . . $ GLPCOL#name.);
715 else
716 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s\n%20s", col->namecxx . . $ GLPCOL#name., "");
717 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%3s", "");
718 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ",
719 fabs(col->pvalcxx . . $ GLPCOL#pval.) <= 1e-9 ? 0.0 : col->pvalcxx . . $ GLPCOL#pval.);
720 if (col->typecxx . . $ GLPCOL#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! || col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! ||
721 col->typecxx . . $ GLPCOL#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!)
722 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", col->lbcxx . . $ GLPCOL#lb.);
723 else
724 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", "");
725 if (col->typecxx . . $ GLPCOL#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!)
726 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", col->ubcxx . . $ GLPCOL#ub.);
727 else
728 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", col->typecxx . . $ GLPCOL#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`! ? "=" : "");
729 if (fabs(col->dvalcxx . . $ GLPCOL#dval.) <= 1e-9)
730 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s", "< eps");
731 else
732 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", col->dvalcxx . . $ GLPCOL#dval.);
733 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
734 }
735 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
736 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "Karush-Kuhn-Tucker optimality conditions:\n");
737 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
738 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_IPTcxx . . $ `external/glpk/glpk.h:81:9`!, GLP_KKT_PEcxx . . $ `external/glpk/glpk.h:260:9`!, &ae_max, &ae_ind, &re_max,
739 &re_ind);
740 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.PE: max.abs.err = %.2e on row %d\n",
741 ae_max, ae_ind);
742 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on row %d\n",
743 re_max, re_ind);
744 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
745 re_max <= 1e-9 ? "High quality" :
746 re_max <= 1e-6 ? "Medium quality" :
747 re_max <= 1e-3 ? "Low quality" : "PRIMAL SOLUTION IS WRONG");
748 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
749 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_IPTcxx . . $ `external/glpk/glpk.h:81:9`!, GLP_KKT_PBcxx . . $ `external/glpk/glpk.h:261:9`!, &ae_max, &ae_ind, &re_max,
750 &re_ind);
751 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.PB: max.abs.err = %.2e on %s %d\n",
752 ae_max, ae_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
753 ae_ind <= P->mcxx . . $ glp_prob#m. ? ae_ind : ae_ind - P->mcxx . . $ glp_prob#m.);
754 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on %s %d\n",
755 re_max, re_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
756 re_ind <= P->mcxx . . $ glp_prob#m. ? re_ind : re_ind - P->mcxx . . $ glp_prob#m.);
757 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
758 re_max <= 1e-9 ? "High quality" :
759 re_max <= 1e-6 ? "Medium quality" :
760 re_max <= 1e-3 ? "Low quality" : "PRIMAL SOLUTION IS INFEASIBL"
761 "E");
762 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
763 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_IPTcxx . . $ `external/glpk/glpk.h:81:9`!, GLP_KKT_DEcxx . . $ `external/glpk/glpk.h:262:9`!, &ae_max, &ae_ind, &re_max,
764 &re_ind);
765 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.DE: max.abs.err = %.2e on column %d\n",
766 ae_max, ae_ind == 0 ? 0 : ae_ind - P->mcxx . . $ glp_prob#m.);
767 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on column %d\n",
768 re_max, re_ind == 0 ? 0 : re_ind - P->mcxx . . $ glp_prob#m.);
769 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
770 re_max <= 1e-9 ? "High quality" :
771 re_max <= 1e-6 ? "Medium quality" :
772 re_max <= 1e-3 ? "Low quality" : "DUAL SOLUTION IS WRONG");
773 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
774 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_IPTcxx . . $ `external/glpk/glpk.h:81:9`!, GLP_KKT_DBcxx . . $ `external/glpk/glpk.h:263:9`!, &ae_max, &ae_ind, &re_max,
775 &re_ind);
776 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.DB: max.abs.err = %.2e on %s %d\n",
777 ae_max, ae_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
778 ae_ind <= P->mcxx . . $ glp_prob#m. ? ae_ind : ae_ind - P->mcxx . . $ glp_prob#m.);
779 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on %s %d\n",
780 re_max, re_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
781 re_ind <= P->mcxx . . $ glp_prob#m. ? re_ind : re_ind - P->mcxx . . $ glp_prob#m.);
782 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
783 re_max <= 1e-9 ? "High quality" :
784 re_max <= 1e-6 ? "Medium quality" :
785 re_max <= 1e-3 ? "Low quality" : "DUAL SOLUTION IS INFEASIBLE")
786 ;
787 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
788 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "End of output\n");
789 xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp);
790 if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp))
791 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
792 ret = 1;
793 goto done;
794 }
795 ret = 0;
796 done: if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(fp);
797 return ret;
798 }
799
800 /***********************************************************************
801 * NAME
802 *
803 * glp_read_ipt - read interior-point solution from text file
804 *
805 * SYNOPSIS
806 *
807 * int glp_read_ipt(glp_prob *lp, const char *fname);
808 *
809 * DESCRIPTION
810 *
811 * The routine glp_read_ipt reads interior-point solution from a text
812 * file whose name is specified by the parameter fname into the problem
813 * object.
814 *
815 * For the file format see description of the routine glp_write_ipt.
816 *
817 * RETURNS
818 *
819 * On success the routine returns zero, otherwise non-zero. */
820
821 int glp_read_iptcxx . . $ glp_read_ipt(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *lp, const char *fname)
822 { glp_datacxx . . $ glp_data# *data;
823 jmp_bufcxx . . $ jmp_buf# jump;
824 int i, j, k, ret = 0;
825 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Reading interior-point solution from `%s'...\n", fname);
826 data = glp_sdf_open_filecxx . . $ glp_sdf_open_file(48b6cd6ae4c46f0f).(fname);
827 if (data == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
828 { ret = 1;
829 goto done;
830 }
831 if (setjmpcxx . . $ `<external>/4367339001007250937/setjmp.h:49:9`!(jump))
832 { ret = 1;
833 goto done;
834 }
835 glp_sdf_set_jumpcxx . . $ glp_sdf_set_jump(b0c068eebba1df51).(data, jump);
836 /* number of rows, number of columns */
837 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
838 if (k != lp->mcxx . . $ glp_prob#m.)
839 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "wrong number of rows\n");
840 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
841 if (k != lp->ncxx . . $ glp_prob#n.)
842 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "wrong number of columns\n");
843 /* solution status, objective value */
844 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
845 if (!(k == GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`! || k == GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`!))
846 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "invalid solution status\n");
847 lp->ipt_statcxx . . $ glp_prob#ipt_stat. = k;
848 lp->ipt_objcxx . . $ glp_prob#ipt_obj. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
849 /* rows (auxiliary variables) */
850 for (i = 1; i <= lp->mcxx . . $ glp_prob#m.; i++)
851 { GLPROWcxx . . $ GLPROW# *row = lp->rowcxx . . $ glp_prob#row.[i];
852 /* primal value, dual value */
853 row->pvalcxx . . $ GLPROW#pval. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
854 row->dvalcxx . . $ GLPROW#dval. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
855 }
856 /* columns (structural variables) */
857 for (j = 1; j <= lp->ncxx . . $ glp_prob#n.; j++)
858 { GLPCOLcxx . . $ GLPCOL# *col = lp->colcxx . . $ glp_prob#col.[j];
859 /* primal value, dual value */
860 col->pvalcxx . . $ GLPCOL#pval. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
861 col->dvalcxx . . $ GLPCOL#dval. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
862 }
863 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were read\n", glp_sdf_linecxx . . $ glp_sdf_line(d55aa0a7098b3be0).(data));
864 done: if (ret) lp->ipt_statcxx . . $ glp_prob#ipt_stat. = GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`!;
865 if (data != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) glp_sdf_close_filecxx . . $ glp_sdf_close_file(eb8f982ad4273b27).(data);
866 return ret;
867 }
868
869 /***********************************************************************
870 * NAME
871 *
872 * glp_write_ipt - write interior-point solution to text file
873 *
874 * SYNOPSIS
875 *
876 * int glp_write_ipt(glp_prob *lp, const char *fname);
877 *
878 * DESCRIPTION
879 *
880 * The routine glp_write_ipt writes the current interior-point solution
881 * to a text file whose name is specified by the parameter fname. This
882 * file can be read back with the routine glp_read_ipt.
883 *
884 * RETURNS
885 *
886 * On success the routine returns zero, otherwise non-zero.
887 *
888 * FILE FORMAT
889 *
890 * The file created by the routine glp_write_ipt is a plain text file,
891 * which contains the following information:
892 *
893 * m n
894 * stat obj_val
895 * r_prim[1] r_dual[1]
896 * . . .
897 * r_prim[m] r_dual[m]
898 * c_prim[1] c_dual[1]
899 * . . .
900 * c_prim[n] c_dual[n]
901 *
902 * where:
903 * m is the number of rows (auxiliary variables);
904 * n is the number of columns (structural variables);
905 * stat is the solution status (GLP_UNDEF = 1 or GLP_OPT = 5);
906 * obj_val is the objective value;
907 * r_prim[i], i = 1,...,m, is the primal value of i-th row;
908 * r_dual[i], i = 1,...,m, is the dual value of i-th row;
909 * c_prim[j], j = 1,...,n, is the primal value of j-th column;
910 * c_dual[j], j = 1,...,n, is the dual value of j-th column. */
911
912 int glp_write_iptcxx . . $ glp_write_ipt(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *lp, const char *fname)
913 { XFILEcxx . . $ XFILE# *fp;
914 int i, j, ret = 0;
915 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing interior-point solution to `%s'...\n", fname);
916 fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w");
917 if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
918 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
919 ret = 1;
920 goto done;
921 }
922 /* number of rows, number of columns */
923 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%d %d\n", lp->mcxx . . $ glp_prob#m., lp->ncxx . . $ glp_prob#n.);
924 /* solution status, objective value */
925 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%d %.*g\n", lp->ipt_statcxx . . $ glp_prob#ipt_stat., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, lp->ipt_objcxx . . $ glp_prob#ipt_obj.);
926 /* rows (auxiliary variables) */
927 for (i = 1; i <= lp->mcxx . . $ glp_prob#m.; i++)
928 { GLPROWcxx . . $ GLPROW# *row = lp->rowcxx . . $ glp_prob#row.[i];
929 /* primal value, dual value */
930 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%.*g %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, row->pvalcxx . . $ GLPROW#pval., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!,
931 row->dvalcxx . . $ GLPROW#dval.);
932 }
933 /* columns (structural variables) */
934 for (j = 1; j <= lp->ncxx . . $ glp_prob#n.; j++)
935 { GLPCOLcxx . . $ GLPCOL# *col = lp->colcxx . . $ glp_prob#col.[j];
936 /* primal value, dual value */
937 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%.*g %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, col->pvalcxx . . $ GLPCOL#pval., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!,
938 col->dvalcxx . . $ GLPCOL#dval.);
939 }
940 xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp);
941 if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp))
942 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
943 ret = 1;
944 goto done;
945 }
946 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were written\n", 2 + lp->mcxx . . $ glp_prob#m. + lp->ncxx . . $ glp_prob#n.);
947 done: if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(fp);
948 return ret;
949 }
950
951 /**********************************************************************/
952
953 int glp_print_mipcxx . . $ glp_print_mip(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *P, const char *fname)
954 { /* write MIP solution in printable format */
955 XFILEcxx . . $ XFILE# *fp;
956 GLPROWcxx . . $ GLPROW# *row;
957 GLPCOLcxx . . $ GLPCOL# *col;
958 int i, j, t, ae_ind, re_ind, ret;
959 double ae_max, re_max;
960 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing MIP solution to `%s'...\n", fname);
961 fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w");
962 if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
963 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
964 ret = 1;
965 goto done;
966 }
967 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s\n", "Problem:",
968 P->namecxx . . $ glp_prob#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : P->namecxx . . $ glp_prob#name.);
969 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%d\n", "Rows:", P->mcxx . . $ glp_prob#m.);
970 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%d (%d integer, %d binary)\n", "Columns:",
971 P->ncxx . . $ glp_prob#n., glp_get_num_intcxx . . $ glp_get_num_int(317ecc1aeadfe2b7).(P), glp_get_num_bincxx . . $ glp_get_num_bin(317ecc1aeadfe2b7).(P));
972 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%d\n", "Non-zeros:", P->nnzcxx . . $ glp_prob#nnz.);
973 t = glp_mip_statuscxx . . $ glp_mip_status(317ecc1aeadfe2b7).(P);
974 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s\n", "Status:",
975 t == GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`! ? "INTEGER OPTIMAL" :
976 t == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`! ? "INTEGER NON-OPTIMAL" :
977 t == GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`! ? "INTEGER EMPTY" :
978 t == GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`! ? "INTEGER UNDEFINED" : "???");
979 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s%s%s%.10g (%s)\n", "Objective:",
980 P->objcxx . . $ glp_prob#obj. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : P->objcxx . . $ glp_prob#obj.,
981 P->objcxx . . $ glp_prob#obj. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : " = ", P->mip_objcxx . . $ glp_prob#mip_obj.,
982 P->dircxx . . $ glp_prob#dir. == GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`! ? "MINimum" :
983 P->dircxx . . $ glp_prob#dir. == GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`! ? "MAXimum" : "???");
984 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
985 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " No. Row name Activity Lower bound "
986 " Upper bound\n");
987 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "------ ------------ ------------- ------------- "
988 "-------------\n");
989 for (i = 1; i <= P->mcxx . . $ glp_prob#m.; i++)
990 { row = P->rowcxx . . $ glp_prob#row.[i];
991 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6d ", i);
992 if (row->namecxx . . $ GLPROW#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || strlencxx . . $ strlen(751346f8406fd082).(row->namecxx . . $ GLPROW#name.) <= 12)
993 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s ", row->namecxx . . $ GLPROW#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : row->namecxx . . $ GLPROW#name.);
994 else
995 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s\n%20s", row->namecxx . . $ GLPROW#name., "");
996 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%3s", "");
997 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ",
998 fabs(row->mipxcxx . . $ GLPROW#mipx.) <= 1e-9 ? 0.0 : row->mipxcxx . . $ GLPROW#mipx.);
999 if (row->typecxx . . $ GLPROW#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! || row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! ||
1000 row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!)
1001 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", row->lbcxx . . $ GLPROW#lb.);
1002 else
1003 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", "");
1004 if (row->typecxx . . $ GLPROW#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!)
1005 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", row->ubcxx . . $ GLPROW#ub.);
1006 else
1007 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`! ? "=" : "");
1008 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
1009 }
1010 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
1011 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " No. Column name Activity Lower bound "
1012 " Upper bound\n");
1013 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "------ ------------ ------------- ------------- "
1014 "-------------\n");
1015 for (j = 1; j <= P->ncxx . . $ glp_prob#n.; j++)
1016 { col = P->colcxx . . $ glp_prob#col.[j];
1017 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%6d ", j);
1018 if (col->namecxx . . $ GLPCOL#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || strlencxx . . $ strlen(751346f8406fd082).(col->namecxx . . $ GLPCOL#name.) <= 12)
1019 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%-12s ", col->namecxx . . $ GLPCOL#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : col->namecxx . . $ GLPCOL#name.);
1020 else
1021 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s\n%20s", col->namecxx . . $ GLPCOL#name., "");
1022 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%s ",
1023 col->kindcxx . . $ GLPCOL#kind. == GLP_CVcxx . . $ `external/glpk/glpk.h:54:9`! ? " " :
1024 col->kindcxx . . $ GLPCOL#kind. == GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`! ? "*" : "?");
1025 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ",
1026 fabs(col->mipxcxx . . $ GLPCOL#mipx.) <= 1e-9 ? 0.0 : col->mipxcxx . . $ GLPCOL#mipx.);
1027 if (col->typecxx . . $ GLPCOL#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! || col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! ||
1028 col->typecxx . . $ GLPCOL#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!)
1029 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", col->lbcxx . . $ GLPCOL#lb.);
1030 else
1031 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", "");
1032 if (col->typecxx . . $ GLPCOL#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!)
1033 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13.6g ", col->ubcxx . . $ GLPCOL#ub.);
1034 else
1035 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%13s ", col->typecxx . . $ GLPCOL#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`! ? "=" : "");
1036 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
1037 }
1038 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
1039 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "Integer feasibility conditions:\n");
1040 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
1041 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_MIPcxx . . $ `external/glpk/glpk.h:82:9`!, GLP_KKT_PEcxx . . $ `external/glpk/glpk.h:260:9`!, &ae_max, &ae_ind, &re_max,
1042 &re_ind);
1043 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.PE: max.abs.err = %.2e on row %d\n",
1044 ae_max, ae_ind);
1045 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on row %d\n",
1046 re_max, re_ind);
1047 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
1048 re_max <= 1e-9 ? "High quality" :
1049 re_max <= 1e-6 ? "Medium quality" :
1050 re_max <= 1e-3 ? "Low quality" : "SOLUTION IS WRONG");
1051 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
1052 _glp_check_kktcxx . . $ _glp_check_kkt(d20aa8e221df6422).(P, GLP_MIPcxx . . $ `external/glpk/glpk.h:82:9`!, GLP_KKT_PBcxx . . $ `external/glpk/glpk.h:261:9`!, &ae_max, &ae_ind, &re_max,
1053 &re_ind);
1054 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "KKT.PB: max.abs.err = %.2e on %s %d\n",
1055 ae_max, ae_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
1056 ae_ind <= P->mcxx . . $ glp_prob#m. ? ae_ind : ae_ind - P->mcxx . . $ glp_prob#m.);
1057 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, " max.rel.err = %.2e on %s %d\n",
1058 re_max, re_ind <= P->mcxx . . $ glp_prob#m. ? "row" : "column",
1059 re_ind <= P->mcxx . . $ glp_prob#m. ? re_ind : re_ind - P->mcxx . . $ glp_prob#m.);
1060 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%8s%s\n", "",
1061 re_max <= 1e-9 ? "High quality" :
1062 re_max <= 1e-6 ? "Medium quality" :
1063 re_max <= 1e-3 ? "Low quality" : "SOLUTION IS INFEASIBLE");
1064 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "\n");
1065 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "End of output\n");
1066 xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp);
1067 if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp))
1068 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
1069 ret = 1;
1070 goto done;
1071 }
1072 ret = 0;
1073 done: if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(fp);
1074 return ret;
1075 }
1076
1077 /***********************************************************************
1078 * NAME
1079 *
1080 * glp_read_mip - read MIP solution from text file
1081 *
1082 * SYNOPSIS
1083 *
1084 * int glp_read_mip(glp_prob *mip, const char *fname);
1085 *
1086 * DESCRIPTION
1087 *
1088 * The routine glp_read_mip reads MIP solution from a text file whose
1089 * name is specified by the parameter fname into the problem object.
1090 *
1091 * For the file format see description of the routine glp_write_mip.
1092 *
1093 * RETURNS
1094 *
1095 * On success the routine returns zero, otherwise non-zero. */
1096
1097 int glp_read_mipcxx . . $ glp_read_mip(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *mip, const char *fname)
1098 { glp_datacxx . . $ glp_data# *data;
1099 jmp_bufcxx . . $ jmp_buf# jump;
1100 int i, j, k, ret = 0;
1101 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Reading MIP solution from `%s'...\n", fname);
1102 data = glp_sdf_open_filecxx . . $ glp_sdf_open_file(48b6cd6ae4c46f0f).(fname);
1103 if (data == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1104 { ret = 1;
1105 goto done;
1106 }
1107 if (setjmpcxx . . $ `<external>/4367339001007250937/setjmp.h:49:9`!(jump))
1108 { ret = 1;
1109 goto done;
1110 }
1111 glp_sdf_set_jumpcxx . . $ glp_sdf_set_jump(b0c068eebba1df51).(data, jump);
1112 /* number of rows, number of columns */
1113 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
1114 if (k != mip->mcxx . . $ glp_prob#m.)
1115 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "wrong number of rows\n");
1116 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
1117 if (k != mip->ncxx . . $ glp_prob#n.)
1118 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "wrong number of columns\n");
1119 /* solution status, objective value */
1120 k = glp_sdf_read_intcxx . . $ glp_sdf_read_int(d55aa0a7098b3be0).(data);
1121 if (!(k == GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`! || k == GLP_OPTcxx . . $ `external/glpk/glpk.h:89:9`! || k == GLP_FEAScxx . . $ `external/glpk/glpk.h:86:9`! ||
1122 k == GLP_NOFEAScxx . . $ `external/glpk/glpk.h:88:9`!))
1123 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "invalid solution status\n");
1124 mip->mip_statcxx . . $ glp_prob#mip_stat. = k;
1125 mip->mip_objcxx . . $ glp_prob#mip_obj. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
1126 /* rows (auxiliary variables) */
1127 for (i = 1; i <= mip->mcxx . . $ glp_prob#m.; i++)
1128 { GLPROWcxx . . $ GLPROW# *row = mip->rowcxx . . $ glp_prob#row.[i];
1129 row->mipxcxx . . $ GLPROW#mipx. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
1130 }
1131 /* columns (structural variables) */
1132 for (j = 1; j <= mip->ncxx . . $ glp_prob#n.; j++)
1133 { GLPCOLcxx . . $ GLPCOL# *col = mip->colcxx . . $ glp_prob#col.[j];
1134 col->mipxcxx . . $ GLPCOL#mipx. = glp_sdf_read_numcxx . . $ glp_sdf_read_num(325c00c3fb71d09f).(data);
1135 if (col->kindcxx . . $ GLPCOL#kind. == GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`! && col->mipxcxx . . $ GLPCOL#mipx. != floor(col->mipxcxx . . $ GLPCOL#mipx.))
1136 glp_sdf_errorcxx . . $ glp_sdf_error(36733fdcc0114f3d).(data, "non-integer column value");
1137 }
1138 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were read\n", glp_sdf_linecxx . . $ glp_sdf_line(d55aa0a7098b3be0).(data));
1139 done: if (ret) mip->mip_statcxx . . $ glp_prob#mip_stat. = GLP_UNDEFcxx . . $ `external/glpk/glpk.h:85:9`!;
1140 if (data != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) glp_sdf_close_filecxx . . $ glp_sdf_close_file(eb8f982ad4273b27).(data);
1141 return ret;
1142 }
1143
1144 /***********************************************************************
1145 * NAME
1146 *
1147 * glp_write_mip - write MIP solution to text file
1148 *
1149 * SYNOPSIS
1150 *
1151 * int glp_write_mip(glp_prob *mip, const char *fname);
1152 *
1153 * DESCRIPTION
1154 *
1155 * The routine glp_write_mip writes the current MIP solution to a text
1156 * file whose name is specified by the parameter fname. This file can
1157 * be read back with the routine glp_read_mip.
1158 *
1159 * RETURNS
1160 *
1161 * On success the routine returns zero, otherwise non-zero.
1162 *
1163 * FILE FORMAT
1164 *
1165 * The file created by the routine glp_write_sol is a plain text file,
1166 * which contains the following information:
1167 *
1168 * m n
1169 * stat obj_val
1170 * r_val[1]
1171 * . . .
1172 * r_val[m]
1173 * c_val[1]
1174 * . . .
1175 * c_val[n]
1176 *
1177 * where:
1178 * m is the number of rows (auxiliary variables);
1179 * n is the number of columns (structural variables);
1180 * stat is the solution status (GLP_UNDEF = 1, GLP_FEAS = 2,
1181 * GLP_NOFEAS = 4, or GLP_OPT = 5);
1182 * obj_val is the objective value;
1183 * r_val[i], i = 1,...,m, is the value of i-th row;
1184 * c_val[j], j = 1,...,n, is the value of j-th column. */
1185
1186 int glp_write_mipcxx . . $ glp_write_mip(5aeec8fe9468a6e).(glp_probcxx . . $ glp_prob# *mip, const char *fname)
1187 { XFILEcxx . . $ XFILE# *fp;
1188 int i, j, ret = 0;
1189 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing MIP solution to `%s'...\n", fname);
1190 fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w");
1191 if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1192 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
1193 ret = 1;
1194 goto done;
1195 }
1196 /* number of rows, number of columns */
1197 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%d %d\n", mip->mcxx . . $ glp_prob#m., mip->ncxx . . $ glp_prob#n.);
1198 /* solution status, objective value */
1199 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%d %.*g\n", mip->mip_statcxx . . $ glp_prob#mip_stat., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, mip->mip_objcxx . . $ glp_prob#mip_obj.);
1200 /* rows (auxiliary variables) */
1201 for (i = 1; i <= mip->mcxx . . $ glp_prob#m.; i++)
1202 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, mip->rowcxx . . $ glp_prob#row.[i]->mipxcxx . . $ GLPROW#mipx.);
1203 /* columns (structural variables) */
1204 for (j = 1; j <= mip->ncxx . . $ glp_prob#n.; j++)
1205 xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "%.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, mip->colcxx . . $ glp_prob#col.[j]->mipxcxx . . $ GLPCOL#mipx.);
1206 xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp);
1207 if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp))
1208 { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!());
1209 ret = 1;
1210 goto done;
1211 }
1212 xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were written\n", 2 + mip->mcxx . . $ glp_prob#m. + mip->ncxx . . $ glp_prob#n.);
1213 done: if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(fp);
1214 return ret;
1215 }
1216
1217 /* eof */