-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrunKT.m
More file actions
62 lines (50 loc) · 1.68 KB
/
runKT.m
File metadata and controls
62 lines (50 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function [structs] = runKT(dirName,T,M,ps,ktChs)
%RUNKT
masterfile = ['tempsave' num2str(cputime) '.mat'];
save(masterfile);
if nargin < 4
ps = setmyps(dirName,T,M);
end
if nargin < 5
ktChs = [1 1 1 1];
end
testStructsInds = setdiff([1 2 6 7] .* ktChs,0);
testDataInds = [1:length(ps.data)];
sindpair = reshape(repmat(testStructsInds,length(testDataInds),1), ...
[length(testStructsInds)*length(testDataInds) 1]);
dindpair = repmat(testDataInds', length(testStructsInds),1);
% pss = cell(length(testStructsInds), length(testDataInds));
names= cell(length(testDataInds),1);
structs = cell(length(testStructsInds), length(testDataInds));
llhistories = cell(length(testStructsInds), length(testDataInds));
modellls = cell(length(testStructsInds), length(testDataInds));
bestgraphs = cell(length(testStructsInds), length(testDataInds));
rind = 1;
for ind = 1:length(dindpair)
dind = dindpair(ind);
sind = sindpair(ind);
disp(['running: data:', ps.data{dind}, ' struct:' ps.structures{sind}]);
[mtmp stmp ntmp ltmp gtmp] = runmodel(ps, sind, dind, rind);
succ = 0;
while (succ == 0)
try
if exist(masterfile)
currps = ps; load(masterfile); ps = currps;
end
% pss{sind,dind,rind} = ps;
modellls{sind, dind} = mtmp;
structs{sind,dind} = stmp;
names{dind} = ntmp;
llhistories{sind, dind} = ltmp;
bestgraphs{sind,dind} = gtmp;
save(masterfile, 'modellls', 'structs', 'names', ...
'llhistories', 'bestgraphs');
succ = 1;
catch
succ = 0;
disp('error reading masterfile');
pause(10*rand);
end
end
end
end