From 7c9f5a6c249d16950e93e7adbb88f04d59193ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Garc=C3=ADa=20Rodr=C3=ADguez?= Date: Mon, 24 Apr 2017 18:07:47 +0200 Subject: [PATCH] Fixing error with TSPLIB Fixing error with TSPLIB that was failing to compute the coordinates when the DistanceType was set to 'geo'. Completing documentation for tsplib.m and utils.TSPLIB.m. --- chn/+utils/@TSPLIB/tsplib.m | 12 +++++++++++- chn/tsplib.m | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/chn/+utils/@TSPLIB/tsplib.m b/chn/+utils/@TSPLIB/tsplib.m index 4bcea93..e62f81d 100644 --- a/chn/+utils/@TSPLIB/tsplib.m +++ b/chn/+utils/@TSPLIB/tsplib.m @@ -12,6 +12,16 @@ % DistanceMatrix - Distance matrix for the TSP % problem. % + % Example: + % Create a TSPLIB class for the 'berlin52' TSPLIB problem: + % + % problem = tsplib({'berlin52'}); + % + % Example: + % Obtain a list of TSPLIB problems with a solution: + % + % problems = utils.TSPLIB.problemNames(true,false); + % % See also tsphopfieldnetOptions, tsphopfieldnet. properties (GetAccess = public, SetAccess = private) @@ -93,7 +103,7 @@ fid = fclose(fid); %#ok if strcmp(problem(i).DistanceType,'GEO') - problem(i).Coordinates = tsplib.convert2LatLon(problem(i).Coordinates); %#TODO Should it be in the object instantation? + problem(i).Coordinates = utils.TSPLIB.convert2LatLon(problem(i).Coordinates); %#TODO Should it be in the object instantation? problem(i).DistanceMatrix = network.HopfieldNetworkTSP.computeDistance(problem(i).Coordinates,problem(i).DistanceType); elseif strcmp(problem(i).DistanceType,'EUC_2D') problem(i).DistanceMatrix = network.HopfieldNetworkTSP.computeDistance(problem(i).Coordinates,problem(i).DistanceType); diff --git a/chn/tsplib.m b/chn/tsplib.m index 3510e03..77a4d97 100644 --- a/chn/tsplib.m +++ b/chn/tsplib.m @@ -1,4 +1,22 @@ function problem = tsplib(name) +% tsplib Define a TSPLIB problem +% +% problem = tsplib(name) creates a TSPLIB [1] problem with relevant +% information to solve a TSP instance. +% +% [1] Reinelt, G. (1991). TSPLIB—A traveling salesman problem library. +% ORSA journal on computing, 3(4), 376-384. +% +% tsplib input arguments: +% +% name - TSPLIB problem name. +% +% Example: +% Create a TSPLIB class for the 'berlin52' TSPLIB problem: +% +% problem = tsplib({'berlin52'}); +% +% See also tsphopfieldnetOptions, tsphopfieldnet. problem = utils.TSPLIB(name);