Skip to content

Commit

Permalink
[BE] adjacency matrix update
Browse files Browse the repository at this point in the history
 - add initial() operator check in if equations
 - ticket #5795
 - related to PR #677 and #679
  • Loading branch information
kabdelhak authored and adrpo committed Jan 23, 2020
1 parent c7f16df commit 29b5029
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions OMCompiler/Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -2716,7 +2716,40 @@ algorithm
then
(res,size);

// if Equation
/*
special case: initial()
if initial() then ... else ... end if;
only then branch needs to be checked for initialization and else branch otherwise
*/
case BackendDAE.IF_EQUATION(conditions={DAE.CALL(path=Absyn.IDENT("initial"))},eqnstrue=eqnslst,eqnsfalse=eqns)
algorithm
if not isInitial then
// only one condition, therefore the list of lists for "then" only contains one list
{eqns} := eqnslst;
end if;
(res,size) := incidenceRowLst(eqns, vars, inIndexType, functionTree, iRow, isInitial);
then
(res,size);

/*
special case: NEGATED initial()
if not initial() then ... else ... end if;
only else branch needs to be checked for initialization and then branch otherwise
*/
case BackendDAE.IF_EQUATION(conditions={DAE.LUNARY(DAE.NOT(), DAE.CALL(path=Absyn.IDENT("initial")))},eqnstrue=eqnslst,eqnsfalse=eqns)
algorithm
if isInitial then
// only one condition, therefore the list of lists for "then" only contains one list
{eqns} := eqnslst;
end if;
(res,size) := incidenceRowLst(eqns, vars, inIndexType, functionTree, iRow, isInitial);
then
(res,size);

/*
if Equation
ToDo: More checks for stuff like initial()
*/
case BackendDAE.IF_EQUATION(conditions=expl,eqnstrue=eqnslst,eqnsfalse=eqns)
equation
res = incidenceRow1(expl, incidenceRowExp, vars, iRow, functionTree, inIndexType, isInitial);
Expand Down Expand Up @@ -4440,7 +4473,6 @@ algorithm
// 3. vars occur not in all branches: then unsolvable
case(BackendDAE.IF_EQUATION(conditions=expl,eqnstrue=eqnslst,eqnsfalse=eqnselse)) algorithm
try
print("\n if equation?");
//check condition?
try_b := tryToFindSolvableEqInBranch(inCref, eqnselse, varArray, inVariables, globalKnownVars);
true := try_b;
Expand Down Expand Up @@ -4998,7 +5030,7 @@ algorithm
/*
special case: NEGATED initial()
if not initial() then ... else ... end if;
only then branch needs to be checked for initialization and else branch otherwise
only else branch needs to be checked for initialization and then branch otherwise
*/
case(_,BackendDAE.IF_EQUATION(conditions={DAE.LUNARY(DAE.NOT(), DAE.CALL(path=Absyn.IDENT("initial")))},eqnstrue={eqns}, eqnsfalse=eqnselse),_,_,_)
algorithm
Expand Down

0 comments on commit 29b5029

Please sign in to comment.