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
|
mtt_info(sprintf('%1.0f port bonds incompatible with %1.0f ports', ...
n_port_bonds, n_ports), infofile);
else % Copy the port bonds
for i = 1:n_ports
bonds(i,:) = port_bonds(i,:);
end;
end;
% Set initial status
status = -ones(n_components,1);
total = 2*n_bonds;
done = sum(sum(abs(bonds)))/total*100;
old_done = inf;
while done~=old_done
disp(sprintf('Causality is %3.0f%s complete.', done, pc));
old_done = done;
for i = 1:n_components
comp = nozeros(components(i,:));
bond_list = abs(comp);
direction = sign(comp)'*[1 1];
% Convert from arrow orientated to component orientated causality
comp_bonds = bonds(bond_list,:).*direction;
eval([ '[comp_type,name,cr,arg] = ', system_type, '_cmp(i);' ]);
% change name of 0 and 1 components -- matlab doesn't like numbers here
if strcmp(comp_type,'0')
comp_type = 'zero';
end;
if strcmp(comp_type,'1')
comp_type = 'one';
end;
% Component causality procedure name
cause_name = [comp_type, '_cause'];
% Invoke the appropriate causality procedure
if exist(cause_name)~=2 % Try a compound component
disp('------------PUSH-----------------');
[comp_bonds,s] = abg2cbg(name, comp_type, full_name, comp_bonds, ...
infofile);
status(i)=max(abs(s));
disp('------------POP-----------------');
else % its a simple component
disp(['---', name, ' (', cause_name, ') ---']);
comp_bonds
eval([ '[comp_bonds,status(i)] = ', cause_name, '(comp_bonds);' ]);
comp_bonds
end;
% Update the full bonds list
% and convert from component orientated to arrow orientated causality
bonds(bond_list,:) = comp_bonds.*direction;
end;
done = sum(sum(abs(bonds)))/total*100;
% mtt_info(sprintf('Causality is %3.0f%s complete.', done, pc), infofile);
end;
final_done = (sum(status==zeros(n_components,1))/n_components)*100;;
mtt_info(sprintf('Final causality is %3.0f%s complete.', final_done, pc),
infofile);
% List overcausal bonds
[over_causal_bonds,n] = getindex(status,1);
if n>0
for i=over_causal_bonds'
|
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
|
<
>
>
>
|
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
|
mtt_info(sprintf('%1.0f port bonds incompatible with %1.0f ports', ...
n_port_bonds, n_ports), infofile);
else % Copy the port bonds
for i = 1:n_ports
bonds(i,:) = port_bonds(i,:);
end;
end;
% Set initial status
status = -ones(n_components,1);
total = 2*n_bonds;
done = sum(sum(abs(bonds)))/total*100;
% Outer while loop sets preferred causality
ci_index=1;
while ci_index>0
old_done = inf;
% Inner loop propogates causality
while done~=old_done
disp(sprintf('Causality is %3.0f%s complete.', done, pc));
old_done = done;
for i = 1:n_components
comp = nozeros(components(i,:));
bond_list = abs(comp);
direction = sign(comp)'*[1 1];
% Convert from arrow orientated to component orientated causality
comp_bonds = bonds(bond_list,:).*direction;
eval([ '[comp_type,name,cr,arg] = ', system_type, '_cmp(i);' ]);
% change name of 0 and 1 components -- matlab doesn't like numbers here
if strcmp(comp_type,'0')
comp_type = 'zero';
end;
if strcmp(comp_type,'1')
comp_type = 'one';
end;
% Component causality procedure name
cause_name = [comp_type, '_cause'];
% Invoke the appropriate causality procedure
if exist(cause_name)~=2 % Try a compound component
% disp('------------PUSH-----------------');
[comp_bonds,s] = abg2cbg(name, comp_type, full_name, comp_bonds, ...
infofile);
status(i)=max(abs(s));
% disp('------------POP-----------------');
else % its a simple component
% disp(['---', name, ' (', cause_name, ') ---']);
% comp_bonds
eval([ '[comp_bonds,status(i)] = ', cause_name, '(comp_bonds);' ]);
% comp_bonds
end;
% Update the full bonds list
% and convert from component orientated to arrow orientated causality
bonds(bond_list,:) = comp_bonds.*direction;
end;
done = sum(sum(abs(bonds)))/total*100;
% mtt_info(sprintf('Causality is %3.0f%s complete.', done, pc), infofile);
end;
% Set causality of C and I which is not set
[ci_index,prefered] = getdynamic(status,system_type);
if ci_index>0
bond_index = components(ci_index,1) % its a one port
bonds(bond_index,1) = prefered;
bonds(bond_index,2) = prefered;
end;
end;
% Print final causality
final_done = (sum(status==zeros(n_components,1))/n_components)*100;;
mtt_info(sprintf('Final causality is %3.0f%s complete.', final_done, pc),
infofile);
% List overcausal bonds
[over_causal_bonds,n] = getindex(status,1);
if n>0
for i=over_causal_bonds'
|