Skip to content

Commit

Permalink
- fix tests
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12857 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Sep 10, 2012
1 parent 884b252 commit 2d89e8d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 27 deletions.
51 changes: 43 additions & 8 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ protected function updateStrongComponent
input BackendDAE.StrongComponents iAcc;
output BackendDAE.StrongComponents oComps;
algorithm
oComps := match(iComp,varindxs,eqnindxs,iAcc)
oComps := matchcontinue(iComp,varindxs,eqnindxs,iAcc)
local
BackendDAE.StrongComponents comps;
BackendDAE.StrongComponent comp;
Expand All @@ -1397,8 +1397,9 @@ algorithm
e::_ = eqns;
v::_ = vars;
comp = Util.if_(intEq(listLength(eqns),1),BackendDAE.SINGLEEQUATION(e,v),BackendDAE.EQUATIONSYSTEM(eqns,vars,NONE(),jacType));
comps = List.consOnTrue(intGt(listLength(eqns),0), comp, iAcc);
then
comp::iAcc;
comps;
case (BackendDAE.MIXEDEQUATIONSYSTEM(condSystem=comp,disc_eqns=eqns,disc_vars=vars),_,_,_)
equation
comp::_ =updateStrongComponent(comp,varindxs,eqnindxs,{});
Expand All @@ -1407,8 +1408,9 @@ algorithm
vars = List.map1r(vars,arrayGet,varindxs);
vars = List.select1(vars,intGt,0);
comp = Util.if_(intEq(listLength(eqns),0),comp,BackendDAE.MIXEDEQUATIONSYSTEM(comp,eqns,vars));
comps = List.consOnTrue(intGt(listLength(eqns),0), comp, iAcc);
then
comp::iAcc;
comps;
case (BackendDAE.SINGLEARRAY(eqn=e,vars=vars),_,_,_)
equation
e = eqnindxs[e];
Expand Down Expand Up @@ -1443,9 +1445,41 @@ algorithm
comp = BackendDAE.TORNSYSTEM(vars,eqns,eqnvartpllst,b);
then
comp::iAcc;
end match;
case (_,_,_,_)
equation
print("BackendDAEOptimize.updateStrongComponent failed for Comp:\n");
BackendDump.dumpComponent(iComp);
print("Size EqnsIndx: " +& intString(arrayLength(eqnindxs)) +& "\n");
print("Size VarsIndx: " +& intString(arrayLength(varindxs)) +& "\n");
then
fail();
end matchcontinue;
end updateStrongComponent;

protected function updateEquationSystemComp
input list<Integer> eqns;
input list<Integer> vars;
input BackendDAE.JacobianType jacType;
input BackendDAE.StrongComponents iAcc;
output BackendDAE.StrongComponents oComps;
algorithm
oComps := match(eqns,vars,jacType,iAcc)
local
Integer e,v;
case ({},{},_,_) then iAcc;
case ({},v::_,_,_)
//equation
then
fail();
case (e::{},v::_,_,_)
then
BackendDAE.SINGLEEQUATION(e,v)::iAcc;
case (_,_,_,_)
then
BackendDAE.EQUATIONSYSTEM(eqns,vars,NONE(),jacType)::iAcc;
end match;
end updateEquationSystemComp;

protected function updateTornSystemComp
input list<tuple<Integer,list<Integer>>> inEqnVarTplLst;
input array<Integer> varindxs;
Expand Down Expand Up @@ -4549,17 +4583,18 @@ algorithm
BackendDAE.StrongComponents comps;
array<Integer> ass1,ass2;
case (false,_) then isyst;
case (true,BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns,matching=BackendDAE.NO_MATCHING()))
// case (true,BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns,matching=BackendDAE.NO_MATCHING()))
case (true,BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns))
equation
// remove empty entries from vars/eqns
vars = BackendDAEUtil.listVar1(BackendDAEUtil.varList(vars));
eqns = BackendDAEUtil.listEquation(BackendDAEUtil.equationList(eqns));
then
BackendDAE.EQSYSTEM(vars,eqns,NONE(),NONE(),BackendDAE.NO_MATCHING());
case (true,BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns,matching=BackendDAE.MATCHING(ass1=ass1,ass2=ass2,comps=comps)))
/* case (true,BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns,matching=BackendDAE.MATCHING(ass1=ass1,ass2=ass2,comps=comps)))
then
updateEquationSystemMatching(vars,eqns,ass1,ass2,comps);
end match;
*/ end match;
end constantLinearSystem2;

protected function constantLinearSystem1
Expand Down Expand Up @@ -4636,7 +4671,7 @@ algorithm
BackendDAE.BinTree movedVars;
BackendDAE.Matching matching;
DAE.FunctionTree funcs;
BackendDAE.Shared shared;
BackendDAE.Shared shared;
case (BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns,matching=matching),BackendDAE.SHARED(functionTree=funcs),_,_,_,_,_)
equation
eqns1 = BackendDAEUtil.listEquation(eqn_lst);
Expand Down
29 changes: 10 additions & 19 deletions Compiler/BackEnd/BackendDAEUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ algorithm

case (BackendDAE.EQUATION_ARRAY(numberOfElement = n,arrSize = size,equOptArr = arr))
equation
lst = equationList2(arr, 1, n);
lst = equationList2(arr, n, {});
then
lst;

Expand All @@ -1326,32 +1326,23 @@ protected function equationList2 "function: equationList2
Helper function to equationList
inputs: (Equation option array, int /* pos */, int /* lastpos */)
outputs: BackendDAE.Equation list"
input array<Option<BackendDAE.Equation>> inEquationOptionArray1;
input Integer inInteger2;
input Integer inInteger3;
input array<Option<BackendDAE.Equation>> arr;
input Integer pos;
input list<BackendDAE.Equation> iAcc;
output list<BackendDAE.Equation> outEquationLst;
algorithm
outEquationLst := matchcontinue (inEquationOptionArray1,inInteger2,inInteger3)
outEquationLst := matchcontinue (arr,pos,iAcc)
local
BackendDAE.Equation e;
array<Option<BackendDAE.Equation>> arr;
BackendDAE.Value pos,lastpos,pos_1;
list<BackendDAE.Equation> res;

case (arr,pos,lastpos)
case (_,0,_) then iAcc;
case (_,_,_)
equation
(pos == lastpos) = true;
SOME(e) = arr[pos];
then
{e};

case (arr,pos,lastpos)
equation
pos_1 = pos + 1;
SOME(e) = arr[pos];
res = equationList2(arr, pos_1, lastpos);
equationList2(arr,pos-1,e::iAcc);
case (_,_,_)
then
(e :: res);
equationList2(arr,pos-1,iAcc);
end matchcontinue;
end equationList2;

Expand Down

0 comments on commit 2d89e8d

Please sign in to comment.