Skip to content

Commit

Permalink
always perform cleanup for dqq, even on error
Browse files Browse the repository at this point in the history
  • Loading branch information
tpfau committed Nov 28, 2017
1 parent e334f6e commit 02994e6
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/base/solvers/solveCobraLP.m
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
% set the temporary path to the DQQ solver
tmpPath = [CBTDIR filesep 'binary' filesep computer('arch') filesep 'bin' filesep 'DQQ'];
cd(tmpPath);

cleanUp = onCleanup(@() DQQCleanup(tmpPath));
% create the
if ~exist([tmpPath filesep 'MPS'], 'dir')
mkdir([tmpPath filesep 'MPS'])
Expand Down Expand Up @@ -451,15 +451,6 @@
else
stat = -1; % Solution not optimal or solver problem
end
% cleanup
rmdir([tmpPath filesep 'results'], 's');
fortFiles = [4, 9, 10, 11, 12, 13, 60, 81];
for k = 1:length(fortFiles)
delete(['fort.', num2str(fortFiles(k))]);
end

% remove the temporary .mps model file
rmdir([tmpPath filesep 'MPS'], 's')

% return to original directory
cd(originalDirectory);
Expand Down Expand Up @@ -1769,3 +1760,20 @@
else
stat = -1; % Solution not optimal or solver problem
end


function DQQCleanup(tmpPath)
% perform cleanup after DQQ.
try
% cleanup
rmdir([tmpPath filesep 'results'], 's');
fortFiles = [4, 9, 10, 11, 12, 13, 60, 81];
for k = 1:length(fortFiles)
delete([tmpPath filesep 'fort.', num2str(fortFiles(k))]);
end
catch
end
try % remove the temporary .mps model file
rmdir([tmpPath filesep 'MPS'], 's')
catch
end

0 comments on commit 02994e6

Please sign in to comment.