@@ -38,32 +38,35 @@ encapsulated package Tearing
3838 - Cellier Tearing"
3939
4040
41- public import BackendDAE ;
42- public import DAE ;
43-
44- protected import Array ;
45- protected import BackendDAEEXT ;
46- protected import BackendDAEOptimize ;
47- protected import BackendDAEUtil ;
48- protected import BackendDump ;
49- protected import BackendEquation ;
50- protected import BackendVariable ;
51- protected import Config ;
52- protected import DoubleEndedList ;
53- protected import DumpGraphML ;
54- protected import Error ;
55- protected import ExecStat.execStat ;
56- protected import Expression ;
57- protected import ExpressionDump ;
58- protected import ExpressionSimplify ;
59- protected import ExpressionSolve ;
60- protected import Flags ;
61- protected import Global ;
62- protected import List ;
63- protected import Matching ;
64- protected import MetaModelica.Dangerous ;
65- protected import Util ;
66- protected import Sorting ;
41+ import BackendDAE ;
42+ import DAE ;
43+
44+ protected
45+
46+ import Array ;
47+ import BackendDAEEXT ;
48+ import BackendDAEOptimize ;
49+ import BackendDAEUtil ;
50+ import BackendDump ;
51+ import BackendEquation ;
52+ import BackendVariable ;
53+ import Config ;
54+ import DoubleEndedList ;
55+ import DumpGraphML ;
56+ import Error ;
57+ import ExecStat.execStat ;
58+ import Expression ;
59+ import ExpressionDump ;
60+ import ExpressionSimplify ;
61+ import ExpressionSolve ;
62+ import Flags ;
63+ import Global ;
64+ import List ;
65+ import Matching ;
66+ import MetaModelica.Dangerous ;
67+ import Mutable ;
68+ import Util ;
69+ import Sorting ;
6770
6871// =============================================================================
6972// section for type definitions
@@ -2323,7 +2326,7 @@ algorithm
23232326 // 6. determine which possible Vars causalize most equations considering impossible assignments and write them into potentials
23242327 msel2t := Array . select(mtIn,selectedcols1);
23252328 ((potentials,_,_,_)) := Array . fold(msel2t,function selectCausalVars(
2326- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2329+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
23272330 ), ({},0 ,1 ,{}));
23282331
23292332 // 7. convert indexes from msel2t to indexes from mtIn
@@ -2368,7 +2371,7 @@ algorithm
23682371 // 3. determine which possible Vars causalize most equations considering impossible assignments and write them into potentials
23692372 msel2t := Array . select(mtIn,selectedcols1);
23702373 ((potentials,_,_,_)) := Array . fold(msel2t,function selectCausalVars(
2371- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2374+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
23722375 ),({},0 ,1 ,{}));
23732376
23742377 // 4. convert indexes from msel2t to indexes from mtIn
@@ -2425,7 +2428,7 @@ algorithm
24252428 // 6. determine which possible Vars causalize most equations considering impossible assignments and write them into potentials
24262429 msel2t := Array . select(mtIn,selectedcols1);
24272430 ((potentials,_,_,_)) := Array . fold(msel2t,function selectCausalVars(
2428- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2431+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
24292432 ),({},0 ,1 ,{}));
24302433
24312434 // 7. convert indexes from msel2t to indexes from mtIn
@@ -2476,7 +2479,7 @@ algorithm
24762479 // 3. determine which possible Vars causalize most equations considering impossible assignments and write them into potentials
24772480 msel2t := Array . select(mtIn,selectedcols1);
24782481 ((potentials,_,_,_)) := Array . fold(msel2t,function selectCausalVars(
2479- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2482+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
24802483 ),({},0 ,1 ,{}));
24812484
24822485 // 4. convert indexes from msel2t to indexes from mtIn
@@ -2545,7 +2548,7 @@ algorithm
25452548 // 7. determine which possible Vars causalize most equations considering impossible assignments and write them into potentials
25462549 msel2t := Array . select(mtIn,selectedcols1);
25472550 ((potentials,_,_,_)) := Array . fold(msel2t,function selectCausalVars(
2548- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2551+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
25492552 ),({},0 ,1 ,{}));
25502553
25512554 // 8. convert indexes from msel2t to indexes from mtIn
@@ -2596,7 +2599,7 @@ algorithm
25962599 // 4. determine which possible Vars causalize most equations considering impossible assignments and write them into potentials
25972600 msel2t := Array . select(mtIn,selectedcols1);
25982601 ((potentials,_,_,_)) := Array . fold(msel2t,function selectCausalVars(
2599- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2602+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
26002603 ),({},0 ,1 ,{}));
26012604
26022605 // 5. convert indexes from msel2t to indexes from mtIn
@@ -2653,7 +2656,7 @@ algorithm
26532656 // 6. determine for each variable the number of equations it could causalize considering impossible assignments and save them in counts1
26542657 msel2t := Array . select(mtIn,selectedcols1);
26552658 ((_,_,_,counts1)) := Array . fold(msel2t,function selectCausalVars(
2656- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2659+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
26572660 ),({},0 ,1 ,{}));
26582661 counts1 := listReverse(counts1);
26592662
@@ -2710,7 +2713,7 @@ algorithm
27102713 // 4. determine for each variable the number of equations it could causalize considering impossible assignments and save them in counts1
27112714 msel2t := Array . select(mtIn,selectedcols1);
27122715 ((_,_,_,counts1)) := Array . fold(msel2t,function selectCausalVars(
2713- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2716+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
27142717 ),({},0 ,1 ,{}));
27152718 counts1 := listReverse(counts1);
27162719
@@ -2772,7 +2775,7 @@ algorithm
27722775 // 4. determine for each variable the number of equations it could causalize considering impossible assignments and save them in counts1
27732776 msel2t := Array . select(mtIn,selectedcols1);
27742777 ((_,_,_,counts1)) := Array . fold(msel2t,function selectCausalVars(
2775- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2778+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
27762779 ),({},0 ,1 ,{}));
27772780 counts1 := listReverse(counts1);
27782781
@@ -2807,7 +2810,7 @@ algorithm
28072810 // 10. determine for each variable the number of equations it could causalize considering impossible assignments and save them in counts1
28082811 msel2t := Array . select(mtIn,selectedcols1);
28092812 ((_,_,_,counts1)) := Array . fold(msel2t,function selectCausalVars(
2810- me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= arrayCreate( 1 , selectedcols1)
2813+ me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(selectedrows, arrayLength(ass1In)),selVars= Mutable . create( selectedcols1)
28112814 ),({},0 ,1 ,{}));
28122815 counts1 := listReverse(counts1);
28132816
@@ -2900,7 +2903,7 @@ algorithm
29002903
29012904 // 4.1 Determine for each variable the number of equations it could causalize considering impossible assignments and save them in counts1
29022905 mtsel := Array . select(mtIn,potentialTVars);
2903- ((_,_,_,counts1)) := Array . fold(mtsel,function selectCausalVars(me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(causEq, arrayLength(ass1In)),selVars= arrayCreate( 1 , potentialTVars)),({},0 ,1 ,{}));
2906+ ((_,_,_,counts1)) := Array . fold(mtsel,function selectCausalVars(me= meIn,ass1In= ass1In,selEqsSetArray= selectCausalVarsPrepareSelectionSet(causEq, arrayLength(ass1In)),selVars= Mutable . create( potentialTVars)),({},0 ,1 ,{}));
29042907 if debug then execStat("Tearing.ModifiedCellierHeuristic_3 - 5.1" ); end if ;
29052908
29062909 // 4.2 Determine for each variable the number of impossible assignments and save them in counts2
@@ -3091,7 +3094,7 @@ protected function selectCausalVars
30913094 input BackendDAE . AdjacencyMatrixEnhanced me;
30923095 input array< Integer > ass1In;
30933096 input array< Boolean > selEqsSetArray;
3094- input array < list< Integer >> selVars;
3097+ input Mutable < list< Integer >> selVars;
30953098 output tuple< list< Integer > ,Integer ,Integer ,list< Integer >> OutValue ;
30963099protected
30973100 list< Integer > cVars,interEqs,counts,selVarsNext;
@@ -3101,8 +3104,8 @@ algorithm
31013104 (cVars,num,indx,counts) := inValue;
31023105 // interEqs := List.intersectionOnTrue(row,selEqs,intEq);
31033106 interEqs := list(i for i guard arrayGet(selEqsSetArray,i) in row);
3104- Var ::selVarsNext := arrayGet (selVars, 1 );
3105- arrayUpdate (selVars, 1 , selVarsNext);
3107+ Var ::selVarsNext := Mutable . access (selVars);
3108+ Mutable . update (selVars, selVarsNext);
31063109 arrayUpdate(ass1In,Var ,1 );
31073110 size := List . fold2(interEqs,sizeOfAssignable,me,ass1In,0 );
31083111 arrayUpdate(ass1In,Var ,-1 );
0 commit comments