| 1 | /* glpdmx.c (reading/writing data in DIMACS format) */cxx . . $ `<file>/external/glpk/glpdmx.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 | #define _GLPSTD_STDIOcxx . . $ `external/glpk/glpdmx.c:25:9`! |
| 26 | #include "glpapi.h"cxx . . $ `<file>/external/glpk/glpapi.h`/ |
| 27 | |
| 28 | struct csacxx . . $ csa# |
| 29 | { /* common storage area */ |
| 30 | jmp_bufcxx . . $ jmp_buf# jumpcxx . . $ csa#jump.; |
| 31 | /* label for go to in case of error */ |
| 32 | const char *fnamecxx . . $ csa#fname.; |
| 33 | /* name of input text file */ |
| 34 | XFILEcxx . . $ XFILE# *fpcxx . . $ csa#fp.; |
| 35 | /* stream assigned to input text file */ |
| 36 | int countcxx . . $ csa#count.; |
| 37 | /* line count */ |
| 38 | int ccxx . . $ csa#c.; |
| 39 | /* current character */ |
| 40 | char fieldcxx . . $ csa#field.[255+1]; |
| 41 | /* data field */ |
| 42 | int emptycxx . . $ csa#empty.; |
| 43 | /* warning 'empty line ignored' was printed */ |
| 44 | int nonintcxx . . $ csa#nonint.; |
| 45 | /* warning 'non-integer data detected' was printed */ |
| 46 | }; |
| 47 | |
| 48 | static void errorcxx . . $ error(e8301108646546ee).(struct csacxx . . $ csa# *csa, const char *fmt, ...) |
| 49 | { /* print error message and terminate processing */ |
| 50 | va_listcxx . . $ va_list# arg; |
| 51 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: error: ", csa->fnamecxx . . $ csa#fname., csa->countcxx . . $ csa#count.); |
| 52 | va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(arg, fmt); |
| 53 | xvprintfcxx . . $ `external/glpk/glpenv.h:149:9`!(fmt, arg); |
| 54 | va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(arg); |
| 55 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("\n"); |
| 56 | longjmpcxx . . $ longjmp(d25daf25a2f573dc).(csa->jumpcxx . . $ csa#jump., 1); |
| 57 | /* no return */ |
| 58 | } |
| 59 | |
| 60 | static void warningcxx . . $ warning(e8301108646546ee).(struct csacxx . . $ csa# *csa, const char *fmt, ...) |
| 61 | { /* print warning message and continue processing */ |
| 62 | va_listcxx . . $ va_list# arg; |
| 63 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: warning: ", csa->fnamecxx . . $ csa#fname., csa->countcxx . . $ csa#count.); |
| 64 | va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(arg, fmt); |
| 65 | xvprintfcxx . . $ `external/glpk/glpenv.h:149:9`!(fmt, arg); |
| 66 | va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(arg); |
| 67 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("\n"); |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | static void read_charcxx . . $ read_char(b530f06c2fd89229).(struct csacxx . . $ csa# *csa) |
| 72 | { /* read character from input text file */ |
| 73 | int c; |
| 74 | if (csa->ccxx . . $ csa#c. == '\n') csa->countcxx . . $ csa#count.++; |
| 75 | c = xfgetccxx . . $ `external/glpk/glpenv.h:202:9`!(csa->fpcxx . . $ csa#fp.); |
| 76 | if (c < 0) |
| 77 | { if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(csa->fpcxx . . $ csa#fp.)) |
| 78 | errorcxx . . $ error(e8301108646546ee).(csa, "read error - %s", xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 79 | else if (csa->ccxx . . $ csa#c. == '\n') |
| 80 | errorcxx . . $ error(e8301108646546ee).(csa, "unexpected end of file"); |
| 81 | else |
| 82 | { warningcxx . . $ warning(e8301108646546ee).(csa, "missing final end of line"); |
| 83 | c = '\n'; |
| 84 | } |
| 85 | } |
| 86 | else if (c == '\n') |
| 87 | ; |
| 88 | else if (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(c)) |
| 89 | c = ' '; |
| 90 | else if (iscntrlcxx . . $ `<external>/17904084882347303253/ctype.h:191:10`!(c)) |
| 91 | errorcxx . . $ error(e8301108646546ee).(csa, "invalid control character 0x%02X", c); |
| 92 | csa->ccxx . . $ csa#c. = c; |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | static void read_designatorcxx . . $ read_designator(b530f06c2fd89229).(struct csacxx . . $ csa# *csa) |
| 97 | { /* read one-character line designator */ |
| 98 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(csa->c == '\n'); |
| 99 | read_charcxx . . $ read_char(b530f06c2fd89229).(csa); |
| 100 | for (;;) |
| 101 | { /* skip preceding white-space characters */ |
| 102 | while (csa->ccxx . . $ csa#c. == ' ') |
| 103 | read_charcxx . . $ read_char(b530f06c2fd89229).(csa); |
| 104 | if (csa->ccxx . . $ csa#c. == '\n') |
| 105 | { /* ignore empty line */ |
| 106 | if (!csa->emptycxx . . $ csa#empty.) |
| 107 | { warningcxx . . $ warning(e8301108646546ee).(csa, "empty line ignored"); |
| 108 | csa->emptycxx . . $ csa#empty. = 1; |
| 109 | } |
| 110 | read_charcxx . . $ read_char(b530f06c2fd89229).(csa); |
| 111 | } |
| 112 | else if (csa->ccxx . . $ csa#c. == 'c') |
| 113 | { /* skip comment line */ |
| 114 | while (csa->ccxx . . $ csa#c. != '\n') |
| 115 | read_charcxx . . $ read_char(b530f06c2fd89229).(csa); |
| 116 | read_charcxx . . $ read_char(b530f06c2fd89229).(csa); |
| 117 | } |
| 118 | else |
| 119 | { /* hmm... looks like a line designator */ |
| 120 | csa->fieldcxx . . $ csa#field.[0] = (char)csa->ccxx . . $ csa#c., csa->fieldcxx . . $ csa#field.[1] = '\0'; |
| 121 | /* check that it is followed by a white-space character */ |
| 122 | read_charcxx . . $ read_char(b530f06c2fd89229).(csa); |
| 123 | if (!(csa->ccxx . . $ csa#c. == ' ' || csa->ccxx . . $ csa#c. == '\n')) |
| 124 | errorcxx . . $ error(e8301108646546ee).(csa, "line designator missing or invalid"); |
| 125 | break; |
| 126 | } |
| 127 | } |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | static void read_fieldcxx . . $ read_field(b530f06c2fd89229).(struct csacxx . . $ csa# *csa) |
| 132 | { /* read data field */ |
| 133 | int len = 0; |
| 134 | /* skip preceding white-space characters */ |
| 135 | while (csa->ccxx . . $ csa#c. == ' ') |
| 136 | read_charcxx . . $ read_char(b530f06c2fd89229).(csa); |
| 137 | /* scan data field */ |
| 138 | if (csa->ccxx . . $ csa#c. == '\n') |
| 139 | errorcxx . . $ error(e8301108646546ee).(csa, "unexpected end of line"); |
| 140 | while (!(csa->ccxx . . $ csa#c. == ' ' || csa->ccxx . . $ csa#c. == '\n')) |
| 141 | { if (len == sizeof(csa->fieldcxx . . $ csa#field.)-1) |
| 142 | errorcxx . . $ error(e8301108646546ee).(csa, "data field `%.15s...' too long", csa->fieldcxx . . $ csa#field.); |
| 143 | csa->fieldcxx . . $ csa#field.[len++] = (char)csa->ccxx . . $ csa#c.; |
| 144 | read_charcxx . . $ read_char(b530f06c2fd89229).(csa); |
| 145 | } |
| 146 | csa->fieldcxx . . $ csa#field.[len] = '\0'; |
| 147 | return; |
| 148 | } |
| 149 | |
| 150 | static void end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(struct csacxx . . $ csa# *csa) |
| 151 | { /* skip white-space characters until end of line */ |
| 152 | while (csa->ccxx . . $ csa#c. == ' ') |
| 153 | read_charcxx . . $ read_char(b530f06c2fd89229).(csa); |
| 154 | if (csa->ccxx . . $ csa#c. != '\n') |
| 155 | errorcxx . . $ error(e8301108646546ee).(csa, "too many data fields specified"); |
| 156 | return; |
| 157 | } |
| 158 | |
| 159 | static void check_intcxx . . $ check_int(37bb62106d376206).(struct csacxx . . $ csa# *csa, double num) |
| 160 | { /* print a warning if non-integer data are detected */ |
| 161 | if (!csa->nonintcxx . . $ csa#nonint. && num != floor(num)) |
| 162 | { warningcxx . . $ warning(e8301108646546ee).(csa, "non-integer data detected"); |
| 163 | csa->nonintcxx . . $ csa#nonint. = 1; |
| 164 | } |
| 165 | return; |
| 166 | } |
| 167 | |
| 168 | /*********************************************************************** |
| 169 | * NAME |
| 170 | * |
| 171 | * glp_read_mincost - read min-cost flow problem data in DIMACS format |
| 172 | * |
| 173 | * SYNOPSIS |
| 174 | * |
| 175 | * int glp_read_mincost(glp_graph *G, int v_rhs, int a_low, int a_cap, |
| 176 | * int a_cost, const char *fname); |
| 177 | * |
| 178 | * DESCRIPTION |
| 179 | * |
| 180 | * The routine glp_read_mincost reads minimum cost flow problem data in |
| 181 | * DIMACS format from a text file. |
| 182 | * |
| 183 | * RETURNS |
| 184 | * |
| 185 | * If the operation was successful, the routine returns zero. Otherwise |
| 186 | * it prints an error message and returns non-zero. */ |
| 187 | |
| 188 | int glp_read_mincostcxx . . $ glp_read_mincost(2a3358880b468335).(glp_graphcxx . . $ glp_graph# *G, int v_rhs, int a_low, int a_cap, |
| 189 | int a_cost, const char *fname) |
| 190 | { struct csacxx . . $ csa# _csa, *csa = &_csa; |
| 191 | glp_vertexcxx . . $ glp_vertex# *v; |
| 192 | glp_arccxx . . $ glp_arc# *a; |
| 193 | int i, j, k, nv, na, ret = 0; |
| 194 | double rhs, low, cap, cost; |
| 195 | char *flag = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 196 | if (v_rhs >= 0 && v_rhs > G->v_sizecxx . . $ _glp_graph#v_size. - (int)sizeof(double)) |
| 197 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_mincost: v_rhs = %d; invalid offset\n", |
| 198 | v_rhs); |
| 199 | if (a_low >= 0 && a_low > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 200 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_mincost: a_low = %d; invalid offset\n", |
| 201 | a_low); |
| 202 | if (a_cap >= 0 && a_cap > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 203 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_mincost: a_cap = %d; invalid offset\n", |
| 204 | a_cap); |
| 205 | if (a_cost >= 0 && a_cost > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 206 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_mincost: a_cost = %d; invalid offset\n", |
| 207 | a_cost); |
| 208 | glp_erase_graphcxx . . $ glp_erase_graph(fd6d4ec766750ee3).(G, G->v_sizecxx . . $ _glp_graph#v_size., G->a_sizecxx . . $ _glp_graph#a_size.); |
| 209 | if (setjmpcxx . . $ `<external>/4367339001007250937/setjmp.h:49:9`!(csa->jump)) |
| 210 | { ret = 1; |
| 211 | goto done; |
| 212 | } |
| 213 | csa->fnamecxx . . $ csa#fname. = fname; |
| 214 | csa->fpcxx . . $ csa#fp. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 215 | csa->countcxx . . $ csa#count. = 0; |
| 216 | csa->ccxx . . $ csa#c. = '\n'; |
| 217 | csa->fieldcxx . . $ csa#field.[0] = '\0'; |
| 218 | csa->emptycxx . . $ csa#empty. = csa->nonintcxx . . $ csa#nonint. = 0; |
| 219 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Reading min-cost flow problem data from `%s'...\n", |
| 220 | fname); |
| 221 | csa->fpcxx . . $ csa#fp. = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "r"); |
| 222 | if (csa->fpcxx . . $ csa#fp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 223 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to open `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 224 | longjmpcxx . . $ longjmp(d25daf25a2f573dc).(csa->jumpcxx . . $ csa#jump., 1); |
| 225 | } |
| 226 | /* read problem line */ |
| 227 | read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 228 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "p") != 0) |
| 229 | errorcxx . . $ error(e8301108646546ee).(csa, "problem line missing or invalid"); |
| 230 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 231 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "min") != 0) |
| 232 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong problem designator; `min' expected"); |
| 233 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 234 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &nv) == 0 && nv >= 0)) |
| 235 | errorcxx . . $ error(e8301108646546ee).(csa, "number of nodes missing or invalid"); |
| 236 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 237 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &na) == 0 && na >= 0)) |
| 238 | errorcxx . . $ error(e8301108646546ee).(csa, "number of arcs missing or invalid"); |
| 239 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Flow network has %d node%s and %d arc%s\n", |
| 240 | nv, nv == 1 ? "" : "s", na, na == 1 ? "" : "s"); |
| 241 | if (nv > 0) glp_add_verticescxx . . $ glp_add_vertices(9d5fec13eee488ca).(G, nv); |
| 242 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 243 | /* read node descriptor lines */ |
| 244 | flag = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+nv, sizeof(char)); |
| 245 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&flag[1], 0, nv * sizeof(char)); |
| 246 | if (v_rhs >= 0) |
| 247 | { rhs = 0.0; |
| 248 | for (i = 1; i <= nv; i++) |
| 249 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 250 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)v->datacxx . . $ _glp_vertex#data. + v_rhs, &rhs, sizeof(double)); |
| 251 | } |
| 252 | } |
| 253 | for (;;) |
| 254 | { read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 255 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "n") != 0) break; |
| 256 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 257 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 258 | errorcxx . . $ error(e8301108646546ee).(csa, "node number missing or invalid"); |
| 259 | if (!(1 <= i && i <= nv)) |
| 260 | errorcxx . . $ error(e8301108646546ee).(csa, "node number %d out of range", i); |
| 261 | if (flag[i]) |
| 262 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate descriptor of node %d", i); |
| 263 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 264 | if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &rhs) != 0) |
| 265 | errorcxx . . $ error(e8301108646546ee).(csa, "node supply/demand missing or invalid"); |
| 266 | check_intcxx . . $ check_int(37bb62106d376206).(csa, rhs); |
| 267 | if (v_rhs >= 0) |
| 268 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 269 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)v->datacxx . . $ _glp_vertex#data. + v_rhs, &rhs, sizeof(double)); |
| 270 | } |
| 271 | flag[i] = 1; |
| 272 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 273 | } |
| 274 | xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(flag), flag = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 275 | /* read arc descriptor lines */ |
| 276 | for (k = 1; k <= na; k++) |
| 277 | { if (k > 1) read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 278 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "a") != 0) |
| 279 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong line designator; `a' expected"); |
| 280 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 281 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 282 | errorcxx . . $ error(e8301108646546ee).(csa, "starting node number missing or invalid"); |
| 283 | if (!(1 <= i && i <= nv)) |
| 284 | errorcxx . . $ error(e8301108646546ee).(csa, "starting node number %d out of range", i); |
| 285 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 286 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &j) != 0) |
| 287 | errorcxx . . $ error(e8301108646546ee).(csa, "ending node number missing or invalid"); |
| 288 | if (!(1 <= j && j <= nv)) |
| 289 | errorcxx . . $ error(e8301108646546ee).(csa, "ending node number %d out of range", j); |
| 290 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 291 | if (!(str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &low) == 0 && low >= 0.0)) |
| 292 | errorcxx . . $ error(e8301108646546ee).(csa, "lower bound of arc flow missing or invalid"); |
| 293 | check_intcxx . . $ check_int(37bb62106d376206).(csa, low); |
| 294 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 295 | if (!(str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &cap) == 0 && cap >= low)) |
| 296 | errorcxx . . $ error(e8301108646546ee).(csa, "upper bound of arc flow missing or invalid"); |
| 297 | check_intcxx . . $ check_int(37bb62106d376206).(csa, cap); |
| 298 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 299 | if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &cost) != 0) |
| 300 | errorcxx . . $ error(e8301108646546ee).(csa, "per-unit cost of arc flow missing or invalid"); |
| 301 | check_intcxx . . $ check_int(37bb62106d376206).(csa, cost); |
| 302 | a = glp_add_arccxx . . $ glp_add_arc(e54dd140876db879).(G, i, j); |
| 303 | if (a_low >= 0) |
| 304 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)a->datacxx . . $ _glp_arc#data. + a_low, &low, sizeof(double)); |
| 305 | if (a_cap >= 0) |
| 306 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)a->datacxx . . $ _glp_arc#data. + a_cap, &cap, sizeof(double)); |
| 307 | if (a_cost >= 0) |
| 308 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)a->datacxx . . $ _glp_arc#data. + a_cost, &cost, sizeof(double)); |
| 309 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 310 | } |
| 311 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were read\n", csa->countcxx . . $ csa#count.); |
| 312 | done: if (ret) glp_erase_graphcxx . . $ glp_erase_graph(fd6d4ec766750ee3).(G, G->v_sizecxx . . $ _glp_graph#v_size., G->a_sizecxx . . $ _glp_graph#a_size.); |
| 313 | if (csa->fpcxx . . $ csa#fp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(csa->fpcxx . . $ csa#fp.); |
| 314 | if (flag != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(flag); |
| 315 | return ret; |
| 316 | } |
| 317 | |
| 318 | /*********************************************************************** |
| 319 | * NAME |
| 320 | * |
| 321 | * glp_write_mincost - write min-cost flow problem data in DIMACS format |
| 322 | * |
| 323 | * SYNOPSIS |
| 324 | * |
| 325 | * int glp_write_mincost(glp_graph *G, int v_rhs, int a_low, int a_cap, |
| 326 | * int a_cost, const char *fname); |
| 327 | * |
| 328 | * DESCRIPTION |
| 329 | * |
| 330 | * The routine glp_write_mincost writes minimum cost flow problem data |
| 331 | * in DIMACS format to a text file. |
| 332 | * |
| 333 | * RETURNS |
| 334 | * |
| 335 | * If the operation was successful, the routine returns zero. Otherwise |
| 336 | * it prints an error message and returns non-zero. */ |
| 337 | |
| 338 | int glp_write_mincostcxx . . $ glp_write_mincost(2a3358880b468335).(glp_graphcxx . . $ glp_graph# *G, int v_rhs, int a_low, int a_cap, |
| 339 | int a_cost, const char *fname) |
| 340 | { XFILEcxx . . $ XFILE# *fp; |
| 341 | glp_vertexcxx . . $ glp_vertex# *v; |
| 342 | glp_arccxx . . $ glp_arc# *a; |
| 343 | int i, count = 0, ret; |
| 344 | double rhs, low, cap, cost; |
| 345 | if (v_rhs >= 0 && v_rhs > G->v_sizecxx . . $ _glp_graph#v_size. - (int)sizeof(double)) |
| 346 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_mincost: v_rhs = %d; invalid offset\n", |
| 347 | v_rhs); |
| 348 | if (a_low >= 0 && a_low > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 349 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_mincost: a_low = %d; invalid offset\n", |
| 350 | a_low); |
| 351 | if (a_cap >= 0 && a_cap > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 352 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_mincost: a_cap = %d; invalid offset\n", |
| 353 | a_cap); |
| 354 | if (a_cost >= 0 && a_cost > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 355 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_mincost: a_cost = %d; invalid offset\n", |
| 356 | a_cost); |
| 357 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing min-cost flow problem data to `%s'...\n", |
| 358 | fname); |
| 359 | fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w"); |
| 360 | if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 361 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 362 | ret = 1; |
| 363 | goto done; |
| 364 | } |
| 365 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "c %s\n", |
| 366 | G->namecxx . . $ _glp_graph#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "unknown" : G->namecxx . . $ _glp_graph#name.), count++; |
| 367 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "p min %d %d\n", G->nvcxx . . $ _glp_graph#nv., G->nacxx . . $ _glp_graph#na.), count++; |
| 368 | if (v_rhs >= 0) |
| 369 | { for (i = 1; i <= G->nvcxx . . $ _glp_graph#nv.; i++) |
| 370 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 371 | memcpycxx . . $ memcpy(cc817cb175f282d).(&rhs, (char *)v->datacxx . . $ _glp_vertex#data. + v_rhs, sizeof(double)); |
| 372 | if (rhs != 0.0) |
| 373 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "n %d %.*g\n", i, DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, rhs), count++; |
| 374 | } |
| 375 | } |
| 376 | for (i = 1; i <= G->nvcxx . . $ _glp_graph#nv.; i++) |
| 377 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 378 | for (a = v->outcxx . . $ _glp_vertex#out.; a != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; a = a->t_nextcxx . . $ _glp_arc#t_next.) |
| 379 | { if (a_low >= 0) |
| 380 | memcpycxx . . $ memcpy(cc817cb175f282d).(&low, (char *)a->datacxx . . $ _glp_arc#data. + a_low, sizeof(double)); |
| 381 | else |
| 382 | low = 0.0; |
| 383 | if (a_cap >= 0) |
| 384 | memcpycxx . . $ memcpy(cc817cb175f282d).(&cap, (char *)a->datacxx . . $ _glp_arc#data. + a_cap, sizeof(double)); |
| 385 | else |
| 386 | cap = 1.0; |
| 387 | if (a_cost >= 0) |
| 388 | memcpycxx . . $ memcpy(cc817cb175f282d).(&cost, (char *)a->datacxx . . $ _glp_arc#data. + a_cost, sizeof(double)); |
| 389 | else |
| 390 | cost = 0.0; |
| 391 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "a %d %d %.*g %.*g %.*g\n", |
| 392 | a->tailcxx . . $ _glp_arc#tail.->icxx . . $ _glp_vertex#i., a->headcxx . . $ _glp_arc#head.->icxx . . $ _glp_vertex#i., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, low, DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, cap, |
| 393 | DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, cost), count++; |
| 394 | } |
| 395 | } |
| 396 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "c eof\n"), count++; |
| 397 | xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp); |
| 398 | if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp)) |
| 399 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 400 | ret = 1; |
| 401 | goto done; |
| 402 | } |
| 403 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were written\n", count); |
| 404 | ret = 0; |
| 405 | 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); |
| 406 | return ret; |
| 407 | } |
| 408 | |
| 409 | /*********************************************************************** |
| 410 | * NAME |
| 411 | * |
| 412 | * glp_read_maxflow - read maximum flow problem data in DIMACS format |
| 413 | * |
| 414 | * SYNOPSIS |
| 415 | * |
| 416 | * int glp_read_maxflow(glp_graph *G, int *s, int *t, int a_cap, |
| 417 | * const char *fname); |
| 418 | * |
| 419 | * DESCRIPTION |
| 420 | * |
| 421 | * The routine glp_read_maxflow reads maximum flow problem data in |
| 422 | * DIMACS format from a text file. |
| 423 | * |
| 424 | * RETURNS |
| 425 | * |
| 426 | * If the operation was successful, the routine returns zero. Otherwise |
| 427 | * it prints an error message and returns non-zero. */ |
| 428 | |
| 429 | int glp_read_maxflowcxx . . $ glp_read_maxflow(e06dd7c07f5e0cde).(glp_graphcxx . . $ glp_graph# *G, int *_s, int *_t, int a_cap, |
| 430 | const char *fname) |
| 431 | { struct csacxx . . $ csa# _csa, *csa = &_csa; |
| 432 | glp_arccxx . . $ glp_arc# *a; |
| 433 | int i, j, k, s, t, nv, na, ret = 0; |
| 434 | double cap; |
| 435 | if (a_cap >= 0 && a_cap > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 436 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_maxflow: a_cap = %d; invalid offset\n", |
| 437 | a_cap); |
| 438 | glp_erase_graphcxx . . $ glp_erase_graph(fd6d4ec766750ee3).(G, G->v_sizecxx . . $ _glp_graph#v_size., G->a_sizecxx . . $ _glp_graph#a_size.); |
| 439 | if (setjmpcxx . . $ `<external>/4367339001007250937/setjmp.h:49:9`!(csa->jump)) |
| 440 | { ret = 1; |
| 441 | goto done; |
| 442 | } |
| 443 | csa->fnamecxx . . $ csa#fname. = fname; |
| 444 | csa->fpcxx . . $ csa#fp. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 445 | csa->countcxx . . $ csa#count. = 0; |
| 446 | csa->ccxx . . $ csa#c. = '\n'; |
| 447 | csa->fieldcxx . . $ csa#field.[0] = '\0'; |
| 448 | csa->emptycxx . . $ csa#empty. = csa->nonintcxx . . $ csa#nonint. = 0; |
| 449 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Reading maximum flow problem data from `%s'...\n", |
| 450 | fname); |
| 451 | csa->fpcxx . . $ csa#fp. = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "r"); |
| 452 | if (csa->fpcxx . . $ csa#fp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 453 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to open `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 454 | longjmpcxx . . $ longjmp(d25daf25a2f573dc).(csa->jumpcxx . . $ csa#jump., 1); |
| 455 | } |
| 456 | /* read problem line */ |
| 457 | read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 458 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "p") != 0) |
| 459 | errorcxx . . $ error(e8301108646546ee).(csa, "problem line missing or invalid"); |
| 460 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 461 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "max") != 0) |
| 462 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong problem designator; `max' expected"); |
| 463 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 464 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &nv) == 0 && nv >= 2)) |
| 465 | errorcxx . . $ error(e8301108646546ee).(csa, "number of nodes missing or invalid"); |
| 466 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 467 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &na) == 0 && na >= 0)) |
| 468 | errorcxx . . $ error(e8301108646546ee).(csa, "number of arcs missing or invalid"); |
| 469 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Flow network has %d node%s and %d arc%s\n", |
| 470 | nv, nv == 1 ? "" : "s", na, na == 1 ? "" : "s"); |
| 471 | if (nv > 0) glp_add_verticescxx . . $ glp_add_vertices(9d5fec13eee488ca).(G, nv); |
| 472 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 473 | /* read node descriptor lines */ |
| 474 | s = t = 0; |
| 475 | for (;;) |
| 476 | { read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 477 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "n") != 0) break; |
| 478 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 479 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 480 | errorcxx . . $ error(e8301108646546ee).(csa, "node number missing or invalid"); |
| 481 | if (!(1 <= i && i <= nv)) |
| 482 | errorcxx . . $ error(e8301108646546ee).(csa, "node number %d out of range", i); |
| 483 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 484 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "s") == 0) |
| 485 | { if (s > 0) |
| 486 | errorcxx . . $ error(e8301108646546ee).(csa, "only one source node allowed"); |
| 487 | s = i; |
| 488 | } |
| 489 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "t") == 0) |
| 490 | { if (t > 0) |
| 491 | errorcxx . . $ error(e8301108646546ee).(csa, "only one sink node allowed"); |
| 492 | t = i; |
| 493 | } |
| 494 | else |
| 495 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong node designator; `s' or `t' expected"); |
| 496 | if (s > 0 && s == t) |
| 497 | errorcxx . . $ error(e8301108646546ee).(csa, "source and sink nodes must be distinct"); |
| 498 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 499 | } |
| 500 | if (s == 0) |
| 501 | errorcxx . . $ error(e8301108646546ee).(csa, "source node descriptor missing\n"); |
| 502 | if (t == 0) |
| 503 | errorcxx . . $ error(e8301108646546ee).(csa, "sink node descriptor missing\n"); |
| 504 | if (_s != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) *_s = s; |
| 505 | if (_t != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) *_t = t; |
| 506 | /* read arc descriptor lines */ |
| 507 | for (k = 1; k <= na; k++) |
| 508 | { if (k > 1) read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 509 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "a") != 0) |
| 510 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong line designator; `a' expected"); |
| 511 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 512 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 513 | errorcxx . . $ error(e8301108646546ee).(csa, "starting node number missing or invalid"); |
| 514 | if (!(1 <= i && i <= nv)) |
| 515 | errorcxx . . $ error(e8301108646546ee).(csa, "starting node number %d out of range", i); |
| 516 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 517 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &j) != 0) |
| 518 | errorcxx . . $ error(e8301108646546ee).(csa, "ending node number missing or invalid"); |
| 519 | if (!(1 <= j && j <= nv)) |
| 520 | errorcxx . . $ error(e8301108646546ee).(csa, "ending node number %d out of range", j); |
| 521 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 522 | if (!(str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &cap) == 0 && cap >= 0.0)) |
| 523 | errorcxx . . $ error(e8301108646546ee).(csa, "arc capacity missing or invalid"); |
| 524 | check_intcxx . . $ check_int(37bb62106d376206).(csa, cap); |
| 525 | a = glp_add_arccxx . . $ glp_add_arc(e54dd140876db879).(G, i, j); |
| 526 | if (a_cap >= 0) |
| 527 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)a->datacxx . . $ _glp_arc#data. + a_cap, &cap, sizeof(double)); |
| 528 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 529 | } |
| 530 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were read\n", csa->countcxx . . $ csa#count.); |
| 531 | done: if (ret) glp_erase_graphcxx . . $ glp_erase_graph(fd6d4ec766750ee3).(G, G->v_sizecxx . . $ _glp_graph#v_size., G->a_sizecxx . . $ _glp_graph#a_size.); |
| 532 | if (csa->fpcxx . . $ csa#fp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(csa->fpcxx . . $ csa#fp.); |
| 533 | return ret; |
| 534 | } |
| 535 | |
| 536 | /*********************************************************************** |
| 537 | * NAME |
| 538 | * |
| 539 | * glp_write_maxflow - write maximum flow problem data in DIMACS format |
| 540 | * |
| 541 | * SYNOPSIS |
| 542 | * |
| 543 | * int glp_write_maxflow(glp_graph *G, int s, int t, int a_cap, |
| 544 | * const char *fname); |
| 545 | * |
| 546 | * DESCRIPTION |
| 547 | * |
| 548 | * The routine glp_write_maxflow writes maximum flow problem data in |
| 549 | * DIMACS format to a text file. |
| 550 | * |
| 551 | * RETURNS |
| 552 | * |
| 553 | * If the operation was successful, the routine returns zero. Otherwise |
| 554 | * it prints an error message and returns non-zero. */ |
| 555 | |
| 556 | int glp_write_maxflowcxx . . $ glp_write_maxflow(6a1d08e0412ded79).(glp_graphcxx . . $ glp_graph# *G, int s, int t, int a_cap, |
| 557 | const char *fname) |
| 558 | { XFILEcxx . . $ XFILE# *fp; |
| 559 | glp_vertexcxx . . $ glp_vertex# *v; |
| 560 | glp_arccxx . . $ glp_arc# *a; |
| 561 | int i, count = 0, ret; |
| 562 | double cap; |
| 563 | if (!(1 <= s && s <= G->nvcxx . . $ _glp_graph#nv.)) |
| 564 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_maxflow: s = %d; source node number out of r" |
| 565 | "ange\n", s); |
| 566 | if (!(1 <= t && t <= G->nvcxx . . $ _glp_graph#nv.)) |
| 567 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_maxflow: t = %d: sink node number out of ran" |
| 568 | "ge\n", t); |
| 569 | if (a_cap >= 0 && a_cap > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 570 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_mincost: a_cap = %d; invalid offset\n", |
| 571 | a_cap); |
| 572 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing maximum flow problem data to `%s'...\n", |
| 573 | fname); |
| 574 | fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w"); |
| 575 | if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 576 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 577 | ret = 1; |
| 578 | goto done; |
| 579 | } |
| 580 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "c %s\n", |
| 581 | G->namecxx . . $ _glp_graph#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "unknown" : G->namecxx . . $ _glp_graph#name.), count++; |
| 582 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "p max %d %d\n", G->nvcxx . . $ _glp_graph#nv., G->nacxx . . $ _glp_graph#na.), count++; |
| 583 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "n %d s\n", s), count++; |
| 584 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "n %d t\n", t), count++; |
| 585 | for (i = 1; i <= G->nvcxx . . $ _glp_graph#nv.; i++) |
| 586 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 587 | for (a = v->outcxx . . $ _glp_vertex#out.; a != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; a = a->t_nextcxx . . $ _glp_arc#t_next.) |
| 588 | { if (a_cap >= 0) |
| 589 | memcpycxx . . $ memcpy(cc817cb175f282d).(&cap, (char *)a->datacxx . . $ _glp_arc#data. + a_cap, sizeof(double)); |
| 590 | else |
| 591 | cap = 1.0; |
| 592 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "a %d %d %.*g\n", |
| 593 | a->tailcxx . . $ _glp_arc#tail.->icxx . . $ _glp_vertex#i., a->headcxx . . $ _glp_arc#head.->icxx . . $ _glp_vertex#i., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, cap), count++; |
| 594 | } |
| 595 | } |
| 596 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "c eof\n"), count++; |
| 597 | xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp); |
| 598 | if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp)) |
| 599 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 600 | ret = 1; |
| 601 | goto done; |
| 602 | } |
| 603 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were written\n", count); |
| 604 | ret = 0; |
| 605 | 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); |
| 606 | return ret; |
| 607 | } |
| 608 | |
| 609 | /*********************************************************************** |
| 610 | * NAME |
| 611 | * |
| 612 | * glp_read_asnprob - read assignment problem data in DIMACS format |
| 613 | * |
| 614 | * SYNOPSIS |
| 615 | * |
| 616 | * int glp_read_asnprob(glp_graph *G, int v_set, int a_cost, |
| 617 | * const char *fname); |
| 618 | * |
| 619 | * DESCRIPTION |
| 620 | * |
| 621 | * The routine glp_read_asnprob reads assignment problem data in DIMACS |
| 622 | * format from a text file. |
| 623 | * |
| 624 | * RETURNS |
| 625 | * |
| 626 | * If the operation was successful, the routine returns zero. Otherwise |
| 627 | * it prints an error message and returns non-zero. */ |
| 628 | |
| 629 | int glp_read_asnprobcxx . . $ glp_read_asnprob(33d52c0e6e8cedaa).(glp_graphcxx . . $ glp_graph# *G, int v_set, int a_cost, const char |
| 630 | *fname) |
| 631 | { struct csacxx . . $ csa# _csa, *csa = &_csa; |
| 632 | glp_vertexcxx . . $ glp_vertex# *v; |
| 633 | glp_arccxx . . $ glp_arc# *a; |
| 634 | int nv, na, n1, i, j, k, ret = 0; |
| 635 | double cost; |
| 636 | char *flag = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 637 | if (v_set >= 0 && v_set > G->v_sizecxx . . $ _glp_graph#v_size. - (int)sizeof(int)) |
| 638 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_asnprob: v_set = %d; invalid offset\n", |
| 639 | v_set); |
| 640 | if (a_cost >= 0 && a_cost > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 641 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_asnprob: a_cost = %d; invalid offset\n", |
| 642 | a_cost); |
| 643 | glp_erase_graphcxx . . $ glp_erase_graph(fd6d4ec766750ee3).(G, G->v_sizecxx . . $ _glp_graph#v_size., G->a_sizecxx . . $ _glp_graph#a_size.); |
| 644 | if (setjmpcxx . . $ `<external>/4367339001007250937/setjmp.h:49:9`!(csa->jump)) |
| 645 | { ret = 1; |
| 646 | goto done; |
| 647 | } |
| 648 | csa->fnamecxx . . $ csa#fname. = fname; |
| 649 | csa->fpcxx . . $ csa#fp. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 650 | csa->countcxx . . $ csa#count. = 0; |
| 651 | csa->ccxx . . $ csa#c. = '\n'; |
| 652 | csa->fieldcxx . . $ csa#field.[0] = '\0'; |
| 653 | csa->emptycxx . . $ csa#empty. = csa->nonintcxx . . $ csa#nonint. = 0; |
| 654 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Reading assignment problem data from `%s'...\n", fname); |
| 655 | csa->fpcxx . . $ csa#fp. = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "r"); |
| 656 | if (csa->fpcxx . . $ csa#fp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 657 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to open `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 658 | longjmpcxx . . $ longjmp(d25daf25a2f573dc).(csa->jumpcxx . . $ csa#jump., 1); |
| 659 | } |
| 660 | /* read problem line */ |
| 661 | read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 662 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "p") != 0) |
| 663 | errorcxx . . $ error(e8301108646546ee).(csa, "problem line missing or invalid"); |
| 664 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 665 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "asn") != 0) |
| 666 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong problem designator; `asn' expected"); |
| 667 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 668 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &nv) == 0 && nv >= 0)) |
| 669 | errorcxx . . $ error(e8301108646546ee).(csa, "number of nodes missing or invalid"); |
| 670 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 671 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &na) == 0 && na >= 0)) |
| 672 | errorcxx . . $ error(e8301108646546ee).(csa, "number of arcs missing or invalid"); |
| 673 | if (nv > 0) glp_add_verticescxx . . $ glp_add_vertices(9d5fec13eee488ca).(G, nv); |
| 674 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 675 | /* read node descriptor lines */ |
| 676 | flag = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+nv, sizeof(char)); |
| 677 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&flag[1], 0, nv * sizeof(char)); |
| 678 | n1 = 0; |
| 679 | for (;;) |
| 680 | { read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 681 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "n") != 0) break; |
| 682 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 683 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 684 | errorcxx . . $ error(e8301108646546ee).(csa, "node number missing or invalid"); |
| 685 | if (!(1 <= i && i <= nv)) |
| 686 | errorcxx . . $ error(e8301108646546ee).(csa, "node number %d out of range", i); |
| 687 | if (flag[i]) |
| 688 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate descriptor of node %d", i); |
| 689 | flag[i] = 1, n1++; |
| 690 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 691 | } |
| 692 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!( |
| 693 | "Assignment problem has %d + %d = %d node%s and %d arc%s\n", |
| 694 | n1, nv - n1, nv, nv == 1 ? "" : "s", na, na == 1 ? "" : "s"); |
| 695 | if (v_set >= 0) |
| 696 | { for (i = 1; i <= nv; i++) |
| 697 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 698 | k = (flag[i] ? 0 : 1); |
| 699 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)v->datacxx . . $ _glp_vertex#data. + v_set, &k, sizeof(int)); |
| 700 | } |
| 701 | } |
| 702 | /* read arc descriptor lines */ |
| 703 | for (k = 1; k <= na; k++) |
| 704 | { if (k > 1) read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 705 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "a") != 0) |
| 706 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong line designator; `a' expected"); |
| 707 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 708 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 709 | errorcxx . . $ error(e8301108646546ee).(csa, "starting node number missing or invalid"); |
| 710 | if (!(1 <= i && i <= nv)) |
| 711 | errorcxx . . $ error(e8301108646546ee).(csa, "starting node number %d out of range", i); |
| 712 | if (!flag[i]) |
| 713 | errorcxx . . $ error(e8301108646546ee).(csa, "node %d cannot be a starting node", i); |
| 714 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 715 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &j) != 0) |
| 716 | errorcxx . . $ error(e8301108646546ee).(csa, "ending node number missing or invalid"); |
| 717 | if (!(1 <= j && j <= nv)) |
| 718 | errorcxx . . $ error(e8301108646546ee).(csa, "ending node number %d out of range", j); |
| 719 | if (flag[j]) |
| 720 | errorcxx . . $ error(e8301108646546ee).(csa, "node %d cannot be an ending node", j); |
| 721 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 722 | if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &cost) != 0) |
| 723 | errorcxx . . $ error(e8301108646546ee).(csa, "arc cost missing or invalid"); |
| 724 | check_intcxx . . $ check_int(37bb62106d376206).(csa, cost); |
| 725 | a = glp_add_arccxx . . $ glp_add_arc(e54dd140876db879).(G, i, j); |
| 726 | if (a_cost >= 0) |
| 727 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)a->datacxx . . $ _glp_arc#data. + a_cost, &cost, sizeof(double)); |
| 728 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 729 | } |
| 730 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were read\n", csa->countcxx . . $ csa#count.); |
| 731 | done: if (ret) glp_erase_graphcxx . . $ glp_erase_graph(fd6d4ec766750ee3).(G, G->v_sizecxx . . $ _glp_graph#v_size., G->a_sizecxx . . $ _glp_graph#a_size.); |
| 732 | if (csa->fpcxx . . $ csa#fp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(csa->fpcxx . . $ csa#fp.); |
| 733 | if (flag != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(flag); |
| 734 | return ret; |
| 735 | } |
| 736 | |
| 737 | /*********************************************************************** |
| 738 | * NAME |
| 739 | * |
| 740 | * glp_write_asnprob - write assignment problem data in DIMACS format |
| 741 | * |
| 742 | * SYNOPSIS |
| 743 | * |
| 744 | * int glp_write_asnprob(glp_graph *G, int v_set, int a_cost, |
| 745 | * const char *fname); |
| 746 | * |
| 747 | * DESCRIPTION |
| 748 | * |
| 749 | * The routine glp_write_asnprob writes assignment problem data in |
| 750 | * DIMACS format to a text file. |
| 751 | * |
| 752 | * RETURNS |
| 753 | * |
| 754 | * If the operation was successful, the routine returns zero. Otherwise |
| 755 | * it prints an error message and returns non-zero. */ |
| 756 | |
| 757 | int glp_write_asnprobcxx . . $ glp_write_asnprob(33d52c0e6e8cedaa).(glp_graphcxx . . $ glp_graph# *G, int v_set, int a_cost, const char |
| 758 | *fname) |
| 759 | { XFILEcxx . . $ XFILE# *fp; |
| 760 | glp_vertexcxx . . $ glp_vertex# *v; |
| 761 | glp_arccxx . . $ glp_arc# *a; |
| 762 | int i, k, count = 0, ret; |
| 763 | double cost; |
| 764 | if (v_set >= 0 && v_set > G->v_sizecxx . . $ _glp_graph#v_size. - (int)sizeof(int)) |
| 765 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_asnprob: v_set = %d; invalid offset\n", |
| 766 | v_set); |
| 767 | if (a_cost >= 0 && a_cost > G->a_sizecxx . . $ _glp_graph#a_size. - (int)sizeof(double)) |
| 768 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_asnprob: a_cost = %d; invalid offset\n", |
| 769 | a_cost); |
| 770 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing assignment problem data to `%s'...\n", fname); |
| 771 | fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w"); |
| 772 | if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 773 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 774 | ret = 1; |
| 775 | goto done; |
| 776 | } |
| 777 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "c %s\n", |
| 778 | G->namecxx . . $ _glp_graph#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "unknown" : G->namecxx . . $ _glp_graph#name.), count++; |
| 779 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "p asn %d %d\n", G->nvcxx . . $ _glp_graph#nv., G->nacxx . . $ _glp_graph#na.), count++; |
| 780 | for (i = 1; i <= G->nvcxx . . $ _glp_graph#nv.; i++) |
| 781 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 782 | if (v_set >= 0) |
| 783 | memcpycxx . . $ memcpy(cc817cb175f282d).(&k, (char *)v->datacxx . . $ _glp_vertex#data. + v_set, sizeof(int)); |
| 784 | else |
| 785 | k = (v->outcxx . . $ _glp_vertex#out. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? 0 : 1); |
| 786 | if (k == 0) |
| 787 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "n %d\n", i), count++; |
| 788 | } |
| 789 | for (i = 1; i <= G->nvcxx . . $ _glp_graph#nv.; i++) |
| 790 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 791 | for (a = v->outcxx . . $ _glp_vertex#out.; a != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; a = a->t_nextcxx . . $ _glp_arc#t_next.) |
| 792 | { if (a_cost >= 0) |
| 793 | memcpycxx . . $ memcpy(cc817cb175f282d).(&cost, (char *)a->datacxx . . $ _glp_arc#data. + a_cost, sizeof(double)); |
| 794 | else |
| 795 | cost = 1.0; |
| 796 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "a %d %d %.*g\n", |
| 797 | a->tailcxx . . $ _glp_arc#tail.->icxx . . $ _glp_vertex#i., a->headcxx . . $ _glp_arc#head.->icxx . . $ _glp_vertex#i., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, cost), count++; |
| 798 | } |
| 799 | } |
| 800 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "c eof\n"), count++; |
| 801 | xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp); |
| 802 | if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp)) |
| 803 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 804 | ret = 1; |
| 805 | goto done; |
| 806 | } |
| 807 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were written\n", count); |
| 808 | ret = 0; |
| 809 | 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); |
| 810 | return ret; |
| 811 | } |
| 812 | |
| 813 | /*********************************************************************** |
| 814 | * NAME |
| 815 | * |
| 816 | * glp_read_ccdata - read graph in DIMACS clique/coloring format |
| 817 | * |
| 818 | * SYNOPSIS |
| 819 | * |
| 820 | * int glp_read_ccdata(glp_graph *G, int v_wgt, const char *fname); |
| 821 | * |
| 822 | * DESCRIPTION |
| 823 | * |
| 824 | * The routine glp_read_ccdata reads an (undirected) graph in DIMACS |
| 825 | * clique/coloring format from a text file. |
| 826 | * |
| 827 | * RETURNS |
| 828 | * |
| 829 | * If the operation was successful, the routine returns zero. Otherwise |
| 830 | * it prints an error message and returns non-zero. */ |
| 831 | |
| 832 | int glp_read_ccdatacxx . . $ glp_read_ccdata(4c671af078c78925).(glp_graphcxx . . $ glp_graph# *G, int v_wgt, const char *fname) |
| 833 | { struct csacxx . . $ csa# _csa, *csa = &_csa; |
| 834 | glp_vertexcxx . . $ glp_vertex# *v; |
| 835 | int i, j, k, nv, ne, ret = 0; |
| 836 | double w; |
| 837 | char *flag = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 838 | if (v_wgt >= 0 && v_wgt > G->v_sizecxx . . $ _glp_graph#v_size. - (int)sizeof(double)) |
| 839 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_ccdata: v_wgt = %d; invalid offset\n", |
| 840 | v_wgt); |
| 841 | glp_erase_graphcxx . . $ glp_erase_graph(fd6d4ec766750ee3).(G, G->v_sizecxx . . $ _glp_graph#v_size., G->a_sizecxx . . $ _glp_graph#a_size.); |
| 842 | if (setjmpcxx . . $ `<external>/4367339001007250937/setjmp.h:49:9`!(csa->jump)) |
| 843 | { ret = 1; |
| 844 | goto done; |
| 845 | } |
| 846 | csa->fnamecxx . . $ csa#fname. = fname; |
| 847 | csa->fpcxx . . $ csa#fp. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 848 | csa->countcxx . . $ csa#count. = 0; |
| 849 | csa->ccxx . . $ csa#c. = '\n'; |
| 850 | csa->fieldcxx . . $ csa#field.[0] = '\0'; |
| 851 | csa->emptycxx . . $ csa#empty. = csa->nonintcxx . . $ csa#nonint. = 0; |
| 852 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Reading graph from `%s'...\n", fname); |
| 853 | csa->fpcxx . . $ csa#fp. = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "r"); |
| 854 | if (csa->fpcxx . . $ csa#fp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 855 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to open `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 856 | longjmpcxx . . $ longjmp(d25daf25a2f573dc).(csa->jumpcxx . . $ csa#jump., 1); |
| 857 | } |
| 858 | /* read problem line */ |
| 859 | read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 860 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "p") != 0) |
| 861 | errorcxx . . $ error(e8301108646546ee).(csa, "problem line missing or invalid"); |
| 862 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 863 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "edge") != 0) |
| 864 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong problem designator; `edge' expected"); |
| 865 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 866 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &nv) == 0 && nv >= 0)) |
| 867 | errorcxx . . $ error(e8301108646546ee).(csa, "number of vertices missing or invalid"); |
| 868 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 869 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &ne) == 0 && ne >= 0)) |
| 870 | errorcxx . . $ error(e8301108646546ee).(csa, "number of edges missing or invalid"); |
| 871 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Graph has %d vert%s and %d edge%s\n", |
| 872 | nv, nv == 1 ? "ex" : "ices", ne, ne == 1 ? "" : "s"); |
| 873 | if (nv > 0) glp_add_verticescxx . . $ glp_add_vertices(9d5fec13eee488ca).(G, nv); |
| 874 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 875 | /* read node descriptor lines */ |
| 876 | flag = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+nv, sizeof(char)); |
| 877 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&flag[1], 0, nv * sizeof(char)); |
| 878 | if (v_wgt >= 0) |
| 879 | { w = 1.0; |
| 880 | for (i = 1; i <= nv; i++) |
| 881 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 882 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)v->datacxx . . $ _glp_vertex#data. + v_wgt, &w, sizeof(double)); |
| 883 | } |
| 884 | } |
| 885 | for (;;) |
| 886 | { read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 887 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "n") != 0) break; |
| 888 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 889 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 890 | errorcxx . . $ error(e8301108646546ee).(csa, "vertex number missing or invalid"); |
| 891 | if (!(1 <= i && i <= nv)) |
| 892 | errorcxx . . $ error(e8301108646546ee).(csa, "vertex number %d out of range", i); |
| 893 | if (flag[i]) |
| 894 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate descriptor of vertex %d", i); |
| 895 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 896 | if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &w) != 0) |
| 897 | errorcxx . . $ error(e8301108646546ee).(csa, "vertex weight missing or invalid"); |
| 898 | check_intcxx . . $ check_int(37bb62106d376206).(csa, w); |
| 899 | if (v_wgt >= 0) |
| 900 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 901 | memcpycxx . . $ memcpy(cc817cb175f282d).((char *)v->datacxx . . $ _glp_vertex#data. + v_wgt, &w, sizeof(double)); |
| 902 | } |
| 903 | flag[i] = 1; |
| 904 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 905 | } |
| 906 | xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(flag), flag = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 907 | /* read edge descriptor lines */ |
| 908 | for (k = 1; k <= ne; k++) |
| 909 | { if (k > 1) read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 910 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "e") != 0) |
| 911 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong line designator; `e' expected"); |
| 912 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 913 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 914 | errorcxx . . $ error(e8301108646546ee).(csa, "first vertex number missing or invalid"); |
| 915 | if (!(1 <= i && i <= nv)) |
| 916 | errorcxx . . $ error(e8301108646546ee).(csa, "first vertex number %d out of range", i); |
| 917 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 918 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &j) != 0) |
| 919 | errorcxx . . $ error(e8301108646546ee).(csa, "second vertex number missing or invalid"); |
| 920 | if (!(1 <= j && j <= nv)) |
| 921 | errorcxx . . $ error(e8301108646546ee).(csa, "second vertex number %d out of range", j); |
| 922 | glp_add_arccxx . . $ glp_add_arc(e54dd140876db879).(G, i, j); |
| 923 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 924 | } |
| 925 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were read\n", csa->countcxx . . $ csa#count.); |
| 926 | done: if (ret) glp_erase_graphcxx . . $ glp_erase_graph(fd6d4ec766750ee3).(G, G->v_sizecxx . . $ _glp_graph#v_size., G->a_sizecxx . . $ _glp_graph#a_size.); |
| 927 | if (csa->fpcxx . . $ csa#fp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(csa->fpcxx . . $ csa#fp.); |
| 928 | if (flag != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(flag); |
| 929 | return ret; |
| 930 | } |
| 931 | |
| 932 | /*********************************************************************** |
| 933 | * NAME |
| 934 | * |
| 935 | * glp_write_ccdata - write graph in DIMACS clique/coloring format |
| 936 | * |
| 937 | * SYNOPSIS |
| 938 | * |
| 939 | * int glp_write_ccdata(glp_graph *G, int v_wgt, const char *fname); |
| 940 | * |
| 941 | * DESCRIPTION |
| 942 | * |
| 943 | * The routine glp_write_ccdata writes the specified graph in DIMACS |
| 944 | * clique/coloring format to a text file. |
| 945 | * |
| 946 | * RETURNS |
| 947 | * |
| 948 | * If the operation was successful, the routine returns zero. Otherwise |
| 949 | * it prints an error message and returns non-zero. */ |
| 950 | |
| 951 | int glp_write_ccdatacxx . . $ glp_write_ccdata(4c671af078c78925).(glp_graphcxx . . $ glp_graph# *G, int v_wgt, const char *fname) |
| 952 | { XFILEcxx . . $ XFILE# *fp; |
| 953 | glp_vertexcxx . . $ glp_vertex# *v; |
| 954 | glp_arccxx . . $ glp_arc# *e; |
| 955 | int i, count = 0, ret; |
| 956 | double w; |
| 957 | if (v_wgt >= 0 && v_wgt > G->v_sizecxx . . $ _glp_graph#v_size. - (int)sizeof(double)) |
| 958 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_ccdata: v_wgt = %d; invalid offset\n", |
| 959 | v_wgt); |
| 960 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing graph 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, "c %s\n", |
| 968 | G->namecxx . . $ _glp_graph#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "unknown" : G->namecxx . . $ _glp_graph#name.), count++; |
| 969 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "p edge %d %d\n", G->nvcxx . . $ _glp_graph#nv., G->nacxx . . $ _glp_graph#na.), count++; |
| 970 | if (v_wgt >= 0) |
| 971 | { for (i = 1; i <= G->nvcxx . . $ _glp_graph#nv.; i++) |
| 972 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 973 | memcpycxx . . $ memcpy(cc817cb175f282d).(&w, (char *)v->datacxx . . $ _glp_vertex#data. + v_wgt, sizeof(double)); |
| 974 | if (w != 1.0) |
| 975 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "n %d %.*g\n", i, DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, w), count++; |
| 976 | } |
| 977 | } |
| 978 | for (i = 1; i <= G->nvcxx . . $ _glp_graph#nv.; i++) |
| 979 | { v = G->vcxx . . $ _glp_graph#v.[i]; |
| 980 | for (e = v->outcxx . . $ _glp_vertex#out.; e != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; e = e->t_nextcxx . . $ _glp_arc#t_next.) |
| 981 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "e %d %d\n", e->tailcxx . . $ _glp_arc#tail.->icxx . . $ _glp_vertex#i., e->headcxx . . $ _glp_arc#head.->icxx . . $ _glp_vertex#i.), count++; |
| 982 | } |
| 983 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "c eof\n"), count++; |
| 984 | xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp); |
| 985 | if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp)) |
| 986 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 987 | ret = 1; |
| 988 | goto done; |
| 989 | } |
| 990 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were written\n", count); |
| 991 | ret = 0; |
| 992 | 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); |
| 993 | return ret; |
| 994 | } |
| 995 | |
| 996 | /*********************************************************************** |
| 997 | * NAME |
| 998 | * |
| 999 | * glp_read_prob - read problem data in GLPK format |
| 1000 | * |
| 1001 | * SYNOPSIS |
| 1002 | * |
| 1003 | * int glp_read_prob(glp_prob *P, int flags, const char *fname); |
| 1004 | * |
| 1005 | * The routine glp_read_prob reads problem data in GLPK LP/MIP format |
| 1006 | * from a text file. |
| 1007 | * |
| 1008 | * RETURNS |
| 1009 | * |
| 1010 | * If the operation was successful, the routine returns zero. Otherwise |
| 1011 | * it prints an error message and returns non-zero. */ |
| 1012 | |
| 1013 | int glp_read_probcxx . . $ glp_read_prob(23f264e9e3ac104e).(glp_probcxx . . $ glp_prob# *P, int flags, const char *fname) |
| 1014 | { struct csacxx . . $ csa# _csa, *csa = &_csa; |
| 1015 | int mip, m, n, nnz, ne, i, j, k, type, kind, ret, *ln = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 1016 | *ia = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *ja = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1017 | double lb, ub, temp, *ar = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1018 | char *rf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *cf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1019 | 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`!) |
| 1020 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_prob: P = %p; invalid problem object\n", |
| 1021 | P); |
| 1022 | if (flags != 0) |
| 1023 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_prob: flags = %d; invalid parameter\n", |
| 1024 | flags); |
| 1025 | if (fname == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1026 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_read_prob: fname = %d; invalid parameter\n", |
| 1027 | fname); |
| 1028 | glp_erase_probcxx . . $ glp_erase_prob(84c60d68cac39b9a).(P); |
| 1029 | if (setjmpcxx . . $ `<external>/4367339001007250937/setjmp.h:49:9`!(csa->jump)) |
| 1030 | { ret = 1; |
| 1031 | goto done; |
| 1032 | } |
| 1033 | csa->fnamecxx . . $ csa#fname. = fname; |
| 1034 | csa->fpcxx . . $ csa#fp. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1035 | csa->countcxx . . $ csa#count. = 0; |
| 1036 | csa->ccxx . . $ csa#c. = '\n'; |
| 1037 | csa->fieldcxx . . $ csa#field.[0] = '\0'; |
| 1038 | csa->emptycxx . . $ csa#empty. = csa->nonintcxx . . $ csa#nonint. = 0; |
| 1039 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Reading problem data from `%s'...\n", fname); |
| 1040 | csa->fpcxx . . $ csa#fp. = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "r"); |
| 1041 | if (csa->fpcxx . . $ csa#fp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1042 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to open `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 1043 | longjmpcxx . . $ longjmp(d25daf25a2f573dc).(csa->jumpcxx . . $ csa#jump., 1); |
| 1044 | } |
| 1045 | /* read problem line */ |
| 1046 | read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 1047 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "p") != 0) |
| 1048 | errorcxx . . $ error(e8301108646546ee).(csa, "problem line missing or invalid"); |
| 1049 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1050 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "lp") == 0) |
| 1051 | mip = 0; |
| 1052 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "mip") == 0) |
| 1053 | mip = 1; |
| 1054 | else |
| 1055 | errorcxx . . $ error(e8301108646546ee).(csa, "wrong problem designator; `lp' or `mip' expected\n" |
| 1056 | ); |
| 1057 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1058 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "min") == 0) |
| 1059 | glp_set_obj_dircxx . . $ glp_set_obj_dir(e00ef8be97973834).(P, GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`!); |
| 1060 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "max") == 0) |
| 1061 | glp_set_obj_dircxx . . $ glp_set_obj_dir(e00ef8be97973834).(P, GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`!); |
| 1062 | else |
| 1063 | errorcxx . . $ error(e8301108646546ee).(csa, "objective sense missing or invalid"); |
| 1064 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1065 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &m) == 0 && m >= 0)) |
| 1066 | errorcxx . . $ error(e8301108646546ee).(csa, "number of rows missing or invalid"); |
| 1067 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1068 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &n) == 0 && n >= 0)) |
| 1069 | errorcxx . . $ error(e8301108646546ee).(csa, "number of columns missing or invalid"); |
| 1070 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1071 | if (!(str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &nnz) == 0 && nnz >= 0)) |
| 1072 | errorcxx . . $ error(e8301108646546ee).(csa, "number of constraint coefficients missing or inval" |
| 1073 | "id"); |
| 1074 | if (m > 0) |
| 1075 | { glp_add_rowscxx . . $ glp_add_rows(423829e847ef1a83).(P, m); |
| 1076 | for (i = 1; i <= m; i++) |
| 1077 | glp_set_row_bndscxx . . $ glp_set_row_bnds(9376c6e48e598b7a).(P, i, GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!, 0.0, 0.0); |
| 1078 | } |
| 1079 | if (n > 0) |
| 1080 | { glp_add_colscxx . . $ glp_add_cols(423829e847ef1a83).(P, n); |
| 1081 | for (j = 1; j <= n; j++) |
| 1082 | { if (!mip) |
| 1083 | glp_set_col_bndscxx . . $ glp_set_col_bnds(9376c6e48e598b7a).(P, j, GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`!, 0.0, 0.0); |
| 1084 | else |
| 1085 | glp_set_col_kindcxx . . $ glp_set_col_kind(b083f42914639ad0).(P, j, GLP_BVcxx . . $ `external/glpk/glpk.h:56:9`!); |
| 1086 | } |
| 1087 | } |
| 1088 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 1089 | /* allocate working arrays */ |
| 1090 | rf = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+m, sizeof(char)); |
| 1091 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(rf, 0, 1+m); |
| 1092 | cf = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n, sizeof(char)); |
| 1093 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(cf, 0, 1+n); |
| 1094 | ln = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+nnz, sizeof(int)); |
| 1095 | ia = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+nnz, sizeof(int)); |
| 1096 | ja = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+nnz, sizeof(int)); |
| 1097 | ar = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+nnz, sizeof(double)); |
| 1098 | /* read descriptor lines */ |
| 1099 | ne = 0; |
| 1100 | for (;;) |
| 1101 | { read_designatorcxx . . $ read_designator(b530f06c2fd89229).(csa); |
| 1102 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "i") == 0) |
| 1103 | { /* row descriptor */ |
| 1104 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1105 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 1106 | errorcxx . . $ error(e8301108646546ee).(csa, "row number missing or invalid"); |
| 1107 | if (!(1 <= i && i <= m)) |
| 1108 | errorcxx . . $ error(e8301108646546ee).(csa, "row number out of range"); |
| 1109 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1110 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "f") == 0) |
| 1111 | type = GLP_FRcxx . . $ `external/glpk/glpk.h:59:9`!; |
| 1112 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "l") == 0) |
| 1113 | type = GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`!; |
| 1114 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "u") == 0) |
| 1115 | type = GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`!; |
| 1116 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "d") == 0) |
| 1117 | type = GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!; |
| 1118 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "s") == 0) |
| 1119 | type = GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!; |
| 1120 | else |
| 1121 | errorcxx . . $ error(e8301108646546ee).(csa, "row type missing or invalid"); |
| 1122 | if (type == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! || type == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! || type == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!) |
| 1123 | { read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1124 | if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &lb) != 0) |
| 1125 | errorcxx . . $ error(e8301108646546ee).(csa, "row lower bound/fixed value missing or in" |
| 1126 | "valid"); |
| 1127 | } |
| 1128 | else |
| 1129 | lb = 0.0; |
| 1130 | if (type == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || type == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!) |
| 1131 | { read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1132 | if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &ub) != 0) |
| 1133 | errorcxx . . $ error(e8301108646546ee).(csa, "row upper bound missing or invalid"); |
| 1134 | } |
| 1135 | else |
| 1136 | ub = 0.0; |
| 1137 | if (rf[i] & 0x01) |
| 1138 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate row descriptor"); |
| 1139 | glp_set_row_bndscxx . . $ glp_set_row_bnds(9376c6e48e598b7a).(P, i, type, lb, ub), rf[i] |= 0x01; |
| 1140 | } |
| 1141 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "j") == 0) |
| 1142 | { /* column descriptor */ |
| 1143 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1144 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &j) != 0) |
| 1145 | errorcxx . . $ error(e8301108646546ee).(csa, "column number missing or invalid"); |
| 1146 | if (!(1 <= j && j <= n)) |
| 1147 | errorcxx . . $ error(e8301108646546ee).(csa, "column number out of range"); |
| 1148 | if (!mip) |
| 1149 | kind = GLP_CVcxx . . $ `external/glpk/glpk.h:54:9`!; |
| 1150 | else |
| 1151 | { read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1152 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "c") == 0) |
| 1153 | kind = GLP_CVcxx . . $ `external/glpk/glpk.h:54:9`!; |
| 1154 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "i") == 0) |
| 1155 | kind = GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`!; |
| 1156 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "b") == 0) |
| 1157 | { kind = GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`!; |
| 1158 | type = GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!, lb = 0.0, ub = 1.0; |
| 1159 | goto skip; |
| 1160 | } |
| 1161 | else |
| 1162 | errorcxx . . $ error(e8301108646546ee).(csa, "column kind missing or invalid"); |
| 1163 | } |
| 1164 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1165 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "f") == 0) |
| 1166 | type = GLP_FRcxx . . $ `external/glpk/glpk.h:59:9`!; |
| 1167 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "l") == 0) |
| 1168 | type = GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`!; |
| 1169 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "u") == 0) |
| 1170 | type = GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`!; |
| 1171 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "d") == 0) |
| 1172 | type = GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!; |
| 1173 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "s") == 0) |
| 1174 | type = GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!; |
| 1175 | else |
| 1176 | errorcxx . . $ error(e8301108646546ee).(csa, "column type missing or invalid"); |
| 1177 | if (type == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! || type == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! || type == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!) |
| 1178 | { read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1179 | if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &lb) != 0) |
| 1180 | errorcxx . . $ error(e8301108646546ee).(csa, "column lower bound/fixed value missing or" |
| 1181 | " invalid"); |
| 1182 | } |
| 1183 | else |
| 1184 | lb = 0.0; |
| 1185 | if (type == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`! || type == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!) |
| 1186 | { read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1187 | if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &ub) != 0) |
| 1188 | errorcxx . . $ error(e8301108646546ee).(csa, "column upper bound missing or invalid"); |
| 1189 | } |
| 1190 | else |
| 1191 | ub = 0.0; |
| 1192 | skip: if (cf[j] & 0x01) |
| 1193 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate column descriptor"); |
| 1194 | glp_set_col_kindcxx . . $ glp_set_col_kind(b083f42914639ad0).(P, j, kind); |
| 1195 | glp_set_col_bndscxx . . $ glp_set_col_bnds(9376c6e48e598b7a).(P, j, type, lb, ub), cf[j] |= 0x01; |
| 1196 | } |
| 1197 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "a") == 0) |
| 1198 | { /* coefficient descriptor */ |
| 1199 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1200 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 1201 | errorcxx . . $ error(e8301108646546ee).(csa, "row number missing or invalid"); |
| 1202 | if (!(0 <= i && i <= m)) |
| 1203 | errorcxx . . $ error(e8301108646546ee).(csa, "row number out of range"); |
| 1204 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1205 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &j) != 0) |
| 1206 | errorcxx . . $ error(e8301108646546ee).(csa, "column number missing or invalid"); |
| 1207 | if (!((i == 0 ? 0 : 1) <= j && j <= n)) |
| 1208 | errorcxx . . $ error(e8301108646546ee).(csa, "column number out of range"); |
| 1209 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1210 | if (i == 0) |
| 1211 | { if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &temp) != 0) |
| 1212 | errorcxx . . $ error(e8301108646546ee).(csa, "objective %s missing or invalid", |
| 1213 | j == 0 ? "constant term" : "coefficient"); |
| 1214 | if (cf[j] & 0x10) |
| 1215 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate objective %s", |
| 1216 | j == 0 ? "constant term" : "coefficient"); |
| 1217 | glp_set_obj_coefcxx . . $ glp_set_obj_coef(d60e14834b632e5e).(P, j, temp), cf[j] |= 0x10; |
| 1218 | } |
| 1219 | else |
| 1220 | { if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(csa->fieldcxx . . $ csa#field., &temp) != 0) |
| 1221 | errorcxx . . $ error(e8301108646546ee).(csa, "constraint coefficient missing or invalid" |
| 1222 | ); |
| 1223 | if (ne == nnz) |
| 1224 | errorcxx . . $ error(e8301108646546ee).(csa, "too many constraint coefficient descripto" |
| 1225 | "rs"); |
| 1226 | ln[++ne] = csa->countcxx . . $ csa#count.; |
| 1227 | ia[ne] = i, ja[ne] = j, ar[ne] = temp; |
| 1228 | } |
| 1229 | } |
| 1230 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "n") == 0) |
| 1231 | { /* symbolic name descriptor */ |
| 1232 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1233 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "p") == 0) |
| 1234 | { /* problem name */ |
| 1235 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1236 | if (P->namecxx . . $ glp_prob#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1237 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate problem name"); |
| 1238 | glp_set_prob_namecxx . . $ glp_set_prob_name(d84c0d6c877919f6).(P, csa->fieldcxx . . $ csa#field.); |
| 1239 | } |
| 1240 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "z") == 0) |
| 1241 | { /* objective name */ |
| 1242 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1243 | if (P->objcxx . . $ glp_prob#obj. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1244 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate objective name"); |
| 1245 | glp_set_obj_namecxx . . $ glp_set_obj_name(d84c0d6c877919f6).(P, csa->fieldcxx . . $ csa#field.); |
| 1246 | } |
| 1247 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "i") == 0) |
| 1248 | { /* row name */ |
| 1249 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1250 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &i) != 0) |
| 1251 | errorcxx . . $ error(e8301108646546ee).(csa, "row number missing or invalid"); |
| 1252 | if (!(1 <= i && i <= m)) |
| 1253 | errorcxx . . $ error(e8301108646546ee).(csa, "row number out of range"); |
| 1254 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1255 | if (P->rowcxx . . $ glp_prob#row.[i]->namecxx . . $ GLPROW#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1256 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate row name"); |
| 1257 | glp_set_row_namecxx . . $ glp_set_row_name(7764df469f6d9ace).(P, i, csa->fieldcxx . . $ csa#field.); |
| 1258 | } |
| 1259 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "j") == 0) |
| 1260 | { /* column name */ |
| 1261 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1262 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(csa->fieldcxx . . $ csa#field., &j) != 0) |
| 1263 | errorcxx . . $ error(e8301108646546ee).(csa, "column number missing or invalid"); |
| 1264 | if (!(1 <= j && j <= n)) |
| 1265 | errorcxx . . $ error(e8301108646546ee).(csa, "column number out of range"); |
| 1266 | read_fieldcxx . . $ read_field(b530f06c2fd89229).(csa); |
| 1267 | if (P->colcxx . . $ glp_prob#col.[j]->namecxx . . $ GLPCOL#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1268 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate column name"); |
| 1269 | glp_set_col_namecxx . . $ glp_set_col_name(7764df469f6d9ace).(P, j, csa->fieldcxx . . $ csa#field.); |
| 1270 | } |
| 1271 | else |
| 1272 | errorcxx . . $ error(e8301108646546ee).(csa, "object designator missing or invalid"); |
| 1273 | } |
| 1274 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(csa->fieldcxx . . $ csa#field., "e") == 0) |
| 1275 | break; |
| 1276 | else |
| 1277 | errorcxx . . $ error(e8301108646546ee).(csa, "line designator missing or invalid"); |
| 1278 | end_of_linecxx . . $ end_of_line(b530f06c2fd89229).(csa); |
| 1279 | } |
| 1280 | if (ne < nnz) |
| 1281 | errorcxx . . $ error(e8301108646546ee).(csa, "too few constraint coefficient descriptors"); |
| 1282 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(ne == nnz); |
| 1283 | k = glp_check_dupcxx . . $ glp_check_dup(7c21838140d47389).(m, n, ne, ia, ja); |
| 1284 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(0 <= k && k <= nnz); |
| 1285 | if (k > 0) |
| 1286 | { csa->countcxx . . $ csa#count. = ln[k]; |
| 1287 | errorcxx . . $ error(e8301108646546ee).(csa, "duplicate constraint coefficient"); |
| 1288 | } |
| 1289 | glp_load_matrixcxx . . $ glp_load_matrix(424112a44cc66b74).(P, ne, ia, ja, ar); |
| 1290 | /* print some statistics */ |
| 1291 | if (P->namecxx . . $ glp_prob#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1292 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Problem: %s\n", P->namecxx . . $ glp_prob#name.); |
| 1293 | if (P->objcxx . . $ glp_prob#obj. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1294 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Objective: %s\n", P->objcxx . . $ glp_prob#obj.); |
| 1295 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d row%s, %d column%s, %d non-zero%s\n", |
| 1296 | m, m == 1 ? "" : "s", n, n == 1 ? "" : "s", nnz, nnz == 1 ? |
| 1297 | "" : "s"); |
| 1298 | if (glp_get_num_intcxx . . $ glp_get_num_int(317ecc1aeadfe2b7).(P) > 0) |
| 1299 | { int ni = glp_get_num_intcxx . . $ glp_get_num_int(317ecc1aeadfe2b7).(P); |
| 1300 | int nb = glp_get_num_bincxx . . $ glp_get_num_bin(317ecc1aeadfe2b7).(P); |
| 1301 | if (ni == 1) |
| 1302 | { if (nb == 0) |
| 1303 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("One variable is integer\n"); |
| 1304 | else |
| 1305 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("One variable is binary\n"); |
| 1306 | } |
| 1307 | else |
| 1308 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d integer variables, ", ni); |
| 1309 | if (nb == 0) |
| 1310 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("none"); |
| 1311 | else if (nb == 1) |
| 1312 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("one"); |
| 1313 | else if (nb == ni) |
| 1314 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("all"); |
| 1315 | else |
| 1316 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d", nb); |
| 1317 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!(" of which %s binary\n", nb == 1 ? "is" : "are"); |
| 1318 | } |
| 1319 | } |
| 1320 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were read\n", csa->countcxx . . $ csa#count.); |
| 1321 | /* problem data has been successfully read */ |
| 1322 | glp_sort_matrixcxx . . $ glp_sort_matrix(84c60d68cac39b9a).(P); |
| 1323 | ret = 0; |
| 1324 | done: if (csa->fpcxx . . $ csa#fp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfclosecxx . . $ `external/glpk/glpenv.h:211:9`!(csa->fpcxx . . $ csa#fp.); |
| 1325 | if (rf != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(rf); |
| 1326 | if (cf != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(cf); |
| 1327 | if (ln != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(ln); |
| 1328 | if (ia != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(ia); |
| 1329 | if (ja != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(ja); |
| 1330 | if (ar != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(ar); |
| 1331 | if (ret) glp_erase_probcxx . . $ glp_erase_prob(84c60d68cac39b9a).(P); |
| 1332 | return ret; |
| 1333 | } |
| 1334 | |
| 1335 | /*********************************************************************** |
| 1336 | * NAME |
| 1337 | * |
| 1338 | * glp_write_prob - write problem data in GLPK format |
| 1339 | * |
| 1340 | * SYNOPSIS |
| 1341 | * |
| 1342 | * int glp_write_prob(glp_prob *P, int flags, const char *fname); |
| 1343 | * |
| 1344 | * The routine glp_write_prob writes problem data in GLPK LP/MIP format |
| 1345 | * to a text file. |
| 1346 | * |
| 1347 | * RETURNS |
| 1348 | * |
| 1349 | * If the operation was successful, the routine returns zero. Otherwise |
| 1350 | * it prints an error message and returns non-zero. */ |
| 1351 | |
| 1352 | int glp_write_probcxx . . $ glp_write_prob(23f264e9e3ac104e).(glp_probcxx . . $ glp_prob# *P, int flags, const char *fname) |
| 1353 | { XFILEcxx . . $ XFILE# *fp; |
| 1354 | GLPROWcxx . . $ GLPROW# *row; |
| 1355 | GLPCOLcxx . . $ GLPCOL# *col; |
| 1356 | GLPAIJcxx . . $ GLPAIJ# *aij; |
| 1357 | int mip, i, j, count, ret; |
| 1358 | 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`!) |
| 1359 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_prob: P = %p; invalid problem object\n", |
| 1360 | P); |
| 1361 | if (flags != 0) |
| 1362 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_prob: flags = %d; invalid parameter\n", |
| 1363 | flags); |
| 1364 | if (fname == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1365 | xerrorcxx . . $ `external/glpk/glpenv.h:158:9`!("glp_write_prob: fname = %d; invalid parameter\n", |
| 1366 | fname); |
| 1367 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Writing problem data to `%s'...\n", fname); |
| 1368 | fp = xfopencxx . . $ `external/glpk/glpenv.h:193:9`!(fname, "w"), count = 0; |
| 1369 | if (fp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1370 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Unable to create `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 1371 | ret = 1; |
| 1372 | goto done; |
| 1373 | } |
| 1374 | /* write problem line */ |
| 1375 | mip = (glp_get_num_intcxx . . $ glp_get_num_int(317ecc1aeadfe2b7).(P) > 0); |
| 1376 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "p %s %s %d %d %d\n", !mip ? "lp" : "mip", |
| 1377 | P->dircxx . . $ glp_prob#dir. == GLP_MINcxx . . $ `external/glpk/glpk.h:50:9`! ? "min" : P->dircxx . . $ glp_prob#dir. == GLP_MAXcxx . . $ `external/glpk/glpk.h:51:9`! ? "max" : "???", |
| 1378 | P->mcxx . . $ glp_prob#m., P->ncxx . . $ glp_prob#n., P->nnzcxx . . $ glp_prob#nnz.), count++; |
| 1379 | if (P->namecxx . . $ glp_prob#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1380 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "n p %s\n", P->namecxx . . $ glp_prob#name.), count++; |
| 1381 | if (P->objcxx . . $ glp_prob#obj. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1382 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "n z %s\n", P->objcxx . . $ glp_prob#obj.), count++; |
| 1383 | /* write row descriptors */ |
| 1384 | for (i = 1; i <= P->mcxx . . $ glp_prob#m.; i++) |
| 1385 | { row = P->rowcxx . . $ glp_prob#row.[i]; |
| 1386 | if (row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`! && row->lbcxx . . $ GLPROW#lb. == 0.0) |
| 1387 | goto skip1; |
| 1388 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "i %d ", i), count++; |
| 1389 | if (row->typecxx . . $ GLPROW#type. == GLP_FRcxx . . $ `external/glpk/glpk.h:59:9`!) |
| 1390 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "f\n"); |
| 1391 | else if (row->typecxx . . $ GLPROW#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`!) |
| 1392 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "l %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, row->lbcxx . . $ GLPROW#lb.); |
| 1393 | else if (row->typecxx . . $ GLPROW#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`!) |
| 1394 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "u %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, row->ubcxx . . $ GLPROW#ub.); |
| 1395 | else if (row->typecxx . . $ GLPROW#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!) |
| 1396 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "d %.*g %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, row->lbcxx . . $ GLPROW#lb., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, |
| 1397 | row->ubcxx . . $ GLPROW#ub.); |
| 1398 | else if (row->typecxx . . $ GLPROW#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!) |
| 1399 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "s %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, row->lbcxx . . $ GLPROW#lb.); |
| 1400 | else |
| 1401 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(row != row); |
| 1402 | skip1: if (row->namecxx . . $ GLPROW#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1403 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "n i %d %s\n", i, row->namecxx . . $ GLPROW#name.), count++; |
| 1404 | } |
| 1405 | /* write column descriptors */ |
| 1406 | for (j = 1; j <= P->ncxx . . $ glp_prob#n.; j++) |
| 1407 | { col = P->colcxx . . $ glp_prob#col.[j]; |
| 1408 | if (!mip && col->typecxx . . $ GLPCOL#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`! && col->lbcxx . . $ GLPCOL#lb. == 0.0) |
| 1409 | goto skip2; |
| 1410 | if (mip && col->kindcxx . . $ GLPCOL#kind. == GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`! && col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`! && |
| 1411 | col->lbcxx . . $ GLPCOL#lb. == 0.0 && col->ubcxx . . $ GLPCOL#ub. == 1.0) |
| 1412 | goto skip2; |
| 1413 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "j %d ", j), count++; |
| 1414 | if (mip) |
| 1415 | { if (col->kindcxx . . $ GLPCOL#kind. == GLP_CVcxx . . $ `external/glpk/glpk.h:54:9`!) |
| 1416 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "c "); |
| 1417 | else if (col->kindcxx . . $ GLPCOL#kind. == GLP_IVcxx . . $ `external/glpk/glpk.h:55:9`!) |
| 1418 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "i "); |
| 1419 | else |
| 1420 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(col != col); |
| 1421 | } |
| 1422 | if (col->typecxx . . $ GLPCOL#type. == GLP_FRcxx . . $ `external/glpk/glpk.h:59:9`!) |
| 1423 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "f\n"); |
| 1424 | else if (col->typecxx . . $ GLPCOL#type. == GLP_LOcxx . . $ `external/glpk/glpk.h:60:9`!) |
| 1425 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "l %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, col->lbcxx . . $ GLPCOL#lb.); |
| 1426 | else if (col->typecxx . . $ GLPCOL#type. == GLP_UPcxx . . $ `external/glpk/glpk.h:61:9`!) |
| 1427 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "u %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, col->ubcxx . . $ GLPCOL#ub.); |
| 1428 | else if (col->typecxx . . $ GLPCOL#type. == GLP_DBcxx . . $ `external/glpk/glpk.h:62:9`!) |
| 1429 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "d %.*g %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, col->lbcxx . . $ GLPCOL#lb., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, |
| 1430 | col->ubcxx . . $ GLPCOL#ub.); |
| 1431 | else if (col->typecxx . . $ GLPCOL#type. == GLP_FXcxx . . $ `external/glpk/glpk.h:63:9`!) |
| 1432 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "s %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, col->lbcxx . . $ GLPCOL#lb.); |
| 1433 | else |
| 1434 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(col != col); |
| 1435 | skip2: if (col->namecxx . . $ GLPCOL#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1436 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "n j %d %s\n", j, col->namecxx . . $ GLPCOL#name.), count++; |
| 1437 | } |
| 1438 | /* write objective coefficient descriptors */ |
| 1439 | if (P->c0cxx . . $ glp_prob#c0. != 0.0) |
| 1440 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "a 0 0 %.*g\n", DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, P->c0cxx . . $ glp_prob#c0.), count++; |
| 1441 | for (j = 1; j <= P->ncxx . . $ glp_prob#n.; j++) |
| 1442 | { col = P->colcxx . . $ glp_prob#col.[j]; |
| 1443 | if (col->coefcxx . . $ GLPCOL#coef. != 0.0) |
| 1444 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "a 0 %d %.*g\n", j, DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, col->coefcxx . . $ GLPCOL#coef.), |
| 1445 | count++; |
| 1446 | } |
| 1447 | /* write constraint coefficient descriptors */ |
| 1448 | for (i = 1; i <= P->mcxx . . $ glp_prob#m.; i++) |
| 1449 | { row = P->rowcxx . . $ glp_prob#row.[i]; |
| 1450 | for (aij = row->ptrcxx . . $ GLPROW#ptr.; aij != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; aij = aij->r_nextcxx . . $ GLPAIJ#r_next.) |
| 1451 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "a %d %d %.*g\n", i, aij->colcxx . . $ GLPAIJ#col.->jcxx . . $ GLPCOL#j., DBL_DIGcxx . . $ `<external>/18143172452841944454/float.h:54:9`!, |
| 1452 | aij->valcxx . . $ GLPAIJ#val.), count++; |
| 1453 | } |
| 1454 | /* write end line */ |
| 1455 | xfprintfcxx . . $ `external/glpk/glpenv.h:214:9`!(fp, "e o f\n"), count++; |
| 1456 | xfflushcxx . . $ `external/glpk/glpenv.h:208:9`!(fp); |
| 1457 | if (xferrorcxx . . $ `external/glpk/glpenv.h:196:9`!(fp)) |
| 1458 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("Write error on `%s' - %s\n", fname, xerrmsgcxx . . $ `external/glpk/glpenv.h:190:9`!()); |
| 1459 | ret = 1; |
| 1460 | goto done; |
| 1461 | } |
| 1462 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%d lines were written\n", count); |
| 1463 | ret = 0; |
| 1464 | 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); |
| 1465 | return ret; |
| 1466 | } |
| 1467 | |
| 1468 | /* eof */ |