Skip to content

Commit

Permalink
Fixing error with TSPLIB
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mathinking committed Apr 24, 2017
1 parent e171753 commit 7c9f5a6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
12 changes: 11 additions & 1 deletion chn/+utils/@TSPLIB/tsplib.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -93,7 +103,7 @@
fid = fclose(fid); %#ok<NASGU>

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);
Expand Down
18 changes: 18 additions & 0 deletions chn/tsplib.m
Original file line number Diff line number Diff line change
@@ -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);

Expand Down

0 comments on commit 7c9f5a6

Please sign in to comment.