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