@@ -2734,17 +2734,21 @@ algorithm
27342734 Discrete output variables that do not occur get computed by pre().
27352735 Ticket #5659
27362736 */
2737- if indexTypeSolvable(inIndexType) then
2738- crefLst := CheckModel . algorithmStatementListOutputs(statementLst, DAE . EXPAND ()); // expand as we're in an algorithm
2739- for cr in crefLst loop
2740- try
2741- (varslst, p) := BackendVariable . getVar(cr, vars);
2742- res := adjacencyRowExp1Discrete(varslst, p, res);
2743- else
2744- /* Nothing to do, BackendVariable.getVar fails for $START, $PRE, time etc. */
2745- end try ;
2746- end for ;
2747- end if ;
2737+ crefLst := CheckModel . algorithmStatementListOutputs(statementLst, DAE . EXPAND ()); // expand as we're in an algorithm
2738+ for cr in crefLst loop
2739+ try
2740+ (varslst, p) := BackendVariable . getVar(cr, vars);
2741+ res := adjacencyRowExp1DiscreteOrArray(varslst, p, res);
2742+ else
2743+ /* Nothing to do, BackendVariable.getVar fails for $START, $PRE, time etc. */
2744+ end try ;
2745+ try
2746+ (varslst, p) := BackendVariable . getVar(ComponentReference . crefPrefixStart(cr), vars);
2747+ res := adjacencyRowExp1DiscreteOrArray(varslst, p, res);
2748+ else
2749+ /* Nothing to do, BackendVariable.getVar fails for $START, $PRE, time etc. */
2750+ end try ;
2751+ end for ;
27482752 then
27492753 (res,size);
27502754
@@ -3624,7 +3628,7 @@ algorithm
36243628 end match;
36253629end adjacencyRowExp1;
36263630
3627- protected function adjacencyRowExp1Discrete
3631+ protected function adjacencyRowExp1DiscreteOrArray
36283632 "Adds an adjacency matrix entry for all variables in the inVarLst, if they are discrete."
36293633 input list< BackendDAE . Var > inVarLst;
36303634 input list< Integer > inIntegerLst;
@@ -3638,14 +3642,14 @@ algorithm
36383642 AvlSetInt . Tree vars;
36393643 Integer i;
36403644 case ({}, {}) then inVarIndxLst;
3641- case (BackendDAE . VAR (varKind = BackendDAE . DISCRETE () )::rest, i::irest)
3645+ case (BackendDAE . VAR ()::rest, i::irest)
36423646 equation
36433647 vars = AvlSetInt . add(inVarIndxLst, i);
3644- then adjacencyRowExp1Discrete (rest,irest,vars);
3648+ then adjacencyRowExp1DiscreteOrArray (rest,irest,vars);
36453649 case (_::rest, _::irest)
3646- then adjacencyRowExp1Discrete (rest,irest,inVarIndxLst);
3650+ then adjacencyRowExp1DiscreteOrArray (rest,irest,inVarIndxLst);
36473651 end match;
3648- end adjacencyRowExp1Discrete ;
3652+ end adjacencyRowExp1DiscreteOrArray ;
36493653
36503654public function traversingadjacencyRowExpFinderwithInput "Helper for statesAndVarsExp"
36513655 input DAE . Exp inExp;
@@ -4317,21 +4321,6 @@ protected function traverseStmts<ArgT> "Author: Frenkel TUD 2012-06
43174321 end FuncExpType ;
43184322
43194323protected
4320- function removeSubscripts
4321- "kabdelhak: remove left hand side subscripts
4322- (Modelica Specification v3.5 : 11.1.2)
4323- Fix: Do not do if it is a scalar variable with all constant subscripts.
4324- It leads to a massive number of hash table accesses for big tensors."
4325- input output DAE . Exp exp;
4326- algorithm
4327- exp := match exp
4328- case DAE . CREF () guard(not ComponentReference . crefIsScalarWithAllConstSubs(exp. componentRef)) algorithm
4329- exp. componentRef := ComponentReference . crefStripSubsExceptModelSubs(exp. componentRef);
4330- then exp;
4331- else exp;
4332- end match;
4333- end removeSubscripts;
4334-
43354324 DAE . Exp e,e2;
43364325 list< DAE . Exp > expl1;
43374326 DAE . ComponentRef cr;
@@ -4350,7 +4339,7 @@ algorithm
43504339 // (Modelica Specification v3.5 : 11.1.2)
43514340 // solves ticket #7832
43524341 extraArg = func (e, extraArg);
4353- extraArg = func (removeSubscripts(e2) , extraArg);
4342+ extraArg = func (e2 , extraArg);
43544343 then
43554344 extraArg;
43564345
@@ -4360,7 +4349,7 @@ algorithm
43604349 // (Modelica Specification v3.5 : 11.1.2)
43614350 // solves ticket #7832
43624351 extraArg = func (e, extraArg);
4363- extraArg = List . fold(list(removeSubscripts(ex) for ex in expl1) ,func ,extraArg);
4352+ extraArg = List . fold(expl1,func ,extraArg);
43644353 then
43654354 extraArg;
43664355
@@ -4370,7 +4359,7 @@ algorithm
43704359 // (Modelica Specification v3.5 : 11.1.2)
43714360 // solves ticket #7832
43724361 extraArg = func (e, extraArg);
4373- extraArg = func (removeSubscripts(e2) , extraArg);
4362+ extraArg = func (e2 , extraArg);
43744363 then
43754364 extraArg;
43764365
@@ -10322,16 +10311,6 @@ algorithm
1032210311 end match;
1032310312end containsHomotopyCall2;
1032410313
10325- protected function indexTypeSolvable
10326- input BackendDAE . IndexType indexType;
10327- output Boolean b;
10328- algorithm
10329- b := match indexType
10330- case BackendDAE . SOLVABLE () then true ;
10331- else false ;
10332- end match;
10333- end indexTypeSolvable;
10334-
1033510314public function doIndexReduction
1033610315 input BackendDAE . MatchingOptions opt;
1033710316 output Boolean b;
0 commit comments