Commit b42db53b by Sylvain

Add dryrun option to parameters

parent 716b7b2c
......@@ -123,6 +123,10 @@ By default, this program tries to resume from previous runs and does
not clobber already computed results. If you want to change this
behaviour and erase all results, set `overwrite` to true.
Another useful behaviour is controlled by the `dryrun` property that,
when set to true behaves as if `overwrite` were true without actually
writing down any results.
You can specify where various data files would be stored by tweaking
the following fields:
- `resultsPath` stores the raw results
......
......@@ -151,21 +151,25 @@ function runSimulation(smls, seqs, trksAll, varargin)
durations = [];
% The results file already exists; should we overwrite, resume, skip?
if exist(dataFilePath, 'file')
if (isfield(trk, 'overwrite') && meanYes(trk.overwrite)) ||...
(isfield(parameters, 'overwrite') && meanYes(parameters.overwrite))
fprintf(' Overwriting existing results\n');
else
load(dataFilePath, 'fullResult');
allTrkResults = fullResult.trkResults;
durations = fullResult.durations;
firstRun = length(fullResult.trkResults);
if firstRun < numRunsTrk
fprintf(' Resuming %d runs already done\n', length(allTrkResults));
if isfield(parameters, 'dryrun') && meanYes(parameters.dryrun)
fprintf(' Dry run, no data will be saved!\n');
else
if exist(dataFilePath, 'file')
if (isfield(trk, 'overwrite') && meanYes(trk.overwrite)) ||...
(isfield(parameters, 'overwrite') && meanYes(parameters.overwrite))
fprintf(' Overwriting existing results\n');
else
fprintf(' Enough number of runs: %d/%d\n', firstRun, numRunsTrk);
numTask = numTask + firstRun;
continue;
load(dataFilePath, 'fullResult');
allTrkResults = fullResult.trkResults;
durations = fullResult.durations;
firstRun = length(fullResult.trkResults);
if firstRun < numRunsTrk
fprintf(' Resuming %d runs already done\n', length(allTrkResults));
else
fprintf(' Enough number of runs: %d/%d\n', firstRun, numRunsTrk);
numTask = numTask + firstRun;
continue;
end
end
end
end
......@@ -208,25 +212,32 @@ function runSimulation(smls, seqs, trksAll, varargin)
durations(idxRun) = toc;
% Save results for this run if next fails
clear fullResult;
fullResult.durations = durations;
fullResult.trkResults = allTrkResults;
fullResult.sequence = seq;
fullResult.tracker = trk;
save(dataFilePath, 'fullResult');
if ~(isfield(parameters, 'dryrun') && meanYes(parameters.dryrun))
clear fullResult;
fullResult.durations = durations;
fullResult.trkResults = allTrkResults;
fullResult.sequence = seq;
fullResult.tracker = trk;
save(dataFilePath, 'fullResult');
end
numTask = numTask + 1;
end
cd(currentPath);
if length(allTrkResults) == 0
fprintf(' No data saved\n');
elseif length(allTrkResults) < numRunsTrk
fprintf(' Saving %d out of %d runs\n', length(allTrkResults), numRunsTrk);
save(dataFilePath, 'fullResult');
if isfield(parameters, 'dryrun') && meanYes(parameters.dryrun)
fprintf(' Dry run, no data saved\n');
else
fprintf(' Results written in ''%s''\n', dataFilePath);
save(dataFilePath, 'fullResult');
if length(allTrkResults) == 0
fprintf(' No data saved\n');
elseif length(allTrkResults) < numRunsTrk
fprintf(' Saving %d out of %d runs\n', length(allTrkResults), numRunsTrk);
save(dataFilePath, 'fullResult');
else
fprintf(' Results written in ''%s''\n', dataFilePath);
save(dataFilePath, 'fullResult');
end
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment