19 int i, j, n, Forwards;
25 FullFileName =
FullName(FileName, Cost);
28 printff(
"Writing%s: \"%s\" ... ",
32 assert(TourFile = fopen(FullFileName,
"w"));
34 fprintf(TourFile,
"COMMENT : Length = " GainFormat "\n", Cost);
35 fprintf(TourFile,
"COMMENT : Found by GLKH [Keld Helsgaun] %s",
37 fprintf(TourFile,
"TYPE : TOUR\n");
39 fprintf(TourFile,
"DIMENSION : %d\n", n);
40 fprintf(TourFile,
"TOUR_SECTION\n");
43 for (j = 1; j <= n; j++)
44 if (Tour[j] < Tour[i])
47 for (j = 1; j <= n; j++) {
48 fprintf(TourFile,
"%d\n", Tour[i]);
55 fprintf(TourFile,
"-1\nEOF\n");
69 char *NewName = 0, *CostBuffer, *Pos;
71 if (!(Pos = strstr(Name,
"$"))) {
72 assert(NewName = (
char *) calloc(strlen(Name) + 1, 1));
73 strcpy(NewName, Name);
76 assert(CostBuffer = (
char *) malloc(400));
81 (
char *) calloc(strlen(Name) + strlen(CostBuffer) + 1, 1));
82 strncpy(NewName, Name, Pos - Name);
83 strcat(NewName, CostBuffer);
84 strcat(NewName, Pos + 1);
87 while ((Pos = strstr(Name,
"$")));
void printff(char *fmt,...)
char * OutputTourFileName
void WriteTour(char *FileName, int *Tour, GainType Cost)
static char * FullName(char *Name, GainType Cost)