Skip to content

Commit

Permalink
- bugfix for tuple initial equations
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13653 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Oct 26, 2012
1 parent 0e22c33 commit be90161
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -260,6 +260,18 @@ algorithm
then
(inVars,inKnVars,inExVars,eqns,reqns,ieqns,inConstraintLst,inClassAttributeLst,inWhenClauseLst,inExtObjClasses,iAliaseqns);

/* Only succeds for initial tuple equations, i.e. (a,b,c) = foo(x,y,z) or foo(x,y,z) = (a,b,c) */
case(DAE.INITIALEQUATION(DAE.TUPLE(explst),e2 as DAE.CALL(path =_),source),_,_,_,_,_,_,_,_,_,_,_,_)
equation
(eqns,reqns,ieqns) = lowerAlgorithm(DAE.INITIALALGORITHM(DAE.ALGORITHM_STMTS({DAE.STMT_TUPLE_ASSIGN(DAE.T_UNKNOWN_DEFAULT,explst,e2,source)}),source),functionTree,inEqnsLst,inREqnsLst,inIEqnsLst);
then
(inVars,inKnVars,inExVars,eqns,reqns,ieqns,inConstraintLst,inClassAttributeLst,inWhenClauseLst,inExtObjClasses,iAliaseqns);
case(DAE.INITIALEQUATION(e2 as DAE.CALL(path =_),DAE.TUPLE(explst),source),_,_,_,_,_,_,_,_,_,_,_,_)
equation
(eqns,reqns,ieqns) = lowerAlgorithm(DAE.INITIALALGORITHM(DAE.ALGORITHM_STMTS({DAE.STMT_TUPLE_ASSIGN(DAE.T_UNKNOWN_DEFAULT,explst,e2,source)}),source),functionTree,inEqnsLst,inREqnsLst,inIEqnsLst);
then
(inVars,inKnVars,inExVars,eqns,reqns,ieqns,inConstraintLst,inClassAttributeLst,inWhenClauseLst,inExtObjClasses,iAliaseqns);

// scalar equations
case (DAE.EQUATION(exp = _),_,_,_,_,_,_,_,_,_,_,_,_)
equation
Expand Down Expand Up @@ -904,6 +916,9 @@ algorithm
case (DAE.EQUATION(DAE.TUPLE(explst), DAE.TUPLE(explst1), source = source),_,_)
then
lowerTupleAssignment(explst,explst1,source,functionTree,inEqns);
case (DAE.INITIALEQUATION(DAE.TUPLE(explst), DAE.TUPLE(explst1), source = source),_,_)
then
lowerTupleAssignment(explst,explst1,source,functionTree,inEqns);

case (DAE.EQUATION(exp = e1,scalar = e2,source = source),_,_)
equation
Expand Down
2 changes: 2 additions & 0 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -9340,6 +9340,7 @@ algorithm
equation
true = intLt(nEqns,nVars);
print("underconstrained Intial System\n");
BackendDump.dump(inDAE);

then
{};
Expand Down Expand Up @@ -9393,6 +9394,7 @@ algorithm
case((var as BackendDAE.VAR(varKind=BackendDAE.PARAM()),(vars,fixvars)))
equation
b = BackendVariable.varFixed(var);
var = BackendVariable.setVarKind(var,BackendDAE.VARIABLE());
vars = Debug.bcallret2(not b,BackendVariable.addVar,var,vars,vars);
then
((var,(vars,fixvars)));
Expand Down
14 changes: 13 additions & 1 deletion Compiler/BackEnd/BackendDump.mo
Expand Up @@ -698,6 +698,10 @@ algorithm
eqnlen = listLength(eqnsl);
eqnlen_str = intString(eqnlen);
print(eqnlen_str);
eqnssize = BackendDAEUtil.equationSize(eqns);
print(", ");
print(intString(eqnssize));
print(")\n");
print(")\n");
print("=========\n");
dumpEqns(eqnsl);
Expand All @@ -716,7 +720,7 @@ algorithm
match (inShared)
local
list<BackendDAE.Var> knvars,extvars;
Integer varlen,eqnlen;
Integer varlen,eqnlen,eqnssize;
String varlen_str,eqnlen_str,s;
list<BackendDAE.Equation> reqnsl,ieqnsl;
list<String> ss;
Expand Down Expand Up @@ -769,6 +773,10 @@ algorithm
eqnlen = listLength(reqnsl);
eqnlen_str = intString(eqnlen);
print(eqnlen_str);
eqnssize = BackendDAEUtil.equationSize(reqns);
print(", ");
print(intString(eqnssize));
print(")\n");
print(")\n");
print("=========\n");
dumpEqns(reqnsl);
Expand All @@ -777,6 +785,10 @@ algorithm
eqnlen = listLength(ieqnsl);
eqnlen_str = intString(eqnlen);
print(eqnlen_str);
eqnssize = BackendDAEUtil.equationSize(ieqns);
print(", ");
print(intString(eqnssize));
print(")\n");
print(")\n");
print("=========\n");
dumpEqns(ieqnsl);
Expand Down

0 comments on commit be90161

Please sign in to comment.