Differences From Artifact [e055f9ba28]:

To Artifact [4bd66676aa]:


11
12
13
14
15
16
17




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

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




## Revision 1.19  2001/10/26 01:01:49  geraint
## fixcc when rdae_is_dae (-cr).
##
## Revision 1.18  2001/10/05 23:37:32  geraint
## Fixed assignment statement in ae.r when RHS=0.
##
## Revision 1.17  2001/07/27 23:29:10  geraint







>
>
>
>







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

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.20  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.19  2001/10/26 01:01:49  geraint
## fixcc when rdae_is_dae (-cr).
##
## Revision 1.18  2001/10/05 23:37:32  geraint
## Fixed assignment statement in ae.r when RHS=0.
##
## Revision 1.17  2001/07/27 23:29:10  geraint
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
        *)
                echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Create the reduce output code

def2write_r $optimise $1 cse 
def2write_r $optimise $1 csex # Version without E matrix
def2write_r $optimise $1 cseo


echo "Creating $1_cse.r $solve_msg $optimise_msg $fix_msg"
echo "Creating $1_csex.r $optimise_msg"
echo "Creating $1_cseo.r $optimise_msg"

# Remove the old log file
rm -f dae2cse_r.log

# Remove some files
rm -f $1_cse.r? $1_cseo.r?

# Use reduce to accomplish the transformation
$SYMBOLIC >dae2cse_r.log << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";








>




>








|







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
        *)
                echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

# Create the reduce output code
def2write_r $optimise $1 ae
def2write_r $optimise $1 cse 
def2write_r $optimise $1 csex # Version without E matrix
def2write_r $optimise $1 cseo

echo "Creating $1_ae.r $optimise_msg"
echo "Creating $1_cse.r $solve_msg $optimise_msg $fix_msg"
echo "Creating $1_csex.r $optimise_msg"
echo "Creating $1_cseo.r $optimise_msg"

# Remove the old log file
rm -f dae2cse_r.log

# Remove some files
rm -f $1_ae.r? $1_cse.r? $1_cseo.r?

# Use reduce to accomplish the transformation
$SYMBOLIC >dae2cse_r.log << EOF

%Read the formatting function
in "$MTTPATH/trans/reduce_matrix.r";

317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349












350
351
352
353
354
355
356
    set(lhs(MTT_sol_i),rhs(MTT_sol_i));
  END;

  % No algebraic variables left!
  MTTNYz := 0;
END; % IF MTTNyz>0 and $solve

OUT "$1_ae.r";
IF (MTTNyz>0) THEN % not $solve (or perhaps solution failed?)
BEGIN
    WRITE "MATRIX MTTyz(",MTTNyz,",1)";
    WRITE "%File: $1_ae.r";
    FOR i := 1:MTTNyz DO
	WRITE "MTTyz(",i,",1) := ",MTTyz(i,1)," +0";
END; % if MTTNyz>0 (and !$solve)
WRITE ";END;";
SHUT "$1_ae.r";

OUT "$1_aej.r";
IF (MTTNyz>0) THEN % as above
BEGIN
    WRITE "MATRIX MTTyzj(",MTTNyz,",",MTTNyz,")";
    WRITE "%File: $1_aej.r";
    FOR i := 1:MTTNyz DO
	FOR j := 1:MTTNyz DO
	BEGIN
	   didj := df(MTTyz(i,1),mkid('mttui,j));
	   IF (didj NEQ 0) THEN
	      WRITE "MTTyzj(",i,",",j,") := ",didj," +0";
	END;
END;
WRITE ";END;";
SHUT "$1_aej.r";













% Create the matrix declarations
OUT "$1_cse.r1";
write "%";
IF (MTTNx > 0) THEN
BEGIN
    write "MATRIX MTTEdx(", MTTNx, ",", 1, ")$"; 







<
<
<
<
<
<
<
<
<
<
<















>
>
>
>
>
>
>
>
>
>
>
>







323
324
325
326
327
328
329











330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
    set(lhs(MTT_sol_i),rhs(MTT_sol_i));
  END;

  % No algebraic variables left!
  MTTNYz := 0;
END; % IF MTTNyz>0 and $solve












OUT "$1_aej.r";
IF (MTTNyz>0) THEN % as above
BEGIN
    WRITE "MATRIX MTTyzj(",MTTNyz,",",MTTNyz,")";
    WRITE "%File: $1_aej.r";
    FOR i := 1:MTTNyz DO
	FOR j := 1:MTTNyz DO
	BEGIN
	   didj := df(MTTyz(i,1),mkid('mttui,j));
	   IF (didj NEQ 0) THEN
	      WRITE "MTTyzj(",i,",",j,") := ",didj," +0";
	END;
END;
WRITE ";END;";
SHUT "$1_aej.r";

IF MTTNyz>0 THEN % not $solve or solution failed
BEGIN
OUT "$1_ae.r1";
write "MATRIX MTTYZ(", MTTNyz, ",", 1, ")$";
SHUT "$1_ae.r1";
OUT "$1_ae.r2";
write "%File: $1_ae.r";
in ("$1_ae_write.r");
write "END;";
SHUT "$1_ae.r2";
END;

% Create the matrix declarations
OUT "$1_cse.r1";
write "%";
IF (MTTNx > 0) THEN
BEGIN
    write "MATRIX MTTEdx(", MTTNx, ",", 1, ")$"; 
443
444
445
446
447
448
449

450
451

452
453
454
455
456
457
458
in ("$1_cseo_write.r");
write "END;";
SHUT "$1_cseo.r2";
END;
quit;
EOF


touch $1_cseo.r1
touch $1_cseo.r2

cat $1_cse.r1 $1_cse.r2  > $1_cse.r
cat $1_csex.r1 $1_csex.r2  > $1_csex.r
cat $1_cseo.r1 $1_cseo.r2  > $1_cseo.r

if [ "$solve" = "1" ]; then
    echo "Setting MTTNyz=0 in $1_def.r and updating other $1_def files"
    gawk '{







>


>







450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
in ("$1_cseo_write.r");
write "END;";
SHUT "$1_cseo.r2";
END;
quit;
EOF

touch $1_ae.r1 $1_ae.r2
touch $1_cseo.r1
touch $1_cseo.r2
cat $1_ae.r1 $1_ae.r2 > $1_ae.r
cat $1_cse.r1 $1_cse.r2  > $1_cse.r
cat $1_csex.r1 $1_csex.r2  > $1_csex.r
cat $1_cseo.r1 $1_cseo.r2  > $1_cseo.r

if [ "$solve" = "1" ]; then
    echo "Setting MTTNyz=0 in $1_def.r and updating other $1_def files"
    gawk '{

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