-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
167 lines (128 loc) · 4.79 KB
/
main.m
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
function [] = main(analysisName, jobID, testRun)
% test run = false by default
if nargin<3
testRun=false;
end
% add filepaths to matlab search path
paths = addPaths();
% create output directory
if ~exist(paths.outputs, "dir")
mkdir(paths.outputs)
end
% get configurations
config = getConfig(analysisName, testRun);
%% run analysis
switch analysisName
case 'analysis01A'
% analysis 01A: evolving populations
% Relationship between emergence and prediction performance across
% predictions tasks and in neuromorphic and random reservoirs.
% (run with JobIDs 1-120)
% extract configs for this job
config.populationProperties = table2struct(config.populationProperties(jobID, :));
config.seed = config.seed(jobID);
% add Ctype-specific reservoir network
if strcmp(config.populationProperties.Ctype, 'human')
% add human connectome for neuromorphic reservoir populations
sc = getConfig();
config.populationProperties.C = sc.C;
elseif strcmp(config.populationProperties.Ctype, 'random')
% add [] for random reservoir populations
config.populationProperties.C = [];
end
% run analysis
results = analysis01A(config);
% define file name for saving outputs
filename = [analysisName, '_', ...
config.populationProperties.Ctype, '_', ...
config.populationProperties.Env, '_', ...
num2str(config.seed), '.mat'];
case 'analysis01B'
% analysis 01B:
% Loss and psi are also linked when varying training time only.
% (run with single JobID 1)
% run analysis
tic
results = analysis01B(config);
toc
% define output file name
filename = [analysisName, '_', config.environment, '_', num2str(jobID), '.mat'];
case 'analysis01C'
% analysis 01C:
% Breaking the recurrence by comparing psi of trained vs. random output.
% (run with JobIDs 1-2)
% fetch optimization criterion based on jobID
% (which determines Reservoir default parameters)
config.optimisedFor = config.optimisedFor(1+mod(jobID, length(config.optimisedFor)));
% run analysis
tic
results = analysis01C(config);
toc
% define output file name
filename = [analysisName, '_', num2str(jobID), '.mat'];
%filename = ['analysis01C_', config.optimisedFor{:}, '.mat'];
case 'analysis01D'
% analysis 01D
% Test the hypothesis: P(success|emergence)>P(success)
% (run with jobIDs 1-4)
% set seed according to jobID
config.seed = config.seeds(jobID);
% run analysis
tic
results = analysis01D(config);
toc
% define output file name
filename = [analysisName, '_', num2str(jobID), '.mat'];
case 'analysis02G1'
% analysis 02G: Generalisability analysis part 1 - evolving populations
% for both prediction performance and emergence.
% (run with JobIDs 1-200)
% extract configs for this job
config.populationProperties = table2struct(config.populationProperties(jobID, :));
config.seed = config.seed(jobID);
% add human connectome for neuromorphic reservoir populations
sc = getConfig();
config.populationProperties.C = sc.C;
% run analysis
tic
results = analysis02G1(config);
toc
% define file name for saving outputs
filename = [analysisName, '_', ...
config.populationProperties.Env, '_', ...
'alpha', num2str(config.alpha(jobID)), '_', ...
num2str(config.seed), '.mat'];
case 'analysis02G2'
% analysis 02G2: Generalisability analysis part 2 - evaluating
% populations that were evolved in 02G part 1 on unseen data.
% (run as single job, i.e. jobID=1)
% run analysis
tic
results = analysis02G2(config);
toc
% define output file name
filename = [analysisName, '_', num2str(jobID), '.mat'];
case 'analysis03A'
% analysis 03A:
% Neuromorphic vs. randomly connected reservoirs.
% (run as single job, i.e. jobID = 1)
% run analysis
tic
results = analysis03A(config);
toc
% define output file name
filename = [analysisName, '_', num2str(jobID), '.mat'];
otherwise
error(strcat("unknown analysis ", analysisName))
end
%% save outputs
% create output directory, if it doesn't exist
cd(paths.outputs)
if ~exist(analysisName, "dir")
mkdir(analysisName)
end
% cd into output directory and save files
cd(analysisName)
save(filename, "results", "config")
cd(paths.main)
end