Differences From Artifact [8b50fa41a2]:

To Artifact [117332d406]:


11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994, 1995, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.4  1998/04/07 05:45:12  peterg
## Reverted to an older version due to untraceable bug in new version
##
## Revision 1.3  1996/08/25 10:07:05  peter
## Remove a du state ment causaing touble
##      - but needs more work.
##







>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994, 1995, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.5  1998/04/07 08:12:12  peterg
## Added affine form.
##
## Revision 1.4  1998/04/07 05:45:12  peterg
## Reverted to an older version due to untraceable bug in new version
##
## Revision 1.3  1996/08/25 10:07:05  peter
## Remove a du state ment causaing touble
##      - but needs more work.
##
167
168
169
170
171
172
173

174
175
176
177
178

179
180

181

182

183

184
185
186
187
188
189

190
191
192
193
194
195
196
197

198








199
200
201
202
203
204
205
%    END;
%  END;


% Try and split the obs function into affine form (O(x,u) = o(x) + h(x)u)
affine := 1;
MTTNuu := (MTTGPCNu+1)*MTTNu;


IF affine=1 THEN
BEGIN
  MATRIX MTTObs_o(MTTNyy,1);
  MATRIX MTTObs_h(MTTNyy,MTTNuu);

  FOR i := 1:MTTNyy DO
  BEGIN

    MTTObs_o(i,1) := MTTYY(i,1);

    FOR j := 1:MTTNuu DO

    BEGIN

      %Expand as polynomial in uj
      coeffs := coeff(MTTObs_o(i,1), MTTu(j,1));
      MTTObs_o(i,1) := first(coeffs);
      IF length(coeffs)>1 THEN
        MTTObs_h(i,j) := second(coeffs);
      IF length(coeffs)>2 THEN affine := 0;

    END;
  END;
END;



%%Create the _obs.r file
OUT "$1_obs.r";

affine := affine;









mtt_matrix := MTTYY$
mtt_matrix_n := MTTNyy$
mtt_matrix_m := 1$
mtt_matrix_name := "MTTYY"$
reduce_matrix();








>

|
|


>


>

>
|
>

>
|
|


|
|
>


|
<




>
|
>
>
>
>
>
>
>
>







170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202

203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
%    END;
%  END;


% Try and split the obs function into affine form (O(x,u) = o(x) + h(x)u)
affine := 1;
MTTNuu := (MTTGPCNu+1)*MTTNu;
write "1 affine := ", affine, ";";

%IF (affine=1) THEN
%BEGIN
  MATRIX MTTObs_o(MTTNyy,1);
  MATRIX MTTObs_h(MTTNyy,MTTNuu);
write "2 affine := ", affine, ";";
  FOR i := 1:MTTNyy DO
  BEGIN
write "3 affine := ", affine, ";";
    MTTObs_o(i,1) := MTTYY(i,1);
    k := 0;
    FOR j := 1:MTTNu DO
    FOR jj := 0:MTTGPCNu DO
    BEGIN
      k := k+1;
      %Expand as polynomial in u_j^[jj]
      coeffs := coeff(MTTObs_o(i,1), MTTUU(j,jj+1));
      MTTObs_o(i,1) := first(coeffs);
      IF length(coeffs)>1 THEN
        MTTObs_h(i,k) := second(coeffs);
      IF length(coeffs)>2 THEN 
        affine := -1;
    END;
  END;
%END;



%%Create the _obs.r file
OUT "$1_obs.r";

IF affine=1 THEN
  write "affine := 1; % The O function is affine in u"
ELSE
  write "affine := 0; % The O function is not affine in u";


write "% The matrix sizes";
write "MTTNyy := ", MTTNyy, ";";
write "MTTNuu := ", MTTNuu, ";";

mtt_matrix := MTTYY$
mtt_matrix_n := MTTNyy$
mtt_matrix_m := 1$
mtt_matrix_name := "MTTYY"$
reduce_matrix();


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