-
Notifications
You must be signed in to change notification settings - Fork 0
/
evolveGARBN.m
74 lines (56 loc) · 2.31 KB
/
evolveGARBN.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
function [nodeUpdated, timeStateMatrix] = evolveGARBN(node, varargin)
% EVOLVEGARBN Develop network gradually K discrete time steps according to GARBN (Generalized
% Asynchronous Random Boolean Network) update scheme
%
% EVOLVEGARBN(NODE) advances all nodes in NODE one time-step in GARBN update mode.
%
% EVOLVEGARBN(NODE, K) advances all nodes in NODE K time-steps in GARBN update mode.
%
% EVOLVEGARBN(NODE, K, TK) advances all nodes in NODE K time-steps in GARBN update mode
% and saves all TK steps all node-states and the timeStateMatrix to the disk.
%
% Input:
% node - 1 x n structure-array containing node information
% k - (Optional) Number of time-steps
% tk - (Optional) Period for saving node-states/timeStateMatrix to disk.
%
% Output:
% nodeUpdated - 1 x n sturcture-array with updated node information
% ("lineNumber", "state", "nextState")
% timeStateMatrix - n x k+1 matrix containing calculated time-state evolution
% Author: Christian Schwarzer - SSC EPFL
% CreationDate: 20.11.2002 LastModified: 20.01.2003
switch nargin
case 1
k = 1;
tk = inf;
case 2
k = varargin{1};
tk = inf;
case 3
k = varargin{1};
tk = varargin{2};
otherwise
error('Wrong number of arguments. Type: help evolveGARBN');
end
nodeUpdated = resetNodeStats(node);
timeStateMatrix = zeros(length(nodeUpdated), k+1);
timeStateMatrix(1:length(nodeUpdated),1) = getStateVector(nodeUpdated)';
n = length(nodeUpdated);
% evolve network
for i=2:k+1
howManyNodes = randint(1,1,[0 n]);
nodeSelected = randint(1,howManyNodes,[1 n]);
nodeUpdated = setLUTLines(nodeUpdated);
nodeUpdated = setNodeNextState(nodeUpdated);
for j=1:length(nodeSelected)
nodeUpdated(nodeSelected(j)).state = nodeUpdated(nodeSelected(j)).nextState;
nodeUpdated(nodeSelected(j)).nbUpdates = nodeUpdated(nodeSelected(j)).nbUpdates + 1;
end
timeStateMatrix(1:length(nodeUpdated),i) = getStateVector(nodeUpdated)';
if(mod(i-1,tk) == 0)
saveMatrix(nodeUpdated);
saveMatrix(timeStateMatrix(:,1:i));
i-1; % display current time-step for user information
end
end