Differences From Artifact [23f6a7ee0b]:

To Artifact [1e301015c1]:


13
14
15
16
17
18
19




20
21
22
23
24
25
26
% [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$




% %% Revision 1.18  1997/08/08 08:11:04  peterg
% %% Suppress compoment trace.
% %%
% %% Revision 1.17  1997/08/07 16:10:13  peterg
% %% Move the if status ..  to the beginning of the main loop.
% %%
% %% Revision 1.16  1997/08/04 13:11:19  peterg







>
>
>
>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
% [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.19  1997/08/18 11:23:59  peterg
% %% Main component loop now misses out the ports (SS:[]) -- the causality
% %% is merely passed through these components.
% %%
% %% Revision 1.18  1997/08/08 08:11:04  peterg
% %% Suppress compoment trace.
% %%
% %% Revision 1.17  1997/08/07 16:10:13  peterg
% %% Move the if status ..  to the beginning of the main loop.
% %%
% %% Revision 1.16  1997/08/04 13:11:19  peterg
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170

  % Check compatibility - if ok copy port bonds to the internal bonds list.
  if n_port_bonds~=n_ports
  mtt_info(sprintf('%s: %1.0f port bonds incompatible with %1.0f ports', ...
               full_name, n_port_bonds, n_ports), infofile);

  else % Copy the port bonds & status
    j = abs(components(1:n_ports,1)); %relevant bond numbers
    bonds(j,:) = port_bonds;
    status(1:n_ports) = port_status;
  end
else
  n_port_bonds=0;
end;
bonds,port_bonds







|







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174

  % Check compatibility - if ok copy port bonds to the internal bonds list.
  if n_port_bonds~=n_ports
  mtt_info(sprintf('%s: %1.0f port bonds incompatible with %1.0f ports', ...
               full_name, n_port_bonds, n_ports), infofile);

  else % Copy the port bonds & status
    j = abs(components(1:n_ports,1)) % relevant bond numbers
    bonds(j,:) = port_bonds;
    status(1:n_ports) = port_status;
  end
else
  n_port_bonds=0;
end;
bonds,port_bonds
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
while( ci_index>0)
  old_done = inf;
  % Inner loop propagates causality
  while done~=old_done
   % disp(sprintf('Causality is %3.0f%s complete.', done, pc));
    old_done = done;
  
    for i = n_port_bonds+1:n_components
      if status(i) ~= 0 % only do this if causality not yet complete

	% Get the bonds on this component
	comp = nozeros(components(i,:))
	bond_list = abs(comp);
	direction = sign(comp)'*[1 1];
        n_bonds = length(bond_list);







|







183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
while( ci_index>0)
  old_done = inf;
  % Inner loop propagates causality
  while done~=old_done
   % disp(sprintf('Causality is %3.0f%s complete.', done, pc));
    old_done = done;
  
    for i = n_port_bonds+1:n_components % Miss out the ports 
      if status(i) ~= 0 % only do this if causality not yet complete

	% Get the bonds on this component
	comp = nozeros(components(i,:))
	bond_list = abs(comp);
	direction = sign(comp)'*[1 1];
        n_bonds = length(bond_list);
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
	if strcmp(comp_type,'1')
	  comp_type = 'one';
	end;
      
	% Component causality procedure name
	cause_name = [comp_type, '_cause'];
	
        % Bonds on this component (arrow-orientated)




      	port_bonds = bonds(bond_list,:);






      % Invoke  the appropriate causality procedure
      if exist(cause_name)~=2 % Try a compound component
        % Port status depends on whether the corresponding bonds are
        %  fully causal at this stage.
        one = ones(n_bonds,1);
        port_status = (sum(abs(port_bonds'))'==2*one) - one;
	[port_bonds,s] = abg2cbg(name, comp_type, full_name, 
            port_bonds, port_status, ...
	    typefile, infofile);
	
	% Create a single status from the status vector s
	if max(abs(s)) == 0 % Causal
	  status(i) = 0;
	else
	  if max(s) == 1 % At least one component is overcausal
	    status(i) = 1;
	  else           % no component is overcausal but some are undercausal
	    status(i) = -1;
	  end;
	end;

      else % its a simple component
	port_bonds_in = port_bonds

	% Convert from arrow orientated to component orientated causality
	port_bonds = port_bonds.*direction;
	
	disp(['---', name, ' (', cause_name, ') ---']);

        % Evaluate the built-in causality procedure
	eval([ '[port_bonds,status(i)] = ', cause_name, '(port_bonds);' ]);

       % and convert from component orientated to arrow orientated causality
       port_bonds = port_bonds.*direction; 
       
       port_bonds_out = port_bonds

      end;
      
      % Update the full bonds list
      bonds(bond_list,:) = port_bonds
    end;
    end;
    
    done = sum(sum(abs(bonds)))/total*100;
    %disp(sprintf('Causality is %3.0f%s complete.', done, pc), infofile));
    
  end;







|
>
>
>
>
|
>
>
>
>
>






|
|
|














|


|




|


|

|
<



|







206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260

261
262
263
264
265
266
267
268
269
270
271
	if strcmp(comp_type,'1')
	  comp_type = 'one';
	end;
      
	% Component causality procedure name
	cause_name = [comp_type, '_cause'];
	
        % Bonds on this component (arrow-orientated) -- these become the
        % port bonds on the ith component of this subsystem.
	
	% a bug in octave 1.92 (??) prevents this from working -- replace by
	% a loop -- but check on V2.0
      	% comp_bonds = bonds(bond_list,:)
	
	for kk = 1:n_comp
	  comp_bonds(kk,:) = bonds(comp(kk),:);
	end;
	

      % Invoke  the appropriate causality procedure
      if exist(cause_name)~=2 % Try a compound component
        % Port status depends on whether the corresponding bonds are
        %  fully causal at this stage.
        one = ones(n_bonds,1);
        port_status = (sum(abs(comp_bonds'))'==2*one) - one;
	[comp_bonds,s] = abg2cbg(name, comp_type, full_name, 
            comp_bonds, port_status, ...
	    typefile, infofile);
	
	% Create a single status from the status vector s
	if max(abs(s)) == 0 % Causal
	  status(i) = 0;
	else
	  if max(s) == 1 % At least one component is overcausal
	    status(i) = 1;
	  else           % no component is overcausal but some are undercausal
	    status(i) = -1;
	  end;
	end;

      else % its a simple component
	comp_bonds_in = comp_bonds

	% Convert from arrow orientated to component orientated causality
	comp_bonds = comp_bonds.*direction;
	
	disp(['---', name, ' (', cause_name, ') ---']);

        % Evaluate the built-in causality procedure
	eval([ '[comp_bonds,status(i)] = ', cause_name, '(comp_bonds);' ]);

       % and convert from component orientated to arrow orientated causality
       comp_bonds = comp_bonds.*direction; 
       
       comp_bonds_out = comp_bonds

      end;
      
      % Update the full bonds list
      bonds(bond_list,:) = comp_bonds
    end;
    end;
    
    done = sum(sum(abs(bonds)))/total*100;
    %disp(sprintf('Causality is %3.0f%s complete.', done, pc), infofile));
    
  end;
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
file_name = [full_name, '_cbg.m'];
disp(['Writing ', file_name]);
cbgfilenum = fopen(file_name,'w');
write_cbg(cbgfilenum,full_name,system_type,bonds,status);
fclose(cbgfilenum);

% Return the port bonds - arrow orientated causality
if ~at_top_level %Not at top level
  j = abs(components(1:n_ports,1)) %relevant bond numbers
  port_bonds = bonds(j,:)
end;

disp('====================================');
disp(['END: ', full_name, ' (', fun_name, ')']);
disp('====================================');








|








312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
file_name = [full_name, '_cbg.m'];
disp(['Writing ', file_name]);
cbgfilenum = fopen(file_name,'w');
write_cbg(cbgfilenum,full_name,system_type,bonds,status);
fclose(cbgfilenum);

% Return the port bonds - arrow orientated causality
if ~at_top_level % Not at top level
  j = abs(components(1:n_ports,1)) %relevant bond numbers
  port_bonds = bonds(j,:)
end;

disp('====================================');
disp(['END: ', full_name, ' (', fun_name, ')']);
disp('====================================');


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]