| 1 | /* glptsp.c */cxx . . $ `<file>/external/glpk/glptsp.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_ERRNOcxx . . $ `external/glpk/glptsp.c:25:9`! |
| 26 | #define _GLPSTD_STDIOcxx . . $ `external/glpk/glptsp.c:26:9`! |
| 27 | #include "glpenv.h"cxx . . $ `<file>/external/glpk/glpenv.h`/ |
| 28 | #include "glptsp.h"cxx . . $ `<file>/external/glpk/glptsp.h`/ |
| 29 | #define xfaultcxx . . $ `external/glpk/glptsp.c:29:9`! xerrorcxx . . $ `external/glpk/glpenv.h:158:9`! |
| 30 | |
| 31 | /*---------------------------------------------------------------------- |
| 32 | -- tsp_read_data - read TSP instance data. |
| 33 | -- |
| 34 | -- *Synopsis* |
| 35 | -- |
| 36 | -- #include "glptsp.h" |
| 37 | -- TSP *tsp_read_data(char *fname); |
| 38 | -- |
| 39 | -- *Description* |
| 40 | -- |
| 41 | -- The routine tsp_read_data reads a TSP (or related problem) instance |
| 42 | -- data from the text file, whose name is the character string fname. |
| 43 | -- |
| 44 | -- For detailed description of the format recognized by the routine see |
| 45 | -- the report: G.Reinelt, TSPLIB 95. |
| 46 | -- |
| 47 | -- *Returns* |
| 48 | -- |
| 49 | -- If no error occurred, the routine tsp_read_data returns a pointer to |
| 50 | -- the TSP instance data block, which contains loaded data. In the case |
| 51 | -- of error the routine prints an error message and returns NULL. */ |
| 52 | |
| 53 | struct dsacxx . . $ dsa# |
| 54 | { /* dynamic storage area used by the routine tsp_read_data */ |
| 55 | char *fnamecxx . . $ dsa#fname.; |
| 56 | /* name of the input text file */ |
| 57 | FILEcxx . . $ FILE# *fpcxx . . $ dsa#fp.; |
| 58 | /* stream assigned to the input text file */ |
| 59 | int seqncxx . . $ dsa#seqn.; |
| 60 | /* line sequential number */ |
| 61 | int ccxx . . $ dsa#c.; |
| 62 | /* current character */ |
| 63 | char tokencxx . . $ dsa#token.[255+1]; |
| 64 | /* current token */ |
| 65 | }; |
| 66 | |
| 67 | static int get_charcxx . . $ get_char(bb135ed1a6c3747c).(struct dsacxx . . $ dsa# *dsa) |
| 68 | { dsa->ccxx . . $ dsa#c. = fgetccxx . . $ fgetc(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.); |
| 69 | if (ferrorcxx . . $ ferror(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.)) |
| 70 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: read error - %s\n", |
| 71 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 72 | return 1; |
| 73 | } |
| 74 | if (feofcxx . . $ feof(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.)) |
| 75 | dsa->ccxx . . $ dsa#c. = EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`!; |
| 76 | else if (dsa->ccxx . . $ dsa#c. == '\n') |
| 77 | dsa->seqncxx . . $ dsa#seqn.++; |
| 78 | else if (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(dsa->c)) |
| 79 | dsa->ccxx . . $ dsa#c. = ' '; |
| 80 | else if (iscntrlcxx . . $ `<external>/17904084882347303253/ctype.h:191:10`!(dsa->c)) |
| 81 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: invalid control character 0x%02X\n", |
| 82 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., dsa->ccxx . . $ dsa#c.); |
| 83 | return 1; |
| 84 | } |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | static int skip_spacescxx . . $ skip_spaces(70c4429eef62e141).(struct dsacxx . . $ dsa# *dsa, int across) |
| 89 | { while (dsa->ccxx . . $ dsa#c. == ' ' || (across && dsa->ccxx . . $ dsa#c. == '\n')) |
| 90 | if (get_charcxx . . $ get_char(bb135ed1a6c3747c).(dsa)) return 1; |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | static int scan_keywordcxx . . $ scan_keyword(bb135ed1a6c3747c).(struct dsacxx . . $ dsa# *dsa) |
| 95 | { int len = 0; |
| 96 | if (skip_spacescxx . . $ skip_spaces(70c4429eef62e141).(dsa, 0)) return 1; |
| 97 | dsa->tokencxx . . $ dsa#token.[0] = '\0'; |
| 98 | while (isalnumcxx . . $ `<external>/17904084882347303253/ctype.h:189:10`!(dsa->c) || dsa->ccxx . . $ dsa#c. == '_') |
| 99 | { if (len == 31) |
| 100 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: keyword `%s...' too long\n", dsa->fnamecxx . . $ dsa#fname., |
| 101 | dsa->seqncxx . . $ dsa#seqn., dsa->tokencxx . . $ dsa#token.); |
| 102 | return 1; |
| 103 | } |
| 104 | dsa->tokencxx . . $ dsa#token.[len++] = (char)dsa->ccxx . . $ dsa#c., dsa->tokencxx . . $ dsa#token.[len] = '\0'; |
| 105 | if (get_charcxx . . $ get_char(bb135ed1a6c3747c).(dsa)) return 1; |
| 106 | } |
| 107 | if (len == 0) |
| 108 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: missing keyword\n", dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 109 | return 1; |
| 110 | } |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | static int check_coloncxx . . $ check_colon(bb135ed1a6c3747c).(struct dsacxx . . $ dsa# *dsa) |
| 115 | { if (skip_spacescxx . . $ skip_spaces(70c4429eef62e141).(dsa, 0)) return 1; |
| 116 | if (dsa->ccxx . . $ dsa#c. != ':') |
| 117 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: missing colon after `%s'\n", dsa->fnamecxx . . $ dsa#fname., |
| 118 | dsa->seqncxx . . $ dsa#seqn., dsa->tokencxx . . $ dsa#token.); |
| 119 | return 1; |
| 120 | } |
| 121 | if (get_charcxx . . $ get_char(bb135ed1a6c3747c).(dsa)) return 1; |
| 122 | return 0; |
| 123 | } |
| 124 | |
| 125 | static int scan_tokencxx . . $ scan_token(70c4429eef62e141).(struct dsacxx . . $ dsa# *dsa, int across) |
| 126 | { int len = 0; |
| 127 | if (skip_spacescxx . . $ skip_spaces(70c4429eef62e141).(dsa, across)) return 1; |
| 128 | dsa->tokencxx . . $ dsa#token.[0] = '\0'; |
| 129 | while (!(dsa->ccxx . . $ dsa#c. == EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`! || dsa->ccxx . . $ dsa#c. == '\n' || dsa->ccxx . . $ dsa#c. == ' ')) |
| 130 | { if (len == 255) |
| 131 | { dsa->tokencxx . . $ dsa#token.[31] = '\0'; |
| 132 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: token `%s...' too long\n", dsa->fnamecxx . . $ dsa#fname., |
| 133 | dsa->seqncxx . . $ dsa#seqn., dsa->tokencxx . . $ dsa#token.); |
| 134 | return 1; |
| 135 | } |
| 136 | dsa->tokencxx . . $ dsa#token.[len++] = (char)dsa->ccxx . . $ dsa#c., dsa->tokencxx . . $ dsa#token.[len] = '\0'; |
| 137 | if (get_charcxx . . $ get_char(bb135ed1a6c3747c).(dsa)) return 1; |
| 138 | } |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | static int check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(struct dsacxx . . $ dsa# *dsa) |
| 143 | { if (skip_spacescxx . . $ skip_spaces(70c4429eef62e141).(dsa, 0)) return 1; |
| 144 | if (!(dsa->ccxx . . $ dsa#c. == EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`! || dsa->ccxx . . $ dsa#c. == '\n')) |
| 145 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: extra symbols detected\n", dsa->fnamecxx . . $ dsa#fname., |
| 146 | dsa->seqncxx . . $ dsa#seqn.); |
| 147 | return 1; |
| 148 | } |
| 149 | if (get_charcxx . . $ get_char(bb135ed1a6c3747c).(dsa)) return 1; |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | static int scan_commentcxx . . $ scan_comment(bb135ed1a6c3747c).(struct dsacxx . . $ dsa# *dsa) |
| 154 | { int len = 0; |
| 155 | if (skip_spacescxx . . $ skip_spaces(70c4429eef62e141).(dsa, 0)) return 1; |
| 156 | dsa->tokencxx . . $ dsa#token.[0] = '\0'; |
| 157 | while (!(dsa->ccxx . . $ dsa#c. == EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`! || dsa->ccxx . . $ dsa#c. == '\n')) |
| 158 | { if (len == 255) |
| 159 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: comment too long\n", dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.) |
| 160 | ; |
| 161 | return 1; |
| 162 | } |
| 163 | dsa->tokencxx . . $ dsa#token.[len++] = (char)dsa->ccxx . . $ dsa#c., dsa->tokencxx . . $ dsa#token.[len] = '\0'; |
| 164 | if (get_charcxx . . $ get_char(bb135ed1a6c3747c).(dsa)) return 1; |
| 165 | } |
| 166 | return 0; |
| 167 | } |
| 168 | |
| 169 | static int scan_integercxx . . $ scan_integer(1fc27fedc07949e8).(struct dsacxx . . $ dsa# *dsa, int across, int *val) |
| 170 | { if (scan_tokencxx . . $ scan_token(70c4429eef62e141).(dsa, across)) return 1; |
| 171 | if (strlencxx . . $ strlen(751346f8406fd082).(dsa->tokencxx . . $ dsa#token.) == 0) |
| 172 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: missing integer\n", dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 173 | return 1; |
| 174 | } |
| 175 | if (str2intcxx . . $ `external/glpk/glplib.h:81:9`!(dsa->tokencxx . . $ dsa#token., val)) |
| 176 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: integer `%s' invalid\n", dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn. |
| 177 | , dsa->tokencxx . . $ dsa#token.); |
| 178 | return 1; |
| 179 | } |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | static int scan_numbercxx . . $ scan_number(fc599f8022a8e44e).(struct dsacxx . . $ dsa# *dsa, int across, double *val) |
| 184 | { if (scan_tokencxx . . $ scan_token(70c4429eef62e141).(dsa, across)) return 1; |
| 185 | if (strlencxx . . $ strlen(751346f8406fd082).(dsa->tokencxx . . $ dsa#token.) == 0) |
| 186 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: missing number\n", dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 187 | return 1; |
| 188 | } |
| 189 | if (str2numcxx . . $ `external/glpk/glplib.h:85:9`!(dsa->tokencxx . . $ dsa#token., val)) |
| 190 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: number `%s' invalid\n", dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., |
| 191 | dsa->tokencxx . . $ dsa#token.); |
| 192 | return 1; |
| 193 | } |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | TSPcxx . . $ TSP# *tsp_read_datacxx . . $ `external/glpk/glptsp.h:89:9`!(char *fname) |
| 198 | { struct dsacxx . . $ dsa# _dsa, *dsa = &_dsa; |
| 199 | TSPcxx . . $ TSP# *tsp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 200 | dsa->fnamecxx . . $ dsa#fname. = fname; |
| 201 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: reading TSP data from `%s'...\n", |
| 202 | dsa->fnamecxx . . $ dsa#fname.); |
| 203 | dsa->fpcxx . . $ dsa#fp. = fopencxx . . $ fopen(82ec0787cd37e0a3).(dsa->fnamecxx . . $ dsa#fname., "r"); |
| 204 | if (dsa->fpcxx . . $ dsa#fp. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 205 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: unable to open `%s' - %s\n", |
| 206 | dsa->fnamecxx . . $ dsa#fname., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 207 | goto fail; |
| 208 | } |
| 209 | tsp = xmalloccxx . . $ `external/glpk/glpenv.h:167:9`!(sizeof(TSPcxx . . $ TSP#)); |
| 210 | tsp->namecxx . . $ TSP#name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 211 | tsp->typecxx . . $ TSP#type. = TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!; |
| 212 | tsp->commentcxx . . $ TSP#comment. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 213 | tsp->dimensioncxx . . $ TSP#dimension. = 0; |
| 214 | tsp->edge_weight_typecxx . . $ TSP#edge_weight_type. = TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!; |
| 215 | tsp->edge_weight_formatcxx . . $ TSP#edge_weight_format. = TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!; |
| 216 | tsp->display_data_typecxx . . $ TSP#display_data_type. = TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!; |
| 217 | tsp->node_x_coordcxx . . $ TSP#node_x_coord. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 218 | tsp->node_y_coordcxx . . $ TSP#node_y_coord. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 219 | tsp->dply_x_coordcxx . . $ TSP#dply_x_coord. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 220 | tsp->dply_y_coordcxx . . $ TSP#dply_y_coord. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 221 | tsp->tourcxx . . $ TSP#tour. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 222 | tsp->edge_weightcxx . . $ TSP#edge_weight. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 223 | dsa->seqncxx . . $ dsa#seqn. = 1; |
| 224 | if (get_charcxx . . $ get_char(bb135ed1a6c3747c).(dsa)) goto fail; |
| 225 | loop: if (scan_keywordcxx . . $ scan_keyword(bb135ed1a6c3747c).(dsa)) goto fail; |
| 226 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "NAME") == 0) |
| 227 | { if (tsp->namecxx . . $ TSP#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 228 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: NAME entry multiply defined\n", dsa->fnamecxx . . $ dsa#fname., |
| 229 | dsa->seqncxx . . $ dsa#seqn.); |
| 230 | goto fail; |
| 231 | } |
| 232 | if (check_coloncxx . . $ check_colon(bb135ed1a6c3747c).(dsa)) goto fail; |
| 233 | if (scan_tokencxx . . $ scan_token(70c4429eef62e141).(dsa, 0)) goto fail; |
| 234 | if (strlencxx . . $ strlen(751346f8406fd082).(dsa->tokencxx . . $ dsa#token.) == 0) |
| 235 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: NAME entry incomplete\n", dsa->fnamecxx . . $ dsa#fname., |
| 236 | dsa->seqncxx . . $ dsa#seqn.); |
| 237 | goto fail; |
| 238 | } |
| 239 | tsp->namecxx . . $ TSP#name. = xmalloccxx . . $ `external/glpk/glpenv.h:167:9`!(strlencxx . . $ strlen(751346f8406fd082).(dsa->tokencxx . . $ dsa#token.) + 1); |
| 240 | strcpycxx . . $ strcpy(b7b3a83273496486).(tsp->namecxx . . $ TSP#name., dsa->tokencxx . . $ dsa#token.); |
| 241 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: NAME: %s\n", tsp->namecxx . . $ TSP#name.); |
| 242 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 243 | } |
| 244 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "TYPE") == 0) |
| 245 | { if (tsp->typecxx . . $ TSP#type. != TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!) |
| 246 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: TYPE entry multiply defined\n", dsa->fnamecxx . . $ dsa#fname., |
| 247 | dsa->seqncxx . . $ dsa#seqn.); |
| 248 | goto fail; |
| 249 | } |
| 250 | if (check_coloncxx . . $ check_colon(bb135ed1a6c3747c).(dsa)) goto fail; |
| 251 | if (scan_keywordcxx . . $ scan_keyword(bb135ed1a6c3747c).(dsa)) goto fail; |
| 252 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "TSP") == 0) |
| 253 | tsp->typecxx . . $ TSP#type. = TSP_TSPcxx . . $ `external/glpk/glptsp.h:40:9`!; |
| 254 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "ATSP") == 0) |
| 255 | tsp->typecxx . . $ TSP#type. = TSP_ATSPcxx . . $ `external/glpk/glptsp.h:41:9`!; |
| 256 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "TOUR") == 0) |
| 257 | tsp->typecxx . . $ TSP#type. = TSP_TOURcxx . . $ `external/glpk/glptsp.h:42:9`!; |
| 258 | else |
| 259 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: data type `%s' not recognized\n", |
| 260 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., dsa->tokencxx . . $ dsa#token.); |
| 261 | goto fail; |
| 262 | } |
| 263 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: TYPE: %s\n", dsa->tokencxx . . $ dsa#token.); |
| 264 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 265 | } |
| 266 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "COMMENT") == 0) |
| 267 | { if (tsp->commentcxx . . $ TSP#comment. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 268 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: COMMENT entry multiply defined\n", |
| 269 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 270 | goto fail; |
| 271 | } |
| 272 | if (check_coloncxx . . $ check_colon(bb135ed1a6c3747c).(dsa)) goto fail; |
| 273 | if (scan_commentcxx . . $ scan_comment(bb135ed1a6c3747c).(dsa)) goto fail; |
| 274 | tsp->commentcxx . . $ TSP#comment. = xmalloccxx . . $ `external/glpk/glpenv.h:167:9`!(strlencxx . . $ strlen(751346f8406fd082).(dsa->tokencxx . . $ dsa#token.) + 1); |
| 275 | strcpycxx . . $ strcpy(b7b3a83273496486).(tsp->commentcxx . . $ TSP#comment., dsa->tokencxx . . $ dsa#token.); |
| 276 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: COMMENT: %s\n", tsp->commentcxx . . $ TSP#comment.); |
| 277 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 278 | } |
| 279 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "DIMENSION") == 0) |
| 280 | { if (tsp->dimensioncxx . . $ TSP#dimension. != 0) |
| 281 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: DIMENSION entry multiply defined\n", |
| 282 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 283 | goto fail; |
| 284 | } |
| 285 | if (check_coloncxx . . $ check_colon(bb135ed1a6c3747c).(dsa)) goto fail; |
| 286 | if (scan_integercxx . . $ scan_integer(1fc27fedc07949e8).(dsa, 0, &tsp->dimensioncxx . . $ TSP#dimension.)) goto fail; |
| 287 | if (tsp->dimensioncxx . . $ TSP#dimension. < 1) |
| 288 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: invalid dimension\n", dsa->fnamecxx . . $ dsa#fname., |
| 289 | dsa->seqncxx . . $ dsa#seqn.); |
| 290 | goto fail; |
| 291 | } |
| 292 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: DIMENSION: %d\n", tsp->dimensioncxx . . $ TSP#dimension.); |
| 293 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 294 | } |
| 295 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "EDGE_WEIGHT_TYPE") == 0) |
| 296 | { if (tsp->edge_weight_typecxx . . $ TSP#edge_weight_type. != TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!) |
| 297 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: EDGE_WEIGHT_TYPE entry multiply defined\n", |
| 298 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 299 | goto fail; |
| 300 | } |
| 301 | if (check_coloncxx . . $ check_colon(bb135ed1a6c3747c).(dsa)) goto fail; |
| 302 | if (scan_keywordcxx . . $ scan_keyword(bb135ed1a6c3747c).(dsa)) goto fail; |
| 303 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "GEO") == 0) |
| 304 | tsp->edge_weight_typecxx . . $ TSP#edge_weight_type. = TSP_GEOcxx . . $ `external/glpk/glptsp.h:55:9`!; |
| 305 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "EUC_2D") == 0) |
| 306 | tsp->edge_weight_typecxx . . $ TSP#edge_weight_type. = TSP_EUC_2Dcxx . . $ `external/glpk/glptsp.h:53:9`!; |
| 307 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "ATT") == 0) |
| 308 | tsp->edge_weight_typecxx . . $ TSP#edge_weight_type. = TSP_ATTcxx . . $ `external/glpk/glptsp.h:56:9`!; |
| 309 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "EXPLICIT") == 0) |
| 310 | tsp->edge_weight_typecxx . . $ TSP#edge_weight_type. = TSP_EXPLICITcxx . . $ `external/glpk/glptsp.h:52:9`!; |
| 311 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "CEIL_2D") == 0) |
| 312 | tsp->edge_weight_typecxx . . $ TSP#edge_weight_type. = TSP_CEIL_2Dcxx . . $ `external/glpk/glptsp.h:54:9`!; |
| 313 | else |
| 314 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: edge weight type `%s' not recognized\n", |
| 315 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., dsa->tokencxx . . $ dsa#token.); |
| 316 | goto fail; |
| 317 | } |
| 318 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: EDGE_WEIGHT_TYPE: %s\n", dsa->tokencxx . . $ dsa#token.); |
| 319 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 320 | } |
| 321 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "EDGE_WEIGHT_FORMAT") == 0) |
| 322 | { if (tsp->edge_weight_formatcxx . . $ TSP#edge_weight_format. != TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!) |
| 323 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!( |
| 324 | "%s:%d: EDGE_WEIGHT_FORMAT entry multiply defined\n", |
| 325 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 326 | goto fail; |
| 327 | } |
| 328 | if (check_coloncxx . . $ check_colon(bb135ed1a6c3747c).(dsa)) goto fail; |
| 329 | if (scan_keywordcxx . . $ scan_keyword(bb135ed1a6c3747c).(dsa)) goto fail; |
| 330 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "UPPER_ROW") == 0) |
| 331 | tsp->edge_weight_formatcxx . . $ TSP#edge_weight_format. = TSP_UPPER_ROWcxx . . $ `external/glpk/glptsp.h:63:9`!; |
| 332 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "FULL_MATRIX") == 0) |
| 333 | tsp->edge_weight_formatcxx . . $ TSP#edge_weight_format. = TSP_FULL_MATRIXcxx . . $ `external/glpk/glptsp.h:62:9`!; |
| 334 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "FUNCTION") == 0) |
| 335 | tsp->edge_weight_formatcxx . . $ TSP#edge_weight_format. = TSP_FUNCTIONcxx . . $ `external/glpk/glptsp.h:61:9`!; |
| 336 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "LOWER_DIAG_ROW") == 0) |
| 337 | tsp->edge_weight_formatcxx . . $ TSP#edge_weight_format. = TSP_LOWER_DIAG_ROWcxx . . $ `external/glpk/glptsp.h:65:9`!; |
| 338 | else |
| 339 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: edge weight format `%s' not recognized\n", |
| 340 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., dsa->tokencxx . . $ dsa#token.); |
| 341 | goto fail; |
| 342 | } |
| 343 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: EDGE_WEIGHT_FORMAT: %s\n", dsa->tokencxx . . $ dsa#token.); |
| 344 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 345 | } |
| 346 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "DISPLAY_DATA_TYPE") == 0) |
| 347 | { if (tsp->display_data_typecxx . . $ TSP#display_data_type. != TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!) |
| 348 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: DISPLAY_DATA_TYPE entry multiply defined\n", |
| 349 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 350 | goto fail; |
| 351 | } |
| 352 | if (check_coloncxx . . $ check_colon(bb135ed1a6c3747c).(dsa)) goto fail; |
| 353 | if (scan_keywordcxx . . $ scan_keyword(bb135ed1a6c3747c).(dsa)) goto fail; |
| 354 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "COORD_DISPLAY") == 0) |
| 355 | tsp->display_data_typecxx . . $ TSP#display_data_type. = TSP_COORD_DISPLAYcxx . . $ `external/glpk/glptsp.h:71:9`!; |
| 356 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "TWOD_DISPLAY") == 0) |
| 357 | tsp->display_data_typecxx . . $ TSP#display_data_type. = TSP_TWOD_DISPLAYcxx . . $ `external/glpk/glptsp.h:73:9`!; |
| 358 | else |
| 359 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: display data type `%s' not recognized\n", |
| 360 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., dsa->tokencxx . . $ dsa#token.); |
| 361 | goto fail; |
| 362 | } |
| 363 | xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: DISPLAY_DATA_TYPE: %s\n", dsa->tokencxx . . $ dsa#token.); |
| 364 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 365 | } |
| 366 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "NODE_COORD_SECTION") == 0) |
| 367 | { int n = tsp->dimensioncxx . . $ TSP#dimension., k, node; |
| 368 | if (n == 0) |
| 369 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: DIMENSION entry not specified\n", |
| 370 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 371 | goto fail; |
| 372 | } |
| 373 | if (tsp->node_x_coordcxx . . $ TSP#node_x_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 374 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: NODE_COORD_SECTION multiply specified\n", |
| 375 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 376 | goto fail; |
| 377 | } |
| 378 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 379 | tsp->node_x_coordcxx . . $ TSP#node_x_coord. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n, sizeof(double)); |
| 380 | tsp->node_y_coordcxx . . $ TSP#node_y_coord. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n, sizeof(double)); |
| 381 | for (node = 1; node <= n; node++) |
| 382 | tsp->node_x_coordcxx . . $ TSP#node_x_coord.[node] = tsp->node_y_coordcxx . . $ TSP#node_y_coord.[node] = DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!; |
| 383 | for (k = 1; k <= n; k++) |
| 384 | { if (scan_integercxx . . $ scan_integer(1fc27fedc07949e8).(dsa, 0, &node)) goto fail; |
| 385 | if (!(1 <= node && node <= n)) |
| 386 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: invalid node number %d\n", dsa->fnamecxx . . $ dsa#fname., |
| 387 | dsa->seqncxx . . $ dsa#seqn., node); |
| 388 | goto fail; |
| 389 | } |
| 390 | if (tsp->node_x_coordcxx . . $ TSP#node_x_coord.[node] != DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!) |
| 391 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: node number %d multiply specified\n", |
| 392 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., node); |
| 393 | goto fail; |
| 394 | } |
| 395 | if (scan_numbercxx . . $ scan_number(fc599f8022a8e44e).(dsa, 0, &tsp->node_x_coordcxx . . $ TSP#node_x_coord.[node])) |
| 396 | goto fail; |
| 397 | if (scan_numbercxx . . $ scan_number(fc599f8022a8e44e).(dsa, 0, &tsp->node_y_coordcxx . . $ TSP#node_y_coord.[node])) |
| 398 | goto fail; |
| 399 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 400 | } |
| 401 | } |
| 402 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "DISPLAY_DATA_SECTION") == 0) |
| 403 | { int n = tsp->dimensioncxx . . $ TSP#dimension., k, node; |
| 404 | if (n == 0) |
| 405 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: DIMENSION entry not specified\n", |
| 406 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 407 | goto fail; |
| 408 | } |
| 409 | if (tsp->dply_x_coordcxx . . $ TSP#dply_x_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 410 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: DISPLAY_DATA_SECTION multiply specified\n", |
| 411 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 412 | goto fail; |
| 413 | } |
| 414 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 415 | tsp->dply_x_coordcxx . . $ TSP#dply_x_coord. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n, sizeof(double)); |
| 416 | tsp->dply_y_coordcxx . . $ TSP#dply_y_coord. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n, sizeof(double)); |
| 417 | for (node = 1; node <= n; node++) |
| 418 | tsp->dply_x_coordcxx . . $ TSP#dply_x_coord.[node] = tsp->dply_y_coordcxx . . $ TSP#dply_y_coord.[node] = DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!; |
| 419 | for (k = 1; k <= n; k++) |
| 420 | { if (scan_integercxx . . $ scan_integer(1fc27fedc07949e8).(dsa, 0, &node)) goto fail; |
| 421 | if (!(1 <= node && node <= n)) |
| 422 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: invalid node number %d\n", dsa->fnamecxx . . $ dsa#fname., |
| 423 | dsa->seqncxx . . $ dsa#seqn., node); |
| 424 | goto fail; |
| 425 | } |
| 426 | if (tsp->dply_x_coordcxx . . $ TSP#dply_x_coord.[node] != DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!) |
| 427 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: node number %d multiply specified\n", |
| 428 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn., node); |
| 429 | goto fail; |
| 430 | } |
| 431 | if (scan_numbercxx . . $ scan_number(fc599f8022a8e44e).(dsa, 0, &tsp->dply_x_coordcxx . . $ TSP#dply_x_coord.[node])) |
| 432 | goto fail; |
| 433 | if (scan_numbercxx . . $ scan_number(fc599f8022a8e44e).(dsa, 0, &tsp->dply_y_coordcxx . . $ TSP#dply_y_coord.[node])) |
| 434 | goto fail; |
| 435 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 436 | } |
| 437 | } |
| 438 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "TOUR_SECTION") == 0) |
| 439 | { int n = tsp->dimensioncxx . . $ TSP#dimension., k, node; |
| 440 | if (n == 0) |
| 441 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: DIMENSION entry not specified\n", |
| 442 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 443 | goto fail; |
| 444 | } |
| 445 | if (tsp->tourcxx . . $ TSP#tour. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 446 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: TOUR_SECTION multiply specified\n", |
| 447 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 448 | goto fail; |
| 449 | } |
| 450 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 451 | tsp->tourcxx . . $ TSP#tour. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n, sizeof(int)); |
| 452 | for (k = 1; k <= n; k++) |
| 453 | { if (scan_integercxx . . $ scan_integer(1fc27fedc07949e8).(dsa, 1, &node)) goto fail; |
| 454 | if (!(1 <= node && node <= n)) |
| 455 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: invalid node number %d\n", dsa->fnamecxx . . $ dsa#fname., |
| 456 | dsa->seqncxx . . $ dsa#seqn., node); |
| 457 | goto fail; |
| 458 | } |
| 459 | tsp->tourcxx . . $ TSP#tour.[k] = node; |
| 460 | } |
| 461 | if (scan_integercxx . . $ scan_integer(1fc27fedc07949e8).(dsa, 1, &node)) goto fail; |
| 462 | if (node != -1) |
| 463 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: extra node(s) detected\n", dsa->fnamecxx . . $ dsa#fname., |
| 464 | dsa->seqncxx . . $ dsa#seqn.); |
| 465 | goto fail; |
| 466 | } |
| 467 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 468 | } |
| 469 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "EDGE_WEIGHT_SECTION") == 0) |
| 470 | { int n = tsp->dimensioncxx . . $ TSP#dimension., i, j, temp; |
| 471 | if (n == 0) |
| 472 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: DIMENSION entry not specified\n", |
| 473 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 474 | goto fail; |
| 475 | } |
| 476 | if (tsp->edge_weight_formatcxx . . $ TSP#edge_weight_format. == TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!) |
| 477 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: EDGE_WEIGHT_FORMAT entry not specified\n", |
| 478 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 479 | goto fail; |
| 480 | } |
| 481 | if (tsp->edge_weightcxx . . $ TSP#edge_weight. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 482 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: EDGE_WEIGHT_SECTION multiply specified\n", |
| 483 | dsa->fnamecxx . . $ dsa#fname., dsa->seqncxx . . $ dsa#seqn.); |
| 484 | goto fail; |
| 485 | } |
| 486 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 487 | tsp->edge_weightcxx . . $ TSP#edge_weight. = xcalloccxx . . $ `external/glpk/glpenv.h:171:9`!(1+n*n, sizeof(int)); |
| 488 | switch (tsp->edge_weight_formatcxx . . $ TSP#edge_weight_format.) |
| 489 | { case TSP_FULL_MATRIXcxx . . $ `external/glpk/glptsp.h:62:9`!: |
| 490 | for (i = 1; i <= n; i++) |
| 491 | { for (j = 1; j <= n; j++) |
| 492 | { if (scan_integercxx . . $ scan_integer(1fc27fedc07949e8).(dsa, 1, &temp)) goto fail; |
| 493 | tsp->edge_weightcxx . . $ TSP#edge_weight.[(i - 1) * n + j] = temp; |
| 494 | } |
| 495 | } |
| 496 | break; |
| 497 | case TSP_UPPER_ROWcxx . . $ `external/glpk/glptsp.h:63:9`!: |
| 498 | for (i = 1; i <= n; i++) |
| 499 | { tsp->edge_weightcxx . . $ TSP#edge_weight.[(i - 1) * n + i] = 0; |
| 500 | for (j = i + 1; j <= n; j++) |
| 501 | { if (scan_integercxx . . $ scan_integer(1fc27fedc07949e8).(dsa, 1, &temp)) goto fail; |
| 502 | tsp->edge_weightcxx . . $ TSP#edge_weight.[(i - 1) * n + j] = temp; |
| 503 | tsp->edge_weightcxx . . $ TSP#edge_weight.[(j - 1) * n + i] = temp; |
| 504 | } |
| 505 | } |
| 506 | break; |
| 507 | case TSP_LOWER_DIAG_ROWcxx . . $ `external/glpk/glptsp.h:65:9`!: |
| 508 | for (i = 1; i <= n; i++) |
| 509 | { for (j = 1; j <= i; j++) |
| 510 | { if (scan_integercxx . . $ scan_integer(1fc27fedc07949e8).(dsa, 1, &temp)) goto fail; |
| 511 | tsp->edge_weightcxx . . $ TSP#edge_weight.[(i - 1) * n + j] = temp; |
| 512 | tsp->edge_weightcxx . . $ TSP#edge_weight.[(j - 1) * n + i] = temp; |
| 513 | } |
| 514 | } |
| 515 | break; |
| 516 | default: |
| 517 | goto fail; |
| 518 | } |
| 519 | if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 520 | } |
| 521 | else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dsa->tokencxx . . $ dsa#token., "EOF") == 0) |
| 522 | { if (check_newlinecxx . . $ check_newline(bb135ed1a6c3747c).(dsa)) goto fail; |
| 523 | goto done; |
| 524 | } |
| 525 | else |
| 526 | { xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("%s:%d: keyword `%s' not recognized\n", dsa->fnamecxx . . $ dsa#fname., |
| 527 | dsa->seqncxx . . $ dsa#seqn., dsa->tokencxx . . $ dsa#token.); |
| 528 | goto fail; |
| 529 | } |
| 530 | goto loop; |
| 531 | done: xprintfcxx . . $ `external/glpk/glpenv.h:145:9`!("tsp_read_data: %d lines were read\n", dsa->seqncxx . . $ dsa#seqn.-1); |
| 532 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.); |
| 533 | return tsp; |
| 534 | fail: if (tsp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 535 | { if (tsp->namecxx . . $ TSP#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->namecxx . . $ TSP#name.); |
| 536 | if (tsp->commentcxx . . $ TSP#comment. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->commentcxx . . $ TSP#comment.); |
| 537 | if (tsp->node_x_coordcxx . . $ TSP#node_x_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->node_x_coordcxx . . $ TSP#node_x_coord.); |
| 538 | if (tsp->node_y_coordcxx . . $ TSP#node_y_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->node_y_coordcxx . . $ TSP#node_y_coord.); |
| 539 | if (tsp->dply_x_coordcxx . . $ TSP#dply_x_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->dply_x_coordcxx . . $ TSP#dply_x_coord.); |
| 540 | if (tsp->dply_y_coordcxx . . $ TSP#dply_y_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->dply_y_coordcxx . . $ TSP#dply_y_coord.); |
| 541 | if (tsp->tourcxx . . $ TSP#tour. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->tourcxx . . $ TSP#tour.); |
| 542 | if (tsp->edge_weightcxx . . $ TSP#edge_weight. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->edge_weightcxx . . $ TSP#edge_weight.); |
| 543 | xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp); |
| 544 | } |
| 545 | if (dsa->fpcxx . . $ dsa#fp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) fclosecxx . . $ fclose(89bc1efcdac0ca22).(dsa->fpcxx . . $ dsa#fp.); |
| 546 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 547 | } |
| 548 | |
| 549 | /*---------------------------------------------------------------------- |
| 550 | -- tsp_free_data - free TSP instance data. |
| 551 | -- |
| 552 | -- *Synopsis* |
| 553 | -- |
| 554 | -- #include "glptsp.h" |
| 555 | -- void tsp_free_data(TSP *tsp); |
| 556 | -- |
| 557 | -- *Description* |
| 558 | -- |
| 559 | -- The routine tsp_free_data frees all the memory allocated to the TSP |
| 560 | -- instance data block, which the parameter tsp points to. */ |
| 561 | |
| 562 | void tsp_free_datacxx . . $ `external/glpk/glptsp.h:90:9`!(TSPcxx . . $ TSP# *tsp) |
| 563 | { if (tsp->namecxx . . $ TSP#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->namecxx . . $ TSP#name.); |
| 564 | if (tsp->commentcxx . . $ TSP#comment. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->commentcxx . . $ TSP#comment.); |
| 565 | if (tsp->node_x_coordcxx . . $ TSP#node_x_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->node_x_coordcxx . . $ TSP#node_x_coord.); |
| 566 | if (tsp->node_y_coordcxx . . $ TSP#node_y_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->node_y_coordcxx . . $ TSP#node_y_coord.); |
| 567 | if (tsp->dply_x_coordcxx . . $ TSP#dply_x_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->dply_x_coordcxx . . $ TSP#dply_x_coord.); |
| 568 | if (tsp->dply_y_coordcxx . . $ TSP#dply_y_coord. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->dply_y_coordcxx . . $ TSP#dply_y_coord.); |
| 569 | if (tsp->tourcxx . . $ TSP#tour. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->tourcxx . . $ TSP#tour.); |
| 570 | if (tsp->edge_weightcxx . . $ TSP#edge_weight. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp->edge_weightcxx . . $ TSP#edge_weight.); |
| 571 | xfreecxx . . $ `external/glpk/glpenv.h:175:9`!(tsp); |
| 572 | return; |
| 573 | } |
| 574 | |
| 575 | /*---------------------------------------------------------------------- |
| 576 | -- tsp_distance - compute distance between two nodes. |
| 577 | -- |
| 578 | -- *Synopsis* |
| 579 | -- |
| 580 | -- #include "glptsp.h" |
| 581 | -- int tsp_distance(TSP *tsp, int i, int j); |
| 582 | -- |
| 583 | -- *Description* |
| 584 | -- |
| 585 | -- The routine tsp_distance computes the distance between i-th and j-th |
| 586 | -- nodes for the TSP instance, which tsp points to. |
| 587 | -- |
| 588 | -- *Returns* |
| 589 | -- |
| 590 | -- The routine tsp_distance returns the computed distance. */ |
| 591 | |
| 592 | #define nintcxx . . $ `external/glpk/glptsp.c:592:9`!(x) ((int)((x) + 0.5)) |
| 593 | |
| 594 | static double radcxx . . $ rad(447c67c6676f75c3).(double x) |
| 595 | { /* convert input coordinate to longitude/latitude, in radians */ |
| 596 | double pi = 3.141592, deg, min; |
| 597 | deg = (int)x; |
| 598 | min = x - deg; |
| 599 | return pi * (deg + 5.0 * min / 3.0) / 180.0; |
| 600 | } |
| 601 | |
| 602 | int tsp_distancecxx . . $ `external/glpk/glptsp.h:91:9`!(TSPcxx . . $ TSP# *tsp, int i, int j) |
| 603 | { int n = tsp->dimensioncxx . . $ TSP#dimension., dij; |
| 604 | if (!(tsp->typecxx . . $ TSP#type. == TSP_TSPcxx . . $ `external/glpk/glptsp.h:40:9`! || tsp->typecxx . . $ TSP#type. == TSP_ATSPcxx . . $ `external/glpk/glptsp.h:41:9`!)) |
| 605 | xfaultcxx . . $ `external/glpk/glptsp.c:29:9`!("tsp_distance: invalid TSP instance\n"); |
| 606 | if (!(1 <= i && i <= n && 1 <= j && j <= n)) |
| 607 | xfaultcxx . . $ `external/glpk/glptsp.c:29:9`!("tsp_distance: node number out of range\n"); |
| 608 | switch (tsp->edge_weight_typecxx . . $ TSP#edge_weight_type.) |
| 609 | { case TSP_UNDEFcxx . . $ `external/glpk/glptsp.h:70:9`!: |
| 610 | xfaultcxx . . $ `external/glpk/glptsp.c:29:9`!("tsp_distance: edge weight type not specified\n"); |
| 611 | case TSP_EXPLICITcxx . . $ `external/glpk/glptsp.h:52:9`!: |
| 612 | if (tsp->edge_weightcxx . . $ TSP#edge_weight. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 613 | xfaultcxx . . $ `external/glpk/glptsp.c:29:9`!("tsp_distance: edge weights not specified\n"); |
| 614 | dij = tsp->edge_weightcxx . . $ TSP#edge_weight.[(i - 1) * n + j]; |
| 615 | break; |
| 616 | case TSP_EUC_2Dcxx . . $ `external/glpk/glptsp.h:53:9`!: |
| 617 | if (tsp->node_x_coordcxx . . $ TSP#node_x_coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || tsp->node_y_coordcxx . . $ TSP#node_y_coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 618 | xfaultcxx . . $ `external/glpk/glptsp.c:29:9`!("tsp_distance: node coordinates not specified\n"); |
| 619 | { double xd, yd; |
| 620 | xd = tsp->node_x_coordcxx . . $ TSP#node_x_coord.[i] - tsp->node_x_coordcxx . . $ TSP#node_x_coord.[j]; |
| 621 | yd = tsp->node_y_coordcxx . . $ TSP#node_y_coord.[i] - tsp->node_y_coordcxx . . $ TSP#node_y_coord.[j]; |
| 622 | dij = nintcxx . . $ `external/glpk/glptsp.c:592:9`!(sqrt(xd * xd + yd * yd)); |
| 623 | } |
| 624 | break; |
| 625 | case TSP_CEIL_2Dcxx . . $ `external/glpk/glptsp.h:54:9`!: |
| 626 | if (tsp->node_x_coordcxx . . $ TSP#node_x_coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || tsp->node_y_coordcxx . . $ TSP#node_y_coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 627 | xfaultcxx . . $ `external/glpk/glptsp.c:29:9`!("tsp_distance: node coordinates not specified\n"); |
| 628 | { double xd, yd; |
| 629 | xd = tsp->node_x_coordcxx . . $ TSP#node_x_coord.[i] - tsp->node_x_coordcxx . . $ TSP#node_x_coord.[j]; |
| 630 | yd = tsp->node_y_coordcxx . . $ TSP#node_y_coord.[i] - tsp->node_y_coordcxx . . $ TSP#node_y_coord.[j]; |
| 631 | dij = (int)ceil(sqrt(xd * xd + yd * yd)); |
| 632 | } |
| 633 | break; |
| 634 | case TSP_GEOcxx . . $ `external/glpk/glptsp.h:55:9`!: |
| 635 | if (tsp->node_x_coordcxx . . $ TSP#node_x_coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || tsp->node_y_coordcxx . . $ TSP#node_y_coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 636 | xfaultcxx . . $ `external/glpk/glptsp.c:29:9`!("tsp_distance: node coordinates not specified\n"); |
| 637 | { double rrr = 6378.388; |
| 638 | double latitude_i = radcxx . . $ rad(447c67c6676f75c3).(tsp->node_x_coordcxx . . $ TSP#node_x_coord.[i]); |
| 639 | double latitude_j = radcxx . . $ rad(447c67c6676f75c3).(tsp->node_x_coordcxx . . $ TSP#node_x_coord.[j]); |
| 640 | double longitude_i = radcxx . . $ rad(447c67c6676f75c3).(tsp->node_y_coordcxx . . $ TSP#node_y_coord.[i]); |
| 641 | double longitude_j = radcxx . . $ rad(447c67c6676f75c3).(tsp->node_y_coordcxx . . $ TSP#node_y_coord.[j]); |
| 642 | double q1 = cos(longitude_i - longitude_j); |
| 643 | double q2 = cos(latitude_i - latitude_j); |
| 644 | double q3 = cos(latitude_i + latitude_j); |
| 645 | dij = (int)(rrr * acos(0.5 * ((1.0 + q1) * q2 - |
| 646 | (1.0 - q1) *q3)) + 1.0); |
| 647 | } |
| 648 | break; |
| 649 | case TSP_ATTcxx . . $ `external/glpk/glptsp.h:56:9`!: |
| 650 | if (tsp->node_x_coordcxx . . $ TSP#node_x_coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || tsp->node_y_coordcxx . . $ TSP#node_y_coord. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 651 | xfaultcxx . . $ `external/glpk/glptsp.c:29:9`!("tsp_distance: node coordinates not specified\n"); |
| 652 | { int tij; |
| 653 | double xd, yd, rij; |
| 654 | xd = tsp->node_x_coordcxx . . $ TSP#node_x_coord.[i] - tsp->node_x_coordcxx . . $ TSP#node_x_coord.[j]; |
| 655 | yd = tsp->node_y_coordcxx . . $ TSP#node_y_coord.[i] - tsp->node_y_coordcxx . . $ TSP#node_y_coord.[j]; |
| 656 | rij = sqrt((xd * xd + yd * yd) / 10.0); |
| 657 | tij = nintcxx . . $ `external/glpk/glptsp.c:592:9`!(rij); |
| 658 | if (tij < rij) dij = tij + 1; else dij = tij; |
| 659 | } |
| 660 | break; |
| 661 | default: |
| 662 | xassertcxx . . $ `external/glpk/glpenv.h:162:9`!(tsp->edge_weight_type != tsp->edge_weight_type); |
| 663 | } |
| 664 | return dij; |
| 665 | } |
| 666 | |
| 667 | /* eof */ |