/farmR/src/glptsp.h

https://code.google.com/p/javawfm/ · C Header · 103 lines · 44 code · 10 blank · 49 comment · 0 complexity · 19655f375f0675d44617d0303d035dd3 MD5 · raw file

  1. /* glptsp.h (TSP format) */
  2. /***********************************************************************
  3. * This code is part of GLPK (GNU Linear Programming Kit).
  4. *
  5. * Copyright (C) 2000,01,02,03,04,05,06,07,08,2009 Andrew Makhorin,
  6. * Department for Applied Informatics, Moscow Aviation Institute,
  7. * Moscow, Russia. All rights reserved. E-mail: <mao@mai2.rcnet.ru>.
  8. *
  9. * GLPK is free software: you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * GLPK is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  17. * License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  21. ***********************************************************************/
  22. #ifndef _GLPTSP_H
  23. #define _GLPTSP_H
  24. typedef struct TSP TSP;
  25. struct TSP
  26. { /* TSP (or related problem) instance in the format described in
  27. the report [G.Reinelt, TSPLIB 95] */
  28. /*--------------------------------------------------------------*/
  29. /* the specification part */
  30. char *name;
  31. /* identifies the data file */
  32. int type;
  33. /* specifies the type of data: */
  34. #define TSP_UNDEF 0 /* undefined */
  35. #define TSP_TSP 1 /* symmetric TSP */
  36. #define TSP_ATSP 2 /* asymmetric TSP */
  37. #define TSP_TOUR 3 /* collection of tours */
  38. char *comment;
  39. /* additional comments (usually the name of the contributor or
  40. creator of the problem instance is given here) */
  41. int dimension;
  42. /* for a TSP or ATSP, the dimension is the number of its nodes
  43. for a TOUR it is the dimension of the corresponding problem */
  44. int edge_weight_type;
  45. /* specifies how the edge weights (or distances) are given: */
  46. #define TSP_UNDEF 0 /* undefined */
  47. #define TSP_EXPLICIT 1 /* listed explicitly */
  48. #define TSP_EUC_2D 2 /* Eucl. distances in 2-D */
  49. #define TSP_CEIL_2D 3 /* Eucl. distances in 2-D rounded up */
  50. #define TSP_GEO 4 /* geographical distances */
  51. #define TSP_ATT 5 /* special distance function */
  52. int edge_weight_format;
  53. /* describes the format of the edge weights if they are given
  54. explicitly: */
  55. #define TSP_UNDEF 0 /* undefined */
  56. #define TSP_FUNCTION 1 /* given by a function */
  57. #define TSP_FULL_MATRIX 2 /* given by a full matrix */
  58. #define TSP_UPPER_ROW 3 /* upper triangulat matrix (row-wise
  59. without diagonal entries) */
  60. #define TSP_LOWER_DIAG_ROW 4 /* lower triangular matrix (row-wise
  61. including diagonal entries) */
  62. int display_data_type;
  63. /* specifies how a graphical display of the nodes can be
  64. obtained: */
  65. #define TSP_UNDEF 0 /* undefined */
  66. #define TSP_COORD_DISPLAY 1 /* display is generated from the node
  67. coordinates */
  68. #define TSP_TWOD_DISPLAY 2 /* explicit coordinates in 2-D are
  69. given */
  70. /*--------------------------------------------------------------*/
  71. /* data part */
  72. /* NODE_COORD_SECTION: */
  73. double *node_x_coord; /* double node_x_coord[1+dimension]; */
  74. double *node_y_coord; /* double node_y_coord[1+dimension]; */
  75. /* DISPLAY_DATA_SECTION: */
  76. double *dply_x_coord; /* double dply_x_coord[1+dimension]; */
  77. double *dply_y_coord; /* double dply_y_coord[1+dimension]; */
  78. /* TOUR_SECTION: */
  79. int *tour; /* int tour[1+dimension]; */
  80. /* EDGE_WEIGHT_SECTION: */
  81. int *edge_weight; /* int edge_weight[1+dimension*dimension]; */
  82. };
  83. #define tsp_read_data _glp_tsp_read_data
  84. #define tsp_free_data _glp_tsp_free_data
  85. #define tsp_distance _glp_tsp_distance
  86. TSP *tsp_read_data(char *fname);
  87. /* read TSP instance data */
  88. void tsp_free_data(TSP *tsp);
  89. /* free TSP instance data */
  90. int tsp_distance(TSP *tsp, int i, int j);
  91. /* compute distance between two nodes */
  92. #endif
  93. /* eof */