@@ -2716,7 +2716,40 @@ algorithm
27162716 then
27172717 (res,size);
27182718
2719- // if Equation
2719+ /*
2720+ special case: initial()
2721+ if initial() then ... else ... end if;
2722+ only then branch needs to be checked for initialization and else branch otherwise
2723+ */
2724+ case BackendDAE . IF_EQUATION (conditions= {DAE . CALL (path= Absyn . IDENT ("initial" ))},eqnstrue= eqnslst,eqnsfalse= eqns)
2725+ algorithm
2726+ if not isInitial then
2727+ // only one condition, therefore the list of lists for "then" only contains one list
2728+ {eqns} := eqnslst;
2729+ end if ;
2730+ (res,size) := incidenceRowLst(eqns, vars, inIndexType, functionTree, iRow, isInitial);
2731+ then
2732+ (res,size);
2733+
2734+ /*
2735+ special case: NEGATED initial()
2736+ if not initial() then ... else ... end if;
2737+ only else branch needs to be checked for initialization and then branch otherwise
2738+ */
2739+ case BackendDAE . IF_EQUATION (conditions= {DAE . LUNARY (DAE . NOT (), DAE . CALL (path= Absyn . IDENT ("initial" )))},eqnstrue= eqnslst,eqnsfalse= eqns)
2740+ algorithm
2741+ if isInitial then
2742+ // only one condition, therefore the list of lists for "then" only contains one list
2743+ {eqns} := eqnslst;
2744+ end if ;
2745+ (res,size) := incidenceRowLst(eqns, vars, inIndexType, functionTree, iRow, isInitial);
2746+ then
2747+ (res,size);
2748+
2749+ /*
2750+ if Equation
2751+ ToDo: More checks for stuff like initial()
2752+ */
27202753 case BackendDAE . IF_EQUATION (conditions= expl,eqnstrue= eqnslst,eqnsfalse= eqns)
27212754 equation
27222755 res = incidenceRow1(expl, incidenceRowExp, vars, iRow, functionTree, inIndexType, isInitial);
@@ -4440,7 +4473,6 @@ algorithm
44404473 // 3. vars occur not in all branches: then unsolvable
44414474 case (BackendDAE . IF_EQUATION (conditions= expl,eqnstrue= eqnslst,eqnsfalse= eqnselse)) algorithm
44424475 try
4443- print(" \n if equation?" );
44444476 // check condition?
44454477 try_b := tryToFindSolvableEqInBranch(inCref, eqnselse, varArray, inVariables, globalKnownVars);
44464478 true := try_b;
@@ -4998,7 +5030,7 @@ algorithm
49985030 /*
49995031 special case: NEGATED initial()
50005032 if not initial() then ... else ... end if;
5001- only then branch needs to be checked for initialization and else branch otherwise
5033+ only else branch needs to be checked for initialization and then branch otherwise
50025034 */
50035035 case (_,BackendDAE . IF_EQUATION (conditions= {DAE . LUNARY (DAE . NOT (), DAE . CALL (path= Absyn . IDENT ("initial" )))},eqnstrue= {eqns}, eqnsfalse= eqnselse),_,_,_)
50045036 algorithm
0 commit comments