-
Notifications
You must be signed in to change notification settings - Fork 73
/
GsoChapterDemo2013.m
executable file
·229 lines (220 loc) · 11.7 KB
/
GsoChapterDemo2013.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
%%
%% Java Information Dynamics Toolkit (JIDT)
%% Copyright (C) 2012, Joseph T. Lizier
%%
%% This program is free software: you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by
%% the Free Software Foundation, either version 3 of the License, or
%% (at your option) any later version.
%%
%% This program is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%% GNU General Public License for more details.
%%
%% You should have received a copy of the GNU General Public License
%% along with this program. If not, see <http://www.gnu.org/licenses/>.
%%
% To recreate the plots in:
% J.T. Lizier, M. Prokopenko and A.Y. Zomaya, "A framework for the local information dynamics of distributed computation in complex systems", in Guided self-organisation: Inception, ed. M. Prokopenko, pp. 115-158, Springer, Berlin/Heidelberg, 2014; doi: 10.1007/978-3-642-53734-9_5, arXiv:0811.2690.
clear all;
% Set up simulation options:
cells = 10000;
timeSteps = 600;
neighbourhood = 3;
caStates = 2;
% Set up options for information dynamics analysis, and which segment of the CA to plot
measureParams.k=16;
options.saveImages = true;
options.saveImagesFormat = 'pdf';
options.plotOptions.scaleColoursToSubsetOfPlot = true;
scaleColoursToExtremesDefault = false;
options.plotOptions.scaleColoursToExtremes = scaleColoursToExtremesDefault;
% Turn up the contrast so that the small values aren't disproportionately visible: (0.15, 0.30 was good, except for separable which was better with 0.15, 0.35)
options.plotOptions.scalingMainComponent = 0.15;
options.plotOptions.scalingScdryComponent = 0.30;
options.plotOptions.gammaPower = 0.5;
%%%%%%%%%
% Examining rule 54:
options.plotOptions.plotRows = 35;
options.plotOptions.plotCols = 35;
options.plotOptions.plotStartRow = 150;
options.plotOptions.plotStartCol = 175;
options.seed = 2;
if (exist('initialStates/GsoChapterDemo2013-initialState.txt', 'file'))
% A file specifying the initial state exists -- this
% ensures that Matlab and Octave use the same initial state
% (otherwise only Octave recreates the same initial state used in our chapter).
% (You can delete/move the initial state file if you want them generated from scratch.)
options.initialState = load('initialStates/GsoChapterDemo2013-initialState.txt');
elseif (isfield(options, 'initialState'))
options = rmfield(options, 'initialState');
end
fprintf('\nStarting rule 54 ...\n');
fprintf('\nPlotting active info storage ...\n');
plotLocalInfoMeasureForCA(neighbourhood, caStates, 54, cells, timeSteps, 'active', measureParams, options);
fprintf('\nPress any key when ready for excess entropy ...\n');
pause
options.plotRawCa = false;
measureParams.k=8; % just for excess entropy
plotLocalInfoMeasureForCA(neighbourhood, caStates, 54, cells, timeSteps, 'excess', measureParams, options);
fprintf('\nPress any key when ready for apparent transfer entropy j = 1 ...\n');
pause
% Use the full red scale for transfer and separable info, since we need to see the extreme negative values properly
options.plotOptions.scaleColoursToExtremes = true;
options.plotOptions.scalingScdryComponent = 0.35;
options.plotOptions.scalingMainComponent = 0.35;
measureParams.k=16; % back to default
measureParams.j = 1;
plotLocalInfoMeasureForCA(neighbourhood, caStates, 54, cells, timeSteps, 'transfer', measureParams, options);
fprintf('\nPress any key when ready for apparent transfer entropy j = -1 ...\n');
pause
measureParams.j = -1;
plotLocalInfoMeasureForCA(neighbourhood, caStates, 54, cells, timeSteps, 'transfer', measureParams, options);
fprintf('\nPress any key when ready for the separable information ...\n');
pause
options.plotOptions.scalingMainComponent = 0.15; % Return to previous value
options.plotOptions.scalingScdryComponent = 0.35;
plotLocalInfoMeasureForCA(neighbourhood, caStates, 54, cells, timeSteps, 'separable', measureParams, options);
fprintf('\nPress any key when ready to apply to the next rule\n')
pause
options.plotOptions.scaleColoursToExtremes = scaleColoursToExtremesDefault; % return to default value
options.plotOptions.scalingScdryComponent = 0.30; % return to previous value
%%%%%%%%%
% Examining rule 110: (60, 60, 220, 230 is good but with only one collision)
options.plotRawCa = true;
options.plotOptions.plotRows = 50;
options.plotOptions.plotCols = 50;
options.plotOptions.plotStartRow = 50+20;
options.plotOptions.plotStartCol = 800+60;
options.seed = 2;
if (exist('initialStates/GsoChapterDemo2013-initialState.txt', 'file'))
% A file specifying the initial state exists -- this
% ensures that Matlab and Octave use the same initial state
% (otherwise only Octave recreates the same initial state used in our chapter).
% (You can delete/move the initial state file if you want them generated from scratch.)
options.initialState = load('initialStates/GsoChapterDemo2013-initialState.txt');
elseif (isfield(options, 'initialState'))
options = rmfield(options, 'initialState');
end
fprintf('\nStarting rule 110 ...\n');
fprintf('\nPlotting active info storage ...\n');
plotLocalInfoMeasureForCA(neighbourhood, caStates, 110, cells, timeSteps, 'active', measureParams, options);
fprintf('\nPress any key when ready for excess entropy ...\n');
pause
options.plotRawCa = false;
measureParams.k=8; % just for excess entropy
plotLocalInfoMeasureForCA(neighbourhood, caStates, 110, cells, timeSteps, 'excess', measureParams, options);
fprintf('\nPress any key when ready for entropy rate ...\n');
pause
measureParams.k=16; % back to default
plotLocalInfoMeasureForCA(neighbourhood, caStates, 110, cells, timeSteps, 'entropyrate', measureParams, options);
fprintf('\nPress any key when ready for apparent transfer entropy j = -1 ...\n');
pause
% Use the full red scale for transfer and separable info, since we need to see the extreme negative values properly
options.plotOptions.scaleColoursToExtremes = true;
measureParams.j = -1;
plotLocalInfoMeasureForCA(neighbourhood, caStates, 110, cells, timeSteps, 'transfer', measureParams, options);
fprintf('\nPress any key when ready for the separable information ...\n');
pause
options.plotOptions.scalingScdryComponent = 0.35;
plotLocalInfoMeasureForCA(neighbourhood, caStates, 110, cells, timeSteps, 'separable', measureParams, options);
fprintf('\nPress any key when ready to apply to the next rule\n')
pause
options.plotOptions.scaleColoursToExtremes = scaleColoursToExtremesDefault; % return to default value
options.plotOptions.scalingScdryComponent = 0.30; % return to previous value
%%%%%%%%%
% Examining rule phi_par:
% (75, 75, 12, 300 - is ok, but another collision would be good)
% (100, 100, 12, 500 - is very interesting, but perhaps slightly too complicated. Dynamics will lead to some strange colouring also)
options.plotRawCa = true;
options.plotOptions.plotRows = 70;
options.plotOptions.plotCols = 70;
options.plotOptions.plotStartRow = 17;
options.plotOptions.plotStartCol = 585;
options.seed = 2;
if (exist('initialStates/GsoChapterDemo2013-initialState-phipar.txt', 'file'))
% A file specifying the initial state exists -- this
% ensures that Matlab and Octave use the same initial state
% (otherwise only Octave recreates the same initial state used in our chapter).
% (You can delete/move the initial state file if you want them generated from scratch.)
options.initialState = load('initialStates/GsoChapterDemo2013-initialState-phipar.txt');
elseif (isfield(options, 'initialState'))
options = rmfield(options, 'initialState');
end
phi_par = 'feedffdec1aaeec0eef000a0e1a020a0';
phi_par_neighbourhood = 7;
phi_par_cells = 30000;
phi_par_timeSteps = 200;
measureParams.k=10; % Shorter for phi_par
fprintf('\nStarting rule phi_par ...\n');
fprintf('\nPlotting active info storage ...\n');
plotLocalInfoMeasureForCA(phi_par_neighbourhood, caStates, phi_par, phi_par_cells, phi_par_timeSteps, 'active', measureParams, options);
options.plotRawCa = false;
fprintf('\nPress any key when ready for apparent transfer entropy j = -1 ...\n');
pause
% Use the full red scale for transfer and separable info, since we need to see the extreme negative values properly
options.plotOptions.scaleColoursToExtremes = true;
measureParams.j = -1;
plotLocalInfoMeasureForCA(phi_par_neighbourhood, caStates, phi_par, phi_par_cells, phi_par_timeSteps, 'transfer', measureParams, options);
fprintf('\nPress any key when ready for complete transfer entropy j = -1 ...\n');
pause
plotLocalInfoMeasureForCA(phi_par_neighbourhood, caStates, phi_par, phi_par_cells, phi_par_timeSteps, 'transfercomplete', measureParams, options);
fprintf('\nPress any key when ready for apparent transfer entropy j = -3 ...\n');
pause
measureParams.j = -3;
plotLocalInfoMeasureForCA(phi_par_neighbourhood, caStates, phi_par, phi_par_cells, phi_par_timeSteps, 'transfer', measureParams, options);
fprintf('\nPress any key when ready for the separable information ...\n');
pause
options.plotOptions.scalingMainComponent = 0.35; % Make it easier to see stronger negatives
options.plotOptions.scalingScdryComponent = 0.45;
plotLocalInfoMeasureForCA(phi_par_neighbourhood, caStates, phi_par, phi_par_cells, phi_par_timeSteps, 'separable', measureParams, options);
fprintf('\nPress any key when ready to apply to the next rule\n')
pause
options.plotOptions.scaleColoursToExtremes = scaleColoursToExtremesDefault; % return to default value
options.plotOptions.scalingScdryComponent = 0.30; % return to previous value
options.plotOptions.scalingMainComponent = 0.15; % Return to previous value
measureParams.k=16; % back to default
%%%%%%%%%
% Examining rule 22:
options.plotOptions.plotRows = 50;
options.plotOptions.plotCols = 50;
options.plotOptions.plotStartRow = 150;
options.plotOptions.plotStartCol = 175;
options.seed = 2;
if (exist('initialStates/GsoChapterDemo2013-initialState.txt', 'file'))
% A file specifying the initial state exists -- this
% ensures that Matlab and Octave use the same initial state
% (otherwise only Octave recreates the same initial state used in our chapter).
% (You can delete/move the initial state file if you want them generated from scratch.)
options.initialState = load('initialStates/GsoChapterDemo2013-initialState.txt');
elseif (isfield(options, 'initialState'))
options = rmfield(options, 'initialState');
end
fprintf('\nStarting rule 22 ...\n');
fprintf('\nPlotting active info storage ...\n');
options.plotRawCa = true;
plotLocalInfoMeasureForCA(neighbourhood, caStates, 22, cells, timeSteps, 'active', measureParams, options);
fprintf('\nPress any key when ready for excess entropy ...\n');
pause
options.plotRawCa = false;
measureParams.k=8; % just for excess entropy
plotLocalInfoMeasureForCA(neighbourhood, caStates, 22, cells, timeSteps, 'excess', measureParams, options);
fprintf('\nPress any key when ready for entropy rate ...\n');
pause
measureParams.k=16; % back to default
plotLocalInfoMeasureForCA(neighbourhood, caStates, 22, cells, timeSteps, 'entropyrate', measureParams, options);
fprintf('\nPress any key when ready for apparent transfer entropy j = 1 ...\n');
pause
% Use the full red scale for transfer and separable info, since we need to see the extreme negative values properly
options.plotOptions.scaleColoursToExtremes = true;
measureParams.j = 1;
plotLocalInfoMeasureForCA(neighbourhood, caStates, 22, cells, timeSteps, 'transfer', measureParams, options);
fprintf('\nPress any key when ready for the separable information ...\n');
pause
options.plotOptions.scalingScdryComponent = 0.35;
plotLocalInfoMeasureForCA(neighbourhood, caStates, 22, cells, timeSteps, 'separable', measureParams, options);
fprintf('\nPress any key when ready to apply to the next rule\n')
pause
options.plotOptions.scaleColoursToExtremes = scaleColoursToExtremesDefault; % return to default value
options.plotOptions.scalingScdryComponent = 0.30; % return to previous value