Skip to content

Commit

Permalink
Fixing issue when logging simulation using CheckpointPath
Browse files Browse the repository at this point in the history
The method loggingV was not being called correctly.
  • Loading branch information
mathinking committed Apr 24, 2017
1 parent 5143201 commit 18c081b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion chn/+network/@HopfieldNetworkTSP/fixedCities.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
% Starting point V is automatically modified to take into
% account all connections that have been fixed.
for c = 1:length(tourOrder)
V(tourOrder(c),tsphopfieldnet.modulo(net.Cities.SubtoursPositions(f) + c-1,net.TrainParam.N)) = 1;
V(tourOrder(c),net.modulo(net.Cities.SubtoursPositions(f) + c-1,net.TrainParam.N)) = 1;
end
end
% Neurons whose cities and positions have not been fixed are
Expand Down
20 changes: 10 additions & 10 deletions chn/+network/@HopfieldNetworkTSP/sim.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
net = reinit(net);

if ~isfield(net.TrainParam,'Np')
error('tsphopfieldnet:NotTrained', 'Training has not taken place yet. Use train(net).');
error('HopfieldNetworkTSP:NotTrained', 'Training has not taken place yet. Use train(net).');
end

if ~isempty(net.Cities.Subtours)
tsphopfieldnet.verifyIfValidSubtours(net.Cities.Subtours, net.Cities.SubtoursPositions, net.Cities.Names)
net.verifyIfValidSubtours(net.Cities.Subtours, net.Cities.SubtoursPositions, net.Cities.Names)
aux_d = net.Cities.DistanceMatrix;
[net,V,U] = fixedCities(net); %Review fixedCities
end
Expand All @@ -51,7 +51,7 @@
end

else
error('tsphopfieldnet:UnknownsimFcn', 'Unknown training algorithm');
error('HopfieldNetworkTSP:UnknownsimFcn', 'Unknown training algorithm');
end

if ~isempty(net.Cities.Subtours)
Expand Down Expand Up @@ -116,7 +116,7 @@

if ~isempty(net.Setting.CheckpointPath) || net.Setting.SimulationPlot
if ~isempty(net.Setting.CheckpointPath)
tsphopfieldnet.loggingV(fullfile(net.Setting.CheckpointPath, ...
net.loggingV(fullfile(net.Setting.CheckpointPath, ...
net.Results.CheckpointFilename),...
net.Setting.MaxIter,iter,N);
end
Expand Down Expand Up @@ -170,7 +170,7 @@
iter = iter + 1;
if ~isempty(net.Setting.CheckpointPath) || net.Setting.SimulationPlot
if ~isempty(net.Setting.CheckpointPath)
tsphopfieldnet.loggingV(fullfile(net.Setting.CheckpointPath,...
net.loggingV(fullfile(net.Setting.CheckpointPath,...
net.Results.CheckpointFilename),...
net.Setting.MaxIter,iter,[],V,dU);
end
Expand Down Expand Up @@ -225,7 +225,7 @@
if ~any(strcmp({ST.name},'saddle'))
if ~isempty(net.Setting.CheckpointPath) || net.Setting.SimulationPlot
if ~isempty(net.Setting.CheckpointPath)
tsphopfieldnet.loggingV(fullfile(net.Setting.CheckpointPath, ...
net.loggingV(fullfile(net.Setting.CheckpointPath, ...
net.Results.CheckpointFilename),...
net.Setting.MaxIter,iter,N-K);
end
Expand Down Expand Up @@ -368,9 +368,9 @@
if ~any(strcmp({ST.name},'saddle'))
if ~isempty(net.Setting.CheckpointPath) || net.Setting.SimulationPlot
if ~isempty(net.Setting.CheckpointPath)
tsphopfieldnet.loggingV(fullfile(net.Setting.CheckpointPath,...
net.loggingV(fullfile(net.Setting.CheckpointPath,...
net.Results.CheckpointFilename),...
net.Setting.maxIter,iter,[],V,dU);
net.Setting.MaxIter,iter,[],V,dU);
end
if net.Setting.SimulationPlot
fV = viewConvergence(iter,V,net,fV);
Expand Down Expand Up @@ -669,7 +669,7 @@
newCoordinates = [];
end

newOptions = tsphopfieldnetOptions(...
newOptions = options.HopfieldNetworkTSPOptions(...
'R_Iter' , net.Setting.R_Iter ,...
'Dt' , net.Setting.Dt ,...
'E' , net.Setting.E ,...
Expand All @@ -687,7 +687,7 @@



netPhase2 = tsphopfieldnet(length(newCities),net.TrainParam.C,newOptions);
netPhase2 = network.HopfieldNetworkTSP(length(newCities),net.TrainParam.C,newOptions);
netPhase2.Setting.transferFcn = net.Setting.TransferFcn;
netPhase2.Setting.InvTransferFcn = net.Setting.InvTransferFcn;

Expand Down

0 comments on commit 18c081b

Please sign in to comment.