@@ -60,6 +60,7 @@ protected import BackendDAEOptimize;
6060protected import BackendDAETransform ;
6161protected import BackendDump ;
6262protected import BackendEquation ;
63+ protected import BackendDAEEXT ;
6364protected import BackendInline ;
6465protected import BackendVariable ;
6566protected import BackendVarTransform ;
@@ -100,6 +101,7 @@ protected import RemoveSimpleEquations;
100101protected import ResolveLoops ;
101102protected import SCode ;
102103protected import SimCodeFunctionUtil ;
104+ protected import Sorting ;
103105protected import StateMachineFeatures ;
104106protected import SymbolicJacobian ;
105107protected import SynchronousFeatures ;
@@ -2115,6 +2117,27 @@ algorithm
21152117 end try ;
21162118end incidenceMatrix;
21172119
2120+ public function incidenceMatrixMasked
2121+ input BackendDAE . EqSystem inEqSystem;
2122+ input BackendDAE . IndexType inIndexType;
2123+ input array< Boolean > inMask;
2124+ input Option < DAE . FunctionTree > functionTree;
2125+ output BackendDAE . IncidenceMatrix outIncidenceMatrix;
2126+ output BackendDAE . IncidenceMatrixT outIncidenceMatrixT;
2127+ protected
2128+ BackendDAE . Variables vars;
2129+ BackendDAE . EquationArray eqns;
2130+ algorithm
2131+ try
2132+ BackendDAE . EQSYSTEM (orderedVars = vars, orderedEqs = eqns) := inEqSystem;
2133+ (outIncidenceMatrix, outIncidenceMatrixT) :=
2134+ incidenceMatrixDispatchMasked(vars, eqns, inIndexType, inMask, functionTree);
2135+ else
2136+ Error . addMessage(Error . INTERNAL_ERROR , {"BackendDAEUtil.incidenceMatrix failed." });
2137+ fail();
2138+ end try ;
2139+ end incidenceMatrixMasked;
2140+
21182141public function incidenceMatrixScalar
21192142"author: PA, adrpo
21202143 Calculates the incidence matrix, i.e. which variables are present in each equation.
@@ -2187,6 +2210,37 @@ algorithm
21872210 end for ;
21882211end incidenceMatrixDispatch;
21892212
2213+ public function incidenceMatrixDispatchMasked
2214+ input BackendDAE . Variables inVars;
2215+ input BackendDAE . EquationArray inEqns;
2216+ input BackendDAE . IndexType inIndexType;
2217+ input array< Boolean > inMask;
2218+ input Option < DAE . FunctionTree > functionTree = NONE ();
2219+ output BackendDAE . IncidenceMatrix outIncidenceArray;
2220+ output BackendDAE . IncidenceMatrixT outIncidenceArrayT;
2221+ protected
2222+ Integer num_eqs, num_vars;
2223+ BackendDAE . Equation eq;
2224+ list< Integer > row;
2225+ algorithm
2226+ num_eqs := equationArraySize(inEqns);
2227+ num_vars := BackendVariable . varsSize(inVars);
2228+ outIncidenceArray := arrayCreate(num_eqs, {});
2229+ outIncidenceArrayT := arrayCreate(num_vars, {});
2230+
2231+ for idx in 1 :num_eqs loop
2232+ if inMask[idx] then
2233+ // Get the equation.
2234+ eq := BackendEquation . equationNth1(inEqns, idx);
2235+ // Compute the row.
2236+ row := incidenceRow(eq, inVars, inIndexType, functionTree, {});
2237+ // Put it in the arrays.
2238+ arrayUpdate(outIncidenceArray, idx, row);
2239+ outIncidenceArrayT := fillincidenceMatrixT(row, {idx}, outIncidenceArrayT);
2240+ end if ;
2241+ end for ;
2242+ end incidenceMatrixDispatchMasked;
2243+
21902244protected function incidenceMatrixDispatchScalar
21912245"@author: adrpo
21922246 Calculates the incidence matrix as an array of list of integers"
@@ -2281,6 +2335,13 @@ algorithm
22812335 cr = DAE . CREF_IDENT (BackendDAE . WHENCLK_PRREFIX + intString(i), DAE . T_CLOCK_DEFAULT , {});
22822336 (_, varIxs) = BackendVariable . getVar(cr, vars);
22832337 then varIxs;
2338+ case BackendDAE . SUBCLOCK_IDX ()
2339+ equation
2340+ BackendDAE . EQUATION_ATTRIBUTES (kind = kind) = BackendEquation . getEquationAttributes(inEquation);
2341+ BackendDAE . CLOCKED_EQUATION (i) = kind;
2342+ cr = DAE . CREF_IDENT (BackendDAE . WHENCLK_PRREFIX + intString(i), DAE . T_CLOCK_DEFAULT , {});
2343+ (_, varIxs) = BackendVariable . getVar(cr, vars);
2344+ then varIxs;
22842345 else {};
22852346 end matchcontinue;
22862347 (outIntegerLst,rowSize) := matchcontinue (inEquation)
@@ -3516,6 +3577,17 @@ algorithm
35163577 (outM, outMT) := incidenceMatrixDispatch(inSyst. orderedVars, inSyst. removedEqs, inIndxType, inFunctionTree);
35173578end removedIncidenceMatrix;
35183579
3580+ public function removedIncidenceMatrixMasked
3581+ input BackendDAE . EqSystem inSyst;
3582+ input BackendDAE . IndexType inIndxType;
3583+ input array< Boolean > inMask;
3584+ input Option < DAE . FunctionTree > inFunctionTree;
3585+ output BackendDAE . IncidenceMatrix outM;
3586+ output BackendDAE . IncidenceMatrix outMT;
3587+ algorithm
3588+ (outM, outMT) := incidenceMatrixDispatchMasked(inSyst. orderedVars, inSyst. removedEqs, inIndxType, inMask, inFunctionTree);
3589+ end removedIncidenceMatrixMasked;
3590+
35193591protected function traverseStmts "Author: Frenkel TUD 2012-06
35203592 traverese DAE.Statement without change possibility."
35213593 input list< DAE . Statement > inStmts;
@@ -7097,6 +7169,7 @@ algorithm
70977169 (EvaluateParameter . evaluateReplaceEvaluateParameters, "evaluateReplaceEvaluateParameters" , false ),
70987170 (EvaluateParameter . evaluateReplaceFinalEvaluateParameters, "evaluateReplaceFinalEvaluateParameters" , false ),
70997171 (EvaluateParameter . evaluateReplaceProtectedFinalEvaluateParameters, "evaluateReplaceProtectedFinalEvaluateParameters" , false ),
7172+ (EvaluateParameter . evaluateAllParameters, "evaluateAllParameters" , false ),
71007173 (BackendDAEOptimize . removeEqualFunctionCalls, "removeEqualFunctionCalls" , false ),
71017174 (BackendDAEOptimize . removeProtectedParameters, "removeProtectedParameters" , false ),
71027175 (BackendDAEOptimize . removeUnusedParameter, "removeUnusedParameter" , false ),
@@ -7787,9 +7860,20 @@ protected
77877860algorithm
77887861 shared := BackendDAE . SHARED ( emptyVars, emptyVars, emptyVars, emptyEqs, emptyEqs, {}, {}, cache, graph,
77897862 DAEUtil . avlTreeNew(), emptyEventInfo(), {}, backendDAEType, {}, ei,
7790- BackendDAE . PARTITIONS_INFO (emptyClocks() ) );
7863+ emptyPartitionsInfo( ) );
77917864end createEmptyShared;
77927865
7866+ public function emptyPartitionsInfo
7867+ output BackendDAE . PartitionsInfo partitionsInfo;
7868+ protected
7869+ array< BackendDAE . BasePartition > basePartitions;
7870+ array< BackendDAE . SubPartition > subPartitions;
7871+ algorithm
7872+ basePartitions := arrayCreate(0 , BackendDAE . BASE_PARTITION (DAE . INFERRED_CLOCK (), 0 ));
7873+ subPartitions := arrayCreate(0 , BackendDAE . SUB_PARTITION (BackendDAE . DEFAULT_SUBCLOCK , false , {}));
7874+ partitionsInfo := BackendDAE . PARTITIONS_INFO (basePartitions, subPartitions);
7875+ end emptyPartitionsInfo;
7876+
77937877public function makeSingleEquationComp
77947878 input Integer eqIdx;
77957879 input Integer varIdx;
@@ -8074,11 +8158,19 @@ algorithm
80748158 info := BackendDAE . EVENT_INFO ({}, {}, {}, {}, 0 );
80758159end emptyEventInfo;
80768160
8077- public function emptyClocks
8078- output array< DAE . ClockKind > clocks;
8161+ public function getSubClock
8162+ input BackendDAE . EqSystem inSyst;
8163+ input BackendDAE . Shared inShared;
8164+ output Option < BackendDAE . SubClock > outSubClock;
80798165algorithm
8080- clocks := arrayCreate(0 , DAE . INFERRED_CLOCK ());
8081- end emptyClocks;
8166+ outSubClock := match inSyst. partitionKind
8167+ local
8168+ Integer idx;
8169+ case BackendDAE . CLOCKED_PARTITION (idx)
8170+ then SOME (inShared. partitionsInfo. subPartitions[idx]. clock);
8171+ else NONE ();
8172+ end match;
8173+ end getSubClock;
80828174
80838175public function componentsEqual"outputs true if 1 strongly connected components are equal"
80848176 input BackendDAE . StrongComponent comp1;
@@ -8144,5 +8236,32 @@ algorithm
81448236 end matchcontinue;
81458237end otherEqnVarTplEqual;
81468238
8239+
8240+ public function causalizeVarBindSystem"causalizes a system of variables and their binding-equations.
8241+ author: waurich TUD 08.2015"
8242+ input list< BackendDAE . Var > varLstIn;
8243+ output list< list< Integer >> comps;
8244+ output array< Integer > ass1;
8245+ output array< Integer > ass2;
8246+ protected
8247+ Integer nVars,nEqs;
8248+ list< Integer > order;
8249+ BackendDAE . IncidenceMatrix m, mT;
8250+ list< DAE . Exp > bindExps;
8251+ list< BackendDAE . Equation > eqs;
8252+ algorithm
8253+ bindExps := List . map(varLstIn,BackendVariable . varBindExp);
8254+ eqs := List . threadMap2(List . map(varLstIn,BackendVariable . varExp), bindExps, BackendEquation . generateEquation, DAE . emptyElementSource, BackendDAE . EQ_ATTR_DEFAULT_DYNAMIC );
8255+ (m, mT) := BackendDAEUtil . incidenceMatrixDispatch(BackendVariable . listVar1(varLstIn), BackendEquation . listEquation(eqs), BackendDAE . ABSOLUTE (), NONE ());
8256+ nVars := listLength(varLstIn);
8257+ nEqs := listLength(eqs);
8258+ ass1 := arrayCreate(nVars, -1 );
8259+ ass2 := arrayCreate(nEqs, -1 );
8260+ Matching . matchingExternalsetIncidenceMatrix(nVars, nEqs, m);
8261+ BackendDAEEXT . matching(nVars, nEqs, 5 , -1 , 0 . 0 , 1 );
8262+ BackendDAEEXT . getAssignment(ass2, ass1);
8263+ comps := Sorting . TarjanTransposed (mT, ass2);
8264+ end causalizeVarBindSystem;
8265+
81478266annotation(__OpenModelica_Interface= "backend" );
81488267end BackendDAEUtil ;
0 commit comments