/
ReduceDAE.mo
2322 lines (2008 loc) · 93.4 KB
/
ReduceDAE.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
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
161
162
163
164
165
166
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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
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
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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2010, Linköpings University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC
* LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF
* THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC
* PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linköpings University, either from the above address,
* from the URL: http://www.ida.liu.se/projects/OpenModelica
* and in the OpenModelica distribution.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
// two functions "addLabelToExpList" and "addLabelToExpListForSubstitution", were commented in old version
encapsulated package ReduceDAE
public import Absyn;
public import BackendDAE;
public import BackendVarTransform;
public import DAE;
public import Expression;
public import List;
public import SimCode;
public import SimCodeFunction;
public import SimCodeVar;
protected
import ComponentReference;
import Debug;
import Differentiate;
import ExpressionDump;
import ExpressionSimplify;
import Flags;
import Util;
import AbsynUtil;
public constant String LABELNAME="label";
public function buildLabels
"main function for labeling equations -- needed for ranking procedure"
input list<SimCode.SimEqSystem> inEquationLst; //equations to be labeled
input SimCode.ModelInfo inModelInfo; //model info for variables, variable info and labels
input list <Integer> reduceList; //for replace terms: numbers of labels that need to be replaced
input Absyn.FunctionArgs inArgs; //function arguments: mean values for linearization
output list<SimCode.SimEqSystem> outEquationLst;
output SimCode.ModelInfo outModelInfo;
algorithm
(outEquationLst,outModelInfo):=
matchcontinue (inEquationLst,inModelInfo,reduceList,inArgs)
local
Absyn.FunctionArgs args;
SimCode.ModelInfo modelInfo;
list<SimCode.SimEqSystem> eqns,eqns_1;
Absyn.Path name;
list<SimCode.SimEqSystem> linearSystems;
list<SimCode.SimEqSystem> nonLinearSystems;
String description,directory;
SimCode.VarInfo varInfo,varInfo_1;
SimCodeVar.SimVars vars,vars_1;
list<SimCodeFunction.Function> functions;
Boolean hasLargeLinearEquationSystems;
Integer nClocks,nSubClocks;
list<SimCodeVar.SimVar> states,derVar,alg,intAlg,boolAlg,inVar,outVar,algAlias,intAlias,boolAlias,param,
intParam,boolParam,stringAlg,stringParam,stringAlias,extObjVar,jacobianVar,const,intConst,boolConst,stringConst;
Integer nZC,nTE,nR,nMEF,nStates,nAlg,nDiscReal,nIntAlg,nBoolAlg,nAlgAlias,nIntAlias,nBoolAlias,
nParam,nIntParam,nBoolParam,nOut,nIn,nExtObj,nStringAlg,nStringParam,nStringAlias,nEq,nLSys,nNLSys,nMixSys,
nStateSet,nJacobian,nOptCons,nOptFinalConst,nSensParam;
list<String> labels,labels_1,labels_2;
Integer i,p;
list<Absyn.Exp> exp_list;
BackendVarTransform.VariableReplacements repl;
case (eqns,modelInfo as SimCode.MODELINFO(varInfo=varInfo as SimCode.VARINFO()),_,Absyn.FUNCTIONARGS(args = {Absyn.CREF(_), Absyn.ARRAY(arrayExp = exp_list)}))
algorithm
//create replacements for algebraic and state variables together with the time variable by their average values
repl:=meanValueReplacements(modelInfo.vars,exp_list);
//add labels to equations
(eqns_1,vars_1,(i,p),labels_1):=addLabelToEquations(eqns,modelInfo.vars,(0,varInfo.numParams),reduceList,repl);
//append original (empty list) and created labels
labels_2:=listAppend(modelInfo.labels,labels_1);
//update number of parameters in the varInfo nParam=p
if varInfo.numParams <> p then
varInfo.numParams := p;
modelInfo.varInfo := varInfo;
end if;
modelInfo.labels := labels_2;
if not referenceEq(modelInfo.vars, vars_1) then
modelInfo.vars := vars_1;
end if;
then
(eqns_1,modelInfo);
//this case is only necessary for calling generateLabeledDAE from Eclipse, because the first case fails, because there are no inArgs
case (eqns,modelInfo as SimCode.MODELINFO(varInfo=varInfo as SimCode.VARINFO()),_,args)
algorithm
repl:=BackendVarTransform.emptyReplacements();
(eqns_1,vars_1,(i,p),labels_1):=addLabelToEquations(eqns,modelInfo.vars,(0,varInfo.numParams),reduceList,repl);
labels_2:=listAppend(modelInfo.labels,labels_1);
if varInfo.numParams <> p then
varInfo.numParams := p;
modelInfo.varInfo := varInfo;
end if;
modelInfo.labels := labels_2;
if not referenceEq(modelInfo.vars, vars_1) then
modelInfo.vars := vars_1;
end if;
then
(eqns_1,modelInfo);
end matchcontinue;
end buildLabels;
public function reduceTerms
"function that replaces terms with labels given by inArgs"
input list<SimCode.SimEqSystem> inEquationLst;
input SimCode.ModelInfo inModelInfo;
input Absyn.FunctionArgs inArgs;
output list<SimCode.SimEqSystem> outEquationLst;
output SimCode.ModelInfo outModelInfo;
algorithm
(outEquationLst,outModelInfo):=
matchcontinue (inEquationLst,inModelInfo,inArgs)
local
Absyn.FunctionArgs arg;
// list<BackendDAE.Equation> seqnsl,ieqnsl,seqnsl_1,ieqnsl_1;
// list<list<BackendDAE.Equation>> eqnsl,eqnsl_1;
list<SimCode.SimEqSystem> eqns,eqns_1;
//BackendDAE.MultiDimEquation[:] ae_1,ae;
// DAE.Algorithm[:] al;
//list<BackendDAE.WhenClause> wc;
//list<BackendDAE.ZeroCrossing> zc;
//BackendDAE.Variables knvars_1,knvars,extVars;
//BackendDAE.EquationArray seqns_1,ieqns_1,seqns,ieqns;
// BackendDAE.BackendDAE reduced_dae,dae;
// BackendDAE.ExternalObjectClasses extObjCls;
// list<String> labels;
Integer n;
list <Integer> reduceList,keep_lst;
list<Absyn.Exp> exp_list,exp_list2,inExpArgList;
list<Absyn.NamedArg> inNamedArgList;
list<String> outStringList;
list<Absyn.Exp> outExpList;
String st;
String reduceListStr="";
//BackendVarTransform.VariableReplacements repl,repl_2,repl_3;
//list<BackendDAE.MultiDimEquation> arreqnsl,arreqnsl_1;
// BackendDAE.BinTree movedvars_1,movedvars_2;
//BackendDAE.EqSystems eqs,eqs_1;
//BackendDAE.AliasVariables aVars;
// BackendDAE.BackendDAEType daeType;
Absyn.ComponentRef cr;
SimCode.ModelInfo modelInfo,modelInfo_1;
case (eqns,modelInfo,Absyn.FUNCTIONARGS(args=inExpArgList,argNames=inNamedArgList))
equation
//make an integer list of labels to be reduced
(outStringList,outExpList) = AbsynUtil.getNamedFuncArgNamesAndValues(inNamedArgList);
reduceListStr=System.stringReplace(ExpressionDump.printExpStr(Expression.fromAbsynExp(listGet(outExpList,1))), "\"", "");
reduceList=StringDelimit2Int(reduceListStr,",");
//reduce terms by calling buildLabels (buildLabels functions differently depending whether GENERATE_LABELED_SIMCODE or REDUCE_TERMS is enabled)
(eqns,modelInfo_1)= buildLabels(eqns,modelInfo,reduceList,Absyn.FUNCTIONARGS(args=inExpArgList,argNames=inNamedArgList));
then
(eqns,modelInfo_1);
end matchcontinue;
end reduceTerms;
protected function meanValueReplacements
"Creates replacements for algebraic and state variables by the values given in exp_list, last value is for the time variable."
input SimCodeVar.SimVars inVarLst;
input list<Absyn.Exp> exp_list;
output BackendVarTransform.VariableReplacements outVarRepl;
algorithm
outVarRepl:=matchcontinue(inVarLst,exp_list)
local
list<SimCodeVar.SimVar> alg,intAlg,boolAlg,states,listVars,listVars1,listVars2;
BackendVarTransform.VariableReplacements repl;
case(SimCodeVar.SIMVARS(algVars=alg,intAlgVars=intAlg,boolAlgVars=boolAlg,stateVars=states),_)
equation
//empty replacements
repl=BackendVarTransform.emptyReplacements();
//create a list of algVars, intAlgVars, boolAlgvars and stateVars
listVars1 = listAppend(alg,intAlg);
listVars2 = listAppend(listVars1,boolAlg);
listVars = listAppend(listVars2,states);
repl=meanValueReplacements2(repl,listVars,exp_list);
then repl;
end matchcontinue;
end meanValueReplacements;
protected function meanValueReplacements2
"helper function for meanValueReplacements"
input BackendVarTransform.VariableReplacements inVarRepl;
input list<SimCodeVar.SimVar> inVarList;
input list<Absyn.Exp> inValuesList;
output BackendVarTransform.VariableReplacements outVarRepl;
algorithm
outVarRepl:=matchcontinue(inVarRepl,inVarList,inValuesList)
local
BackendVarTransform.VariableReplacements repl;
DAE.ComponentRef name;
DAE.Type type_;
list<SimCodeVar.SimVar> restVar;
String value;
Integer value2;
Absyn.Operator op;
list<Absyn.Exp> restVal;
SimCodeVar.SimVar var;
Absyn.Exp meanValue,exp;
case(repl,{},{}) then repl;
//adds replacement for the time variable
case(repl,{},Absyn.REAL(value)::{})
equation
repl=BackendVarTransform.addReplacement(repl,DAE.crefTime,DAE.RCONST(stringReal(value)),NONE());
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add replacement for time \n" );
end if;
//Debug.fcall(Flags.CPP,print,"Add replacement for time \n" );
then repl;
//replacements for real values
case(repl,SimCodeVar.SIMVAR(name = name,type_ = DAE.T_REAL(_))::restVar,Absyn.REAL(value)::restVal)
equation
repl=BackendVarTransform.addReplacement(repl,name,DAE.RCONST(stringReal(value)),NONE());
repl=meanValueReplacements2(repl,restVar,restVal);
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add replacement for " + ComponentReference.printComponentRefStr(name) + " by " + value + "\n" );
end if;
then repl;
//replacements for integer values
case(repl,SimCodeVar.SIMVAR(name = name,type_ = DAE.T_REAL(_))::restVar,Absyn.INTEGER(value = value2)::restVal)
equation
value=intString(value2);
repl=BackendVarTransform.addReplacement(repl,name,DAE.RCONST(stringReal(value)),NONE());
repl=meanValueReplacements2(repl,restVar,restVal);
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add replacement for " + ComponentReference.printComponentRefStr(name) + " by " + value + "\n" );
end if;
then repl;
//replacements for negative reals
case(repl,SimCodeVar.SIMVAR(name = name,type_ = DAE.T_REAL(_))::restVar,Absyn.UNARY(op = Absyn.UMINUS(),exp = Absyn.REAL(value))::restVal)
equation
repl=BackendVarTransform.addReplacement(repl,name,DAE.UNARY(DAE.UMINUS(DAE.T_REAL_DEFAULT),DAE.RCONST(stringReal(value))),NONE());
repl=meanValueReplacements2(repl,restVar,restVal);
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add replacement for " + ComponentReference.printComponentRefStr(name) + " by -" + value + "\n" );
end if;
//Debug.fcall(Flags.CPP,print,"Add replacement for " + ComponentReference.printComponentRefStr(name) + " by -" + realString(value) + "\n" );
then repl;
//replacements for negative integers
case(repl,SimCodeVar.SIMVAR(name = name,type_ = DAE.T_REAL(_))::restVar,Absyn.UNARY(op = Absyn.UMINUS(),exp = Absyn.INTEGER(value2))::restVal)
equation
value=intString(value2);
repl=BackendVarTransform.addReplacement(repl,name,DAE.UNARY(DAE.UMINUS(DAE.T_REAL_DEFAULT),DAE.RCONST(stringReal(value))),NONE());
repl=meanValueReplacements2(repl,restVar,restVal);
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add replacement for " + ComponentReference.printComponentRefStr(name) + " by -" + value + "\n" );
end if;
then repl;
case(repl,var::restVar,meanValue::restVal)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add no replacement \n" );
end if;
then repl;
case(repl,var::restVar,meanValue::restVal)
equation
repl=meanValueReplacements2(repl,restVar,restVal);
then repl;
end matchcontinue;
end meanValueReplacements2;
protected function addLabelToEquations
"function that calls addLabelToExp for different kinds of SimCode.SimEqSystems"
input list<SimCode.SimEqSystem> inEquationLst1;
input SimCodeVar.SimVars inVarLst;
input tuple<Integer,Integer> inIndex;
input list <Integer> reduceList;
input BackendVarTransform.VariableReplacements inVarRepl;
output list<SimCode.SimEqSystem> outEquationLst;
output SimCodeVar.SimVars outVarLst;
output tuple<Integer,Integer> outIndex;
output list<String> outStringList;
algorithm
(outEquationLst,outVarLst,outIndex,outStringList) := matchcontinue (inEquationLst1,inVarLst,inIndex,reduceList,inVarRepl)
local
DAE.Exp e,e1_1,e2_1,e1,e2,cond;
list<SimCode.SimEqSystem> es_1,es,nl,nl_1,disc;
SimCode.SimEqSystem cont,cont_1,eq,elsePart;
DAE.ComponentRef left;
DAE.Exp right;
list<DAE.Exp> s,t,inputs,outputs,expl,b;
DAE.ComponentRef cr_1,cr;
DAE.ElementSource source "origin of the equation";
list<DAE.ElementSource> sourcelist;
SimCodeVar.SimVars vars,vars_1,vars_2,vars_3;
list<String> labels,labels2,labels3,labels4,labels5;
tuple <Integer,Integer> idx,idx2,idx3,idx4;
Integer i,indexSys,idxLS,idxNLS,nUnknownsLS,nUnknownsNLS;
list<DAE.ComponentRef> conditions;
Boolean partOfLinear,tornSystem,initialCall;
list<BackendDAE.WhenOperator> whenStmtLst;
list<tuple<Integer, Integer, SimCode.SimEqSystem>> A,A2;
list<DAE.ComponentRef> crefs,crefs_1;
list<SimCodeVar.SimVar> varsLin,discVars;
list<DAE.Statement> statements,statements2;
list<SimCode.SimEqSystem> residual;
Option<SimCode.JacobianMatrix> jacobianMatrix;
BackendDAE.EquationAttributes eqAttr;
Boolean partOfJac;
// nothing
case ({},vars,idx,_,_) then ({},vars,idx,{});
// residuals
case (((eq as SimCode.SES_RESIDUAL(i,e,source, eqAttr)) :: es),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace residuals \n" );
end if;
//label a residual equation
(e2,vars_1,idx2,labels) = addLabelToExp(e,vars,idx,true,reduceList,inVarRepl);
//simplify the labeled equation
(e2,_)=ExpressionSimplify.simplify(e2);
//label rest
(es_1 ,vars_2,idx3,labels2)= addLabelToEquations(es,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(SimCode.SES_RESIDUAL(i,e2,source, eqAttr) :: es_1,vars_2,idx3,labels3);
// simple assignments
case (((eq as SimCode.SES_SIMPLE_ASSIGN(i,cr,e,source, eqAttr)) :: es),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace simple assignments \n" );
end if;
//label simple assigment
(e2,vars_1,idx2,labels) = addLabelToExp(e,vars,idx,true,reduceList,inVarRepl);
//simplify the labeled equation
(e2,_)=ExpressionSimplify.simplify(e2);
//label rest
(es_1 ,vars_2,idx3,labels2)= addLabelToEquations(es,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(SimCode.SES_SIMPLE_ASSIGN(i,cr,e2,source, eqAttr) :: es_1,vars_2,idx3,labels3);
// algorithms
case (((eq as SimCode.SES_ALGORITHM(i,statements, eqAttr)) :: es),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace algorithms \n" );
end if;
//Debug.fcall(Flags.CPP,print,"---Replace algorithms \n" );
//call helper function for labeling algorithms
(statements2,vars_1,idx2,labels)=addLabelToAlgorithms(statements,vars,idx,reduceList,inVarRepl);
//label rest
(es_1 ,vars_2,idx3,labels2)= addLabelToEquations(es,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(SimCode.SES_ALGORITHM(i,statements2, eqAttr) :: es_1,vars_2,idx3,labels3);
// linear systems
case (((eq as SimCode.SES_LINEAR (SimCode.LINEARSYSTEM(i,partOfLinear,tornSystem,varsLin,b,A,residual,jacobianMatrix,sourcelist,idxLS,nUnknownsLS,partOfJac),NONE(), eqAttr)) :: es),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace linear equation systems \n" );
end if;
//call helper function for labeling linear equation systems
(A2,vars_1,idx2,labels)=addLabelToLinearEquationSystems(A,vars,idx,reduceList,inVarRepl);
//label rest
(es_1 ,vars_2,idx3,labels2)= addLabelToEquations(es,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(SimCode.SES_LINEAR(SimCode.LINEARSYSTEM(i,partOfLinear,tornSystem,varsLin,b,A2,residual,jacobianMatrix,sourcelist,idxLS,nUnknownsLS, partOfJac),NONE(), eqAttr) :: es_1,vars_2,idx3,labels3);
// non-linear systems
case (((eq as SimCode.SES_NONLINEAR(SimCode.NONLINEARSYSTEM(index=i,eqs=nl,crefs=crefs,indexNonLinearSystem=idxNLS,nUnknowns=nUnknownsNLS,jacobianMatrix=jacobianMatrix),NONE(), eqAttr)) :: es),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace non-linear equation systems \n" );
end if;
//call addLabelToEquations for equations in a nonlinear equation system
(nl_1,vars_1,idx2,labels)=addLabelToEquations(nl,vars,idx,reduceList,inVarRepl);
//label rest
(es_1 ,vars_2,idx3,labels2)= addLabelToEquations(es,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(SimCode.SES_NONLINEAR(SimCode.NONLINEARSYSTEM(index=i,eqs=nl_1,crefs=crefs,indexNonLinearSystem=idxNLS,nUnknowns=nUnknownsNLS,jacobianMatrix=jacobianMatrix,homotopySupport=false,mixedSystem=false,tornSystem=false),NONE(), eqAttr) :: es_1,vars_2,idx3,labels3);
// mixed systems
case (((eq as SimCode.SES_MIXED(i,cont,discVars,disc,indexSys, eqAttr)) :: es),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace mixed equation systems \n" );
end if;
//call addLabelToEquations for equations in a mixed system
({cont_1},vars_1,idx2,labels)=addLabelToEquations({cont},vars,idx,reduceList,inVarRepl);
//label rest
(es_1 ,vars_2,idx3,labels2)= addLabelToEquations(es,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(SimCode.SES_MIXED(i,cont_1,discVars,disc,indexSys, eqAttr) :: es_1,vars_2,idx3,labels3);
// when without else
case (((eq as SimCode.SES_WHEN(i,conditions,initialCall,whenStmtLst,NONE(),source, eqAttr)) :: es),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace when equations without else statement \n" );
end if;
//label rest
(es_1 ,vars_1,idx2,labels)= addLabelToEquations(es,vars,idx,reduceList,inVarRepl);
then
//(SimCode.SES_WHEN(i,conditions,initialCall,whenStmtLst,NONE(),source, eqAttr) :: es_1,vars,idx2,labels);
(SimCode.SES_WHEN(i,conditions,initialCall,whenStmtLst,NONE(),source, eqAttr) :: es_1,vars_1,idx2,labels);
// when with else
case (((eq as SimCode.SES_WHEN(i,conditions,initialCall,whenStmtLst,SOME(elsePart),source, eqAttr)) :: es),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace when equations with else statement \n" );
end if;
//label when equations
//call addLabelToEquations for labeling else part
({elsePart} ,vars_1,idx2,labels)= addLabelToEquations({elsePart},vars,idx,reduceList,inVarRepl);
//label rest
(es_1 ,vars_2,idx3,labels2)= addLabelToEquations(es,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(SimCode.SES_WHEN(i,conditions,initialCall,whenStmtLst,SOME(elsePart),source, eqAttr) :: es_1,vars_2,idx3,labels3);
// add other types of equations
// unknown equations
case (eq::es,vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace unknown equations \n" );
end if;
//Debug.fcall(Flags.CPP,print,"---Replace unknown equations \n" );
(es_1,vars_1,idx2,labels) = addLabelToEquations(es,vars,idx,reduceList,inVarRepl);
then
(eq::es_1,vars_1,idx2,labels);
end matchcontinue;
end addLabelToEquations;
protected function addLabelToAlgorithms
"helper function for labeling algorithms"
input list<DAE.Statement> inStatements;
input SimCodeVar.SimVars inVarLst;
input tuple<Integer,Integer> inIndex;
input list <Integer> reduceList;
input BackendVarTransform.VariableReplacements inVarRepl;
output list<DAE.Statement> outStatements;
output SimCodeVar.SimVars outVarLst;
output tuple<Integer,Integer> outIndex;
output list<String> outStringList;
algorithm
(outStatements,outVarLst,outIndex,outStringList) := matchcontinue (inStatements,inVarLst,inIndex,reduceList,inVarRepl)
local
SimCodeVar.SimVars vars,vars_1,vars_2,vars_3;
tuple <Integer,Integer> idx,idx2,idx3,idx4;
SimCode.SimEqSystem el,el2;
list<DAE.Statement> rest,rest2,stmtLst,stmtLst2;
list<String> labels,labels2,labels3,labels4,labels5;
DAE.Type ty;
DAE.Exp e,e1,e2,e3;
DAE.ElementSource source;
DAE.Statement stmt, elseWhen, elseWhen2;
DAE.Else else_;
Boolean iterIsArray;
DAE.Ident iter;
list<Integer> helpVarIndices;
Integer index;
list<DAE.ComponentRef> conditions;
Boolean initialCall;
case({},vars,idx,_,_)
equation
if Flags.isSet(Flags.REDUCE_DAE) then
Debug.trace("---Replace empty algorithm \n" );
end if;
then ({},vars,idx,{});
case(DAE.STMT_ASSIGN(ty,e1,e,source)::rest,vars,idx,_,_)
equation
if Flags.isSet(Flags.REDUCE_DAE) then
Debug.trace("---Replace assignment algorithm \n");
end if;
(e2,vars_1,idx2,labels) = addLabelToExp(e,vars,idx,true,reduceList,inVarRepl);
(rest2,vars_2,idx3,labels2) = addLabelToAlgorithms(rest,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(DAE.STMT_ASSIGN(ty,e1,e2,source)::rest2,vars_2,idx3,labels3);
case(DAE.STMT_IF(e,stmtLst,else_,source)::rest,vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace if algorithm \n" );
end if;
// //Debug.fcall(Flags.CPP,print,"---Replace if algorithm \n" );
(stmtLst2,vars_1,idx2,labels) = addLabelToAlgorithms(stmtLst,vars,idx,reduceList,inVarRepl);
(rest2,vars_2,idx3,labels2) = addLabelToAlgorithms(rest,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(DAE.STMT_IF(e,stmtLst2,else_,source)::rest2,vars_2,idx3,labels3);
case(DAE.STMT_FOR(ty,iterIsArray,iter,index,e,stmtLst,source)::rest,vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace for algorithm \n" );
end if;
(stmtLst2,vars_1,idx2,labels) = addLabelToAlgorithms(stmtLst,vars,idx,reduceList,inVarRepl);
(rest2,vars_2,idx3,labels2) = addLabelToAlgorithms(rest,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(DAE.STMT_FOR(ty,iterIsArray,iter,index,e,stmtLst2,source)::rest2,vars_2,idx3,labels3);
case(DAE.STMT_WHILE(e,stmtLst,source)::rest,vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace while algorithm \n" );
end if;
(stmtLst2,vars_1,idx2,labels) = addLabelToAlgorithms(stmtLst,vars,idx,reduceList,inVarRepl);
(rest2,vars_2,idx3,labels2) = addLabelToAlgorithms(rest,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(DAE.STMT_WHILE(e,stmtLst2,source)::rest2,vars_2,idx3,labels3);
case(DAE.STMT_WHEN(e,conditions,initialCall,stmtLst,NONE(),source)::rest,vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace when algorithm without else statement \n" );
end if;
(stmtLst2,vars_1,idx2,labels) = addLabelToAlgorithms(stmtLst,vars,idx,reduceList,inVarRepl);
(rest2,vars_2,idx3,labels2) = addLabelToAlgorithms(rest,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(DAE.STMT_WHEN(e,conditions,initialCall,stmtLst2,NONE(),source)::rest2,vars_2,idx3,labels3);
case(DAE.STMT_WHEN(e,conditions,initialCall,stmtLst,SOME(elseWhen),source)::rest,vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace when algorithm with else statement \n" );
end if;
(stmtLst2,vars_1,idx2,labels) = addLabelToAlgorithms(stmtLst,vars,idx,reduceList,inVarRepl);
({elseWhen2},vars_2,idx3,labels2) = addLabelToAlgorithms({elseWhen},vars_1,idx2,reduceList,inVarRepl);
(rest2,vars_3,idx4,labels3) = addLabelToAlgorithms(rest,vars_2,idx3,reduceList,inVarRepl);
labels4=listAppend(labels,labels2);
labels5=listAppend(labels4,labels3);
then
(DAE.STMT_WHEN(e,conditions,initialCall,stmtLst2,SOME(elseWhen2),source)::rest2,vars_3,idx4,labels5);
case(stmt::rest,vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("---Replace other algorithm \n" );
end if;
(rest2,vars_1,idx2,labels) = addLabelToAlgorithms(rest,vars,idx,reduceList,inVarRepl);
then
(stmt::rest2,vars_1,idx2,labels);
end matchcontinue;
end addLabelToAlgorithms;
/* Fatima
protected function addLabelToElse
"helper function for labeling else part"
input DAE.Else inElse;
input SimCodeVar.SimVars inVarLst;
input tuple<Integer,Integer> inIndex;
input list <Integer> reduceList;
input BackendVarTransform.VariableReplacements inVarRepl;
output DAE.Else outElse;
output SimCodeVar.SimVars outVarLst;
output tuple<Integer,Integer> outIndex;
output list<String> outStringList;
algorithm
(outElse,outVarLst,outIndex,outStringList) := matchcontinue (inElse,inVarLst,inIndex,reduceList,inVarRepl)
local
SimCodeVar.SimVars vars,vars_1,vars_2,vars_3;
tuple <Integer,Integer> idx,idx2,idx3,idx4;
SimCode.SimEqSystem el,el2;
list<DAE.Statement> rest,rest2,stmtLst,stmtLst2;
list<String> labels,labels2,labels3,labels4,labels5;
DAE.Else else_,else2;
DAE.Exp e;
case(DAE.NOELSE(),vars,idx,reduceList,inVarRepl) then (DAE.NOELSE(),vars,idx,{});
case(DAE.ELSEIF(e,stmtLst,else_),vars,idx,reduceList,inVarRepl)
equation
////Debug.fcall(Flags.CPP,print,"---Replace elseif with else \n" );
(stmtLst2,vars_1,idx2,labels) = addLabelToAlgorithms(stmtLst,vars,idx,reduceList,inVarRepl);
(else2,vars_2,idx3,labels2) = addLabelToElse(else_,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
(DAE.ELSEIF(e,stmtLst2,else2),vars_2,idx3,labels3);
case(DAE.ELSE(stmtLst),vars,idx,reduceList,inVarRepl)
equation
//Debug.fcall(Flags.CPP,print,"---Replace else \n" );
(stmtLst2,vars_1,idx2,labels) = addLabelToAlgorithms(stmtLst,vars,idx,reduceList,inVarRepl);
then
(DAE.ELSE(stmtLst2),vars_1,idx2,labels) ;
end matchcontinue;
end addLabelToElse;
*/
protected function addLabelToLinearEquationSystems
"helper function for labeling linear equation systems"
input list<tuple<Integer, Integer, SimCode.SimEqSystem>> inLinear;
input SimCodeVar.SimVars inVarLst;
input tuple<Integer,Integer> inIndex;
input list <Integer> reduceList;
input BackendVarTransform.VariableReplacements inVarRepl;
output list<tuple<Integer, Integer, SimCode.SimEqSystem>> outLinear;
output SimCodeVar.SimVars outVarLst;
output tuple<Integer,Integer> outIndex;
output list<String> outStringList;
algorithm
(outLinear,outVarLst,outIndex,outStringList) := matchcontinue (inLinear,inVarLst,inIndex,reduceList,inVarRepl)
local
SimCodeVar.SimVars vars,vars_1,vars_2,vars_3;
tuple <Integer,Integer> idx,idx2,idx3,idx4;
SimCode.SimEqSystem el,el2;
list<tuple<Integer, Integer, SimCode.SimEqSystem>> rest,rest2;
Integer i,j;
list<String> labels,labels2,labels3,labels4,labels5;
case({},vars,idx,_,_) then ({},vars,idx,{});
case((i,j,el)::rest,vars,idx,_,_)
equation
({el2},vars_1,idx2,labels) = addLabelToEquations({el},vars,idx,reduceList,inVarRepl);
(rest2,vars_2,idx3,labels2) = addLabelToLinearEquationSystems(rest,vars_1,idx2,reduceList,inVarRepl);
labels3=listAppend(labels,labels2);
then
((i,j,el2)::rest2,vars_2,idx3,labels3);
end matchcontinue;
end addLabelToLinearEquationSystems;
protected function addLabelToExp
"reads the flag REDUCTION_METHOD and calls addLabelToExpForDeletion, addLabelToExpForSubstitution or addLabelToExpForLinearization"
input DAE.Exp inExp1;
input SimCodeVar.SimVars inVarLst;
input tuple<Integer,Integer> inIntdex;
input Boolean add;
input list <Integer> reduceList;
input BackendVarTransform.VariableReplacements inVarRepl;
output DAE.Exp outExp;
output SimCodeVar.SimVars outVarLst;
output tuple<Integer,Integer> outIntdex;
output list<String> outStringList;
algorithm
(outExp,outVarLst,outIntdex,outStringList):=
matchcontinue (inExp1,inVarLst,inIntdex,add,reduceList,inVarRepl)
local
DAE.Exp e;
SimCodeVar.SimVars vars;
tuple<Integer,Integer> idx;
list<String> labels;
case (_,_,_,_,_,_)
equation
//case for deletion
"deletion"=Flags.getConfigString(Flags.REDUCTION_METHOD);
(e,vars,idx,labels)=addLabelToExpForDeletion(inExp1,inVarLst,inIntdex,add,reduceList);
then
(e,vars,idx,labels);
case (_,_,_,_,_,_)
equation
//case for substitution
"substitution"=Flags.getConfigString(Flags.REDUCTION_METHOD);
(e,vars,idx,labels,_)=addLabelToExpForSubstitution(inExp1,inVarLst,inIntdex,reduceList,inVarRepl);
then
(e,vars,idx,labels);
case (_,_,_,_,_,_)
equation
//case for linearization
"linearization"=Flags.getConfigString(Flags.REDUCTION_METHOD);
(e,vars,idx,labels)=addLabelToExpForLinearization(inExp1,inVarLst,inIntdex,reduceList,inVarRepl);
then
(e,vars,idx,labels);
end matchcontinue;
end addLabelToExp;
protected function addLabelToExpForDeletion
"function that adds labels to expressions for the deletion method"
input DAE.Exp inExp1;
input SimCodeVar.SimVars inVarLst;
input tuple<Integer,Integer> inIntdex;
input Boolean add;
input list <Integer> reduceList;
output DAE.Exp outExp;
output SimCodeVar.SimVars outVarLst;
output tuple<Integer,Integer> outIntdex;
output list<String> outStringList;
algorithm
(outExp,outVarLst,outIntdex,outStringList):=
matchcontinue (inExp1,inVarLst,inIntdex,add,reduceList)
local
DAE.Exp expr,source,target,e1_1,e2_1,e1,e2,e3_1,e3,e_1,r_1,e,r,s;
DAE.Operator op;
String name;
Integer p_1,i_1;
list<DAE.Exp> expl_1,expl;
list<Integer> cnt;
Absyn.Path path,p;
Boolean c,t;
Absyn.CodeNode a;
SimCodeVar.SimVars vars_1,vars_2,vars_3,vars;
tuple<Integer,Integer> idx,idx1,idx2,idx3,idx4;
list<String> labels,labels2,labels3,labels4,labels5;
Real valueR;
Integer valueI;
DAE.CallAttributes attr;
///Add label to a+b
case (e as DAE.BINARY(exp1 = e1,operator = (op as DAE.ADD(ty = _)),exp2 = e2),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add label to add exp " + ExpressionDump.printExpStr(e) + "\n");
end if;
//labels e_1
(e1_1,vars_1,idx2,labels) = addLabelToExpForDeletion(e1,vars,idx,true,reduceList);
//labels e_2
(e2_1,vars_2,idx3,labels2) = addLabelToExpForDeletion(e2,vars_1,idx2,true,reduceList);
//creates a label variable and multiplies it with the all expression
if Flags.getConfigBool(Flags.DISABLE_EXTRA_LABELING) then
(e3,vars_3, idx4,labels3) = addOneLabel(DAE.BINARY(e1_1,op,e2_1),false,idx3,vars_2,reduceList);
else
(e3,vars_3, idx4,labels3) = addOneLabel(DAE.BINARY(e1_1,op,e2_1),add,idx3,vars_2,reduceList);
end if;
labels4=listAppend(labels,labels2);
labels5=listAppend(labels4,labels3);
then
(e3,vars_3,idx4,labels5);
///Add labe to a-b
case (e as DAE.BINARY(exp1 = e1,operator = (op as DAE.SUB(ty = _)),exp2 = e2),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add label to sub exp " + ExpressionDump.printExpStr(e) + "\n");
end if;
//labels e_1
(e1_1,vars_1,idx2,labels) = addLabelToExpForDeletion(e1,vars,idx,true,reduceList);
//labels e_2
(e2_1,vars_2,idx3,labels2) = addLabelToExpForDeletion(e2,vars_1,idx2,true,reduceList);
//creates a label variable and multiplies it with the all expression
if Flags.getConfigBool(Flags.DISABLE_EXTRA_LABELING) then
(e3,vars_3, idx4,labels3) = addOneLabel(DAE.BINARY(e1_1,op,e2_1),false,idx3,vars_2,reduceList);
else
(e3,vars_3, idx4,labels3) = addOneLabel(DAE.BINARY(e1_1,op,e2_1),add,idx3,vars_2,reduceList);
end if;
labels4=listAppend(labels,labels2);
labels5=listAppend(labels4,labels3);
then
(e3,vars_3,idx4,labels5);
///Add label to a*b
case (e as DAE.BINARY(exp1 = e1,operator = (op as DAE.MUL(ty = _)),exp2 = e2),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add label to mul exp " + ExpressionDump.printExpStr(e) + "\n");
end if;
//labels e_1
(e1_1,vars_1,idx2,labels) = addLabelToExpForDeletion(e1,vars,idx,false,reduceList);
//labels e_2
(e2_1,vars_2,idx3,labels2) = addLabelToExpForDeletion(e2,vars_1,idx2,false,reduceList);
//creates a label variable and multiplies it with the all expression
(e3,vars_3, idx4,labels3) = addOneLabel(DAE.BINARY(e1_1,op,e2_1),add,idx3,vars_2,reduceList);
labels4=listAppend(labels,labels2);
labels5=listAppend(labels4,labels3);
then
(e3,vars_3,idx4,labels5);
///Add label to a/b
case (e as DAE.BINARY(exp1 = e1,operator = (op as DAE.DIV(ty = _)),exp2 = e2),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add label to div exp " + ExpressionDump.printExpStr(e) + "\n");
end if;
//Debug.fcall(Flags.CPP,print,"Add label to div exp " +& ExpressionDump.printExpStr(e) +& "\n");
//labels only the nominator
(e1_1,vars_1,idx2,labels) = addLabelToExpForDeletion(e1,vars,idx,true,reduceList);
//(e2_1,vars_2,idx3,labels2) = addLabelToExpForDeletion(e2,vars_1,idx2,true,reduceList);
//labels3=listAppend(labels,labels2);
then
(DAE.BINARY(e1_1,op,e2),vars_1,idx2,labels);
///Add label to a^b
case (e as DAE.BINARY(exp1 = e1,operator = (op as DAE.POW(ty = _)),exp2 = e2),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add label to pow exp " + ExpressionDump.printExpStr(e) + "\n");
end if;
//labels e_1
(e1_1,vars_1,idx2,labels) = addLabelToExpForDeletion(e1,vars,idx,true,reduceList);
//labels e_2
(e2_1,vars_2,idx3,labels2) = addLabelToExpForDeletion(e2,vars_1,idx2,true,reduceList);
//create a label and multiplies it with the all variable
if Flags.getConfigBool(Flags.DISABLE_EXTRA_LABELING) then
(e3,vars_3, idx4,labels3) = addOneLabel(DAE.BINARY(e1_1,op,e2_1),false,idx3,vars_2,reduceList);
else
(e3,vars_3, idx4,labels3) = addOneLabel(DAE.BINARY(e1_1,op,e2_1),add,idx3,vars_2,reduceList);
end if;
labels4=listAppend(labels,labels2);
labels5=listAppend(labels4,labels3);
then
(e3,vars_3,idx4,labels5);
///Add label to -a
case (e as DAE.UNARY(operator = op,exp = e1),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add label to unary exp "+ ExpressionDump.printExpStr(e) +"\n");
end if;
//Debug.fcall(Flags.CPP,print,"Add label to unary exp "+& ExpressionDump.printExpStr(e) +&"\n");
(e1_1,vars_1,idx2,labels) = addLabelToExpForDeletion(e1,vars,idx,true,reduceList);
then
(DAE.UNARY(op,e1_1),vars_1,idx2,labels);
///Add label to relations
case (e as DAE.RELATION(exp1 = e1,operator = op,exp2 = e2),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Not Implemented: Add label to relation " + ExpressionDump.printExpStr(e)+"\n");
end if;
then
(e,vars,idx,{});
///Add label to if expr
case (e as DAE.IFEXP(expCond = e1,expThen = e2,expElse = e3),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add label to if exp" + ExpressionDump.printExpStr(e)+"\n");
end if;
//labels if-clause
(e2_1,vars_1,idx2,labels) = addLabelToExpForDeletion(e2,vars,idx,true,reduceList);
//labels else-clause
(e3_1,vars_2,idx3,labels2) = addLabelToExpForDeletion(e3,vars_1,idx2,true,reduceList);
labels3=listAppend(labels,labels2);
then
(DAE.IFEXP(e1,e2_1,e3_1),vars_2,idx3,labels3);
//Add label to pre expr
case ((e as DAE.CALL(path = Absyn.IDENT(name = "pre"))),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("add no label to pre arguments \n");
end if;
//creates a label and multiplies it with the expression
(e2,vars_1, idx1,labels) = addOneLabel(e,add,idx,vars,reduceList);
then
(e2,vars_1,idx1,labels);
///Add label to edge operator
case ((e as DAE.CALL(path = Absyn.IDENT(name = "edge"))),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("add no label to edge arguments \n");
end if;
//creates a label and multiplies it with the expression
(e2,vars_1, idx1,labels) = addOneLabel(e,add,idx,vars,reduceList);
then
(e2,vars_1,idx1,labels);
///Add label to change operator
case ((e as DAE.CALL(path = Absyn.IDENT(name = "change"))),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("add no label to change arguments \n");
end if;
//creates a label and multiplies it with the expression
(e2,vars_1, idx1,labels) = addOneLabel(e,add,idx,vars,reduceList);
then
(e2,vars_1,idx1,labels);
///Add label to sample operator
case ((e as DAE.CALL(path = Absyn.IDENT(name = "sample"))),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("add no label to sample arguments \n");
end if;
//creates a label and multiplies it with the expression
(e2,vars_1, idx1,labels) = addOneLabel(e,add,idx,vars,reduceList);
then
(e2,vars_1,idx1,labels);
///Add label to no event operator
case ((e as DAE.CALL(path = Absyn.IDENT(name = "noEvent"))),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("add no label for no event arguments \n");
end if;
//creates a label and multiplies it with the expression
(e2,vars_1, idx1,labels) = addOneLabel(e,add,idx,vars,reduceList);
then
(e2,vars_1, idx1,labels);
case ((e as DAE.CALL(path = Absyn.IDENT(name="max"),expLst = {e1,e2},attr = attr)),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add label to max exp " + ExpressionDump.printExpStr(e) + "\n");
end if;
//Debug.fcall(Flags.CPP,print,"Add label to max exp " +& ExpressionDump.printExpStr(e) +& "\n");
//labels e_1
(e1_1,vars_1,idx2,labels) = addLabelToExpForDeletion(e1,vars,idx,true,reduceList);
//labels e_2
(e2_1,vars_2,idx3,labels2) = addLabelToExpForDeletion(e2,vars_1,idx2,true,reduceList);
//create a label and multiplies it with the all expression
(e3,vars_3, idx4,labels3) = addOneLabel(DAE.CALL(Absyn.IDENT("max"),{e1_1,e2_1},attr),add,idx3,vars_2,reduceList);
labels4=listAppend(labels,labels2);
labels5=listAppend(labels4,labels3);
then
(e3,vars_3,idx4,labels5);
case ((e as DAE.CALL(path = Absyn.IDENT(name="min"),expLst = {e1,e2},attr = attr)),vars,idx,_,_)
equation
if(Flags.isSet(Flags.REDUCE_DAE)) then
Debug.trace("Add label to min exp " + ExpressionDump.printExpStr(e) + "\n");
end if;
//labels e_1
(e1_1,vars_1,idx2,labels) = addLabelToExpForDeletion(e1,vars,idx,true,reduceList);