-
Notifications
You must be signed in to change notification settings - Fork 0
/
displayEvolution.m
66 lines (55 loc) · 2.38 KB
/
displayEvolution.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
function [nodeUpdated, timeStateMatrix] = displayEvolution(node, k, mode, varargin)
% DISPLAYEVOLUTION Calculate and visualize evolution of NODE over K discrete time steps according to MODE update scheme
%
% DISPLAYEVOLUTION(NODE, K, MODE) advances all nodes in NODE K time steps in update mode defined
% by MODE and displays node states.
%
% DISPLAYEVOLUTION(NODE, K, MODE, TK, SAVEFLAG) advances all nodes in NODE K time steps in update mode defined
% by MODE and displays node states. All TK steps, node-states and the timeStateMatrix are saved to the current
% directory. Furthermore, if the SAVEFLAG is set, the figure is saved to the disk.
%
%
% Input:
% node - 1 x n structure-array containing node information
% k - Number of discrete timesteps
% mode - String defining update scheme. Currently supported modes are:
% CRBN, ARBN, DARBN, GARBN, DGARBN
% tk - (Optional) Period for saving node-states/timeStateMatrix to disk.
% saveFlag - (Optional) Flag: 1 - Figure will be saved to disk 0 - no saving
%
% Output:
% nodeUpdated - 1 x n structure-array with updated node information
% timeStateMatrix - n x k+1 matrix containing calculated time-state evolution
%
% Author: Christian Schwarzer - SSC EPFL
% CreationDate: 15.11.2002 LastModified: 20.01.2003
if (nargin == 3 | nargin == 4 | nargin == 5)
if(nargin == 5)
tk = varargin{1};
saveFlag = varargin{2};
else
tk = inf;
saveFlag = 0;
end
nodeUpdated = node;
switch mode
case 'CRBN'
fHandle = @evolveCRBN;
case 'ARBN'
fHandle = @evolveARBN;
case 'DARBN'
fHandle = @evolveDARBN;
case 'GARBN'
fHandle = @evolveGARBN;
case 'DGARBN'
fHandle = @evolveDGARBN;
otherwise
error('Unknown update mode. Type ''help displayEvolution'' to see supported modes')
end
timeStateMatrix = zeros(length(nodeUpdated),k+1);
% evolve network in specified update mode
[nodeUpdated timeStateMatrix(1:length(nodeUpdated),1:k+1)] = feval(fHandle,nodeUpdated,k,tk);
displayTimeStateMatrix(timeStateMatrix,saveFlag);
else
error('Wrong number of arguments. Type: help displayEvolution')
end