Overview
Comment:Now does preferred causality of I and C.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 4064008eaacc54878ce89c630a618915491aa788b7572fa2ea36e36c507b32d1
User & Date: gawthrop@users.sourceforge.net on 1996-08-16 12:58:58
Other Links: branch diff | manifest | tags
Context
1996-08-16
13:04:46
Fixed problem with more than one output (y vector). check-in: 57084c7bf1 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:58:58
Now does preferred causality of I and C. check-in: 4064008eaa user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:51:22
Removed debugging lines. check-in: 92adf76dbd user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/abg2cbg.m from [86c7f41797] to [39c9487445].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27







+
+
+







% Acausal bond graph to causal bond graph: mfile format

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.6  1996/08/09 08:27:29  peter
% %% Added a few deguging lines
% %%
% %% Revision 1.5  1996/08/08 18:06:18  peter
% %% Unified file naming scheme
% %%
% %% Revision 1.4  1996/08/08 08:30:06  peter
% %% The cbg filename contains the system name - this makes things easier
% %% when setting up the m to fig translation and m to ese translation
% %%
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
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;

while done~=old_done
  disp(sprintf('Causality is %3.0f%s complete.', done, pc));
  old_done = done;
  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;


    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;
  
final_done =  (sum(status==zeros(n_components,1))/n_components)*100;;
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'
179
180
181
182
183
184
185




186
187
188
189
190
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211







+
+
+
+






% Return the port bonds
for i = 1:n_ports
  port_bonds(i,:) = bonds(i,:);
end;

disp('----------------------');










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