alpar@9: /* glptsp.h (TSP format) */ alpar@9: alpar@9: /*********************************************************************** alpar@9: * This code is part of GLPK (GNU Linear Programming Kit). alpar@9: * alpar@9: * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, alpar@9: * 2009, 2010, 2011 Andrew Makhorin, Department for Applied Informatics, alpar@9: * Moscow Aviation Institute, Moscow, Russia. All rights reserved. alpar@9: * E-mail: . alpar@9: * alpar@9: * GLPK is free software: you can redistribute it and/or modify it alpar@9: * under the terms of the GNU General Public License as published by alpar@9: * the Free Software Foundation, either version 3 of the License, or alpar@9: * (at your option) any later version. alpar@9: * alpar@9: * GLPK is distributed in the hope that it will be useful, but WITHOUT alpar@9: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY alpar@9: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public alpar@9: * License for more details. alpar@9: * alpar@9: * You should have received a copy of the GNU General Public License alpar@9: * along with GLPK. If not, see . alpar@9: ***********************************************************************/ alpar@9: alpar@9: #ifndef GLPTSP_H alpar@9: #define GLPTSP_H alpar@9: alpar@9: typedef struct TSP TSP; alpar@9: alpar@9: struct TSP alpar@9: { /* TSP (or related problem) instance in the format described in alpar@9: the report [G.Reinelt, TSPLIB 95] */ alpar@9: /*--------------------------------------------------------------*/ alpar@9: /* the specification part */ alpar@9: char *name; alpar@9: /* identifies the data file */ alpar@9: int type; alpar@9: /* specifies the type of data: */ alpar@9: #define TSP_UNDEF 0 /* undefined */ alpar@9: #define TSP_TSP 1 /* symmetric TSP */ alpar@9: #define TSP_ATSP 2 /* asymmetric TSP */ alpar@9: #define TSP_TOUR 3 /* collection of tours */ alpar@9: char *comment; alpar@9: /* additional comments (usually the name of the contributor or alpar@9: creator of the problem instance is given here) */ alpar@9: int dimension; alpar@9: /* for a TSP or ATSP, the dimension is the number of its nodes alpar@9: for a TOUR it is the dimension of the corresponding problem */ alpar@9: int edge_weight_type; alpar@9: /* specifies how the edge weights (or distances) are given: */ alpar@9: #define TSP_UNDEF 0 /* undefined */ alpar@9: #define TSP_EXPLICIT 1 /* listed explicitly */ alpar@9: #define TSP_EUC_2D 2 /* Eucl. distances in 2-D */ alpar@9: #define TSP_CEIL_2D 3 /* Eucl. distances in 2-D rounded up */ alpar@9: #define TSP_GEO 4 /* geographical distances */ alpar@9: #define TSP_ATT 5 /* special distance function */ alpar@9: int edge_weight_format; alpar@9: /* describes the format of the edge weights if they are given alpar@9: explicitly: */ alpar@9: #define TSP_UNDEF 0 /* undefined */ alpar@9: #define TSP_FUNCTION 1 /* given by a function */ alpar@9: #define TSP_FULL_MATRIX 2 /* given by a full matrix */ alpar@9: #define TSP_UPPER_ROW 3 /* upper triangulat matrix (row-wise alpar@9: without diagonal entries) */ alpar@9: #define TSP_LOWER_DIAG_ROW 4 /* lower triangular matrix (row-wise alpar@9: including diagonal entries) */ alpar@9: int display_data_type; alpar@9: /* specifies how a graphical display of the nodes can be alpar@9: obtained: */ alpar@9: #define TSP_UNDEF 0 /* undefined */ alpar@9: #define TSP_COORD_DISPLAY 1 /* display is generated from the node alpar@9: coordinates */ alpar@9: #define TSP_TWOD_DISPLAY 2 /* explicit coordinates in 2-D are alpar@9: given */ alpar@9: /*--------------------------------------------------------------*/ alpar@9: /* data part */ alpar@9: /* NODE_COORD_SECTION: */ alpar@9: double *node_x_coord; /* double node_x_coord[1+dimension]; */ alpar@9: double *node_y_coord; /* double node_y_coord[1+dimension]; */ alpar@9: /* DISPLAY_DATA_SECTION: */ alpar@9: double *dply_x_coord; /* double dply_x_coord[1+dimension]; */ alpar@9: double *dply_y_coord; /* double dply_y_coord[1+dimension]; */ alpar@9: /* TOUR_SECTION: */ alpar@9: int *tour; /* int tour[1+dimension]; */ alpar@9: /* EDGE_WEIGHT_SECTION: */ alpar@9: int *edge_weight; /* int edge_weight[1+dimension*dimension]; */ alpar@9: }; alpar@9: alpar@9: #define tsp_read_data _glp_tsp_read_data alpar@9: #define tsp_free_data _glp_tsp_free_data alpar@9: #define tsp_distance _glp_tsp_distance alpar@9: alpar@9: TSP *tsp_read_data(char *fname); alpar@9: /* read TSP instance data */ alpar@9: alpar@9: void tsp_free_data(TSP *tsp); alpar@9: /* free TSP instance data */ alpar@9: alpar@9: int tsp_distance(TSP *tsp, int i, int j); alpar@9: /* compute distance between two nodes */ alpar@9: alpar@9: #endif alpar@9: alpar@9: /* eof */