Differences From Artifact [ef5ba91cfc]:

To Artifact [f51b569efb]:


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







+
+
+







# Copyright (c) P.J.Gawthrop 1991, 1992, 1994.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.10  1998/11/18 13:50:29  peterg
## Removed writeing of EYz matrix
##
## Revision 1.9  1998/11/18 10:53:38  peterg
## Put in some more "IF MTTNx>0 THEN" to avoid error messages when no
## states.
##
## Revision 1.8  1998/11/10 08:54:34  peterg
## Put in "IF MTTNx>0 THEN" to prevent probs when Nx=0
##  -- still a couple of apparent error messages - but answers now
55
56
57
58
59
60
61
62

63
64

65
66











67
68
69
70
71
72
73
74
75
76
58
59
60
61
62
63
64
65
66
67

68


69
70
71
72
73
74
75
76
77
78
79
80
81

82
83
84
85
86
87
88








+

-
+
-
-
+
+
+
+
+
+
+
+
+
+
+


-







## Sorted out bug when MTTNz=0
##
## Revision 1.1  1996/08/15 16:47:02  peter
## Initial revision
##
###############################################################



#Explicit solution option
Solving=$2;
solve=0
if [ "$Solving" = "Solving" ]; then
    solve=1
while [ -n "`echo $1 | grep '^-'`" ]; do
  case $1 in
	-A )
                solve=1;;
	*)
		echo "$1 is an invalid argument - ignoring" ;;
  esac
  shift
done

if [ "$solve" = "1" ]; then
    echo "Creating $1_cse.r (with explicit solution of algebraic equations)"
else
    solve=0
    echo "Creating $1_cse.r"
fi

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

# Use reduce to accomplish the transformation
225
226
227
228
229
230
231

232
233

234

235

236
237
238
239
240
241
242
237
238
239
240
241
242
243
244
245
246
247
248
249

250
251
252
253
254
255
256
257







+


+

+
-
+








  %Create list of the relevant unknowns
  MTT_unknowns := {};
  FOR i := 1:MTTNyz DO
    MTT_unknowns := append(MTT_unknowns,{MTTUi(i,1)});

  %Solve the algebraic equations symbolically
    MTT_sol := solve(MTT_eqns,MTT_unknowns);
  %The result seems to be in an extra list - I don't know why
  % So remove the outer list with first.
  % But only if more than one list element!

  if MTTNyz>1 THEN
  MTT_sol := first(solve(MTT_eqns,MTT_unknowns));
    MTT_sol := first(MTT_sol);

  %Substitute back into the equations
  FOR i := 1:MTTNyz DO
  BEGIN
    MTT_sol_i := first(MTT_sol); MTT_sol := rest(MTT_sol);
    set(lhs(MTT_sol_i),rhs(MTT_sol_i));
  END;
297
298
299
300
301
302
303















304
305
306
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+




write ";END;";

SHUT "$1_cse.r";
quit;

EOF

if [ "$solve" = "1" ]; then
    echo "Setting MTTNyz=0 in $1_def.r and removing other $1_def files"
    awk '{
     if ($1=="MTTNyz") 
       print "MTTNyz := 0;" 
     else print $0
    }' $1_def.r > mtt_junk
  # Make sure it preserves the time stamp!!
  # and remove dependent reps
   touch -r $1_def.r mtt_junk
   rm $1_def.*
   mv mtt_junk $1_def.r
fi


# Now invoke the standard error handling.
mtt_error_r dae2cse_r.log

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