Skip to content

Commit

Permalink
- bugfix dynamic state selection
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14614 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jan 1, 2013
1 parent 312252b commit 47dc5c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 90 deletions.
94 changes: 4 additions & 90 deletions Compiler/BackEnd/IndexReduction.mo
Expand Up @@ -2167,14 +2167,10 @@ algorithm
m = incidenceMatrixfromEnhanced2(inMe,vars);
mT = BackendDAEUtil.transposeMatrix(m,inVarSize);
Debug.fcall(Flags.BLT_DUMP, BackendDump.printEqSystem, BackendDAE.EQSYSTEM(vars,eqns,SOME(m),SOME(mT),BackendDAE.NO_MATCHING(),{}));
// simplify the system

// do onefree matching

// match the variables not the equations, to have prevered states unmatched
vec1 = arrayCreate(inEqnsSize,-1);
vec2 = arrayCreate(inVarSize,-1);
//onefreeMatchingBFS(List.intRange(inEqnsSize),m,mT,vec2,vec1,{});
// match the variables not the equations, to have prevered states unmatched
//true = BackendDAEEXT.setAssignment(inVarSize,inEqnsSize,vec2,vec1);
Matching.matchingExternalsetIncidenceMatrix(inEqnsSize,inVarSize,mT);
BackendDAEEXT.matching(inEqnsSize,inVarSize,3,-1,1.0,1);
BackendDAEEXT.getAssignment(vec2,vec1);
Expand All @@ -2196,9 +2192,8 @@ algorithm
syst = BackendDAE.EQSYSTEM(vars,eqns,NONE(),NONE(),BackendDAE.MATCHING(vec2,vec1,{}),{});
// dumpSystemGraphML(syst,inIshared,NONE(),"StateSelection" +& intString(arrayLength(m)) +& ".graphml");
(syst,m,mT,mapEqnIncRow1,mapIncRowEqn1) = BackendDAEUtil.getIncidenceMatrixScalar(syst,BackendDAE.NORMAL());
sets = Matching.getEqnsforIndexReduction(unassigned,arrayLength(m),m,mT,vec1,vec2,(so,orgEqnsLst,mapEqnIncRow1,mapIncRowEqn1,noofeqns));
// collect equations with no sets and add it to the system

// TODO: partition the system
sets = {unassigned};

// print("Sets:\n");
// BackendDump.dumpIncidenceMatrix(listArray(sets));
Expand All @@ -2209,87 +2204,6 @@ algorithm
end matchcontinue;
end processComps3New;

protected function onefreeMatchingBFS
"function onefreeMatchingBFS
author: Frenkel TUD 2012-05"
input BackendDAE.IncidenceMatrixElement queue;
input BackendDAE.IncidenceMatrix m;
input BackendDAE.IncidenceMatrixT mt;
input array<Integer> ass1;
input array<Integer> ass2;
input BackendDAE.IncidenceMatrixElement nextQeue;
algorithm
_ := match(queue,m,mt,ass1,ass2,nextQeue)
local
Integer c;
BackendDAE.IncidenceMatrixElement rest,newqueue,rows;
case ({},_,_,_,_,{}) then ();
case ({},_,_,_,_,_)
equation
// print("NextQeue\n");
onefreeMatchingBFS(nextQeue,m,mt,ass1,ass2,{});
then
();
case(c::rest,_,_,_,_,_)
equation
// print("Process Eqn " +& intString(c) +& "\n");
rows = List.removeOnTrue(ass1, isAssignedSaveEnhanced, m[c]);
//_ = arrayUpdate(columark,c,mark);
newqueue = onefreeMatchingBFS1(rows,c,mt,ass1,ass2,nextQeue);
onefreeMatchingBFS(rest,m,mt,ass1,ass2,newqueue);
then
();
end match;
end onefreeMatchingBFS;

protected function isAssignedSaveEnhanced
"function isAssigned
author: Frenkel TUD 2012-05"
input array<Integer> ass;
input Integer inTpl;
output Boolean outB;
algorithm
outB := matchcontinue(ass,inTpl)
local
Integer i;
case (_,i)
equation
true = intGt(i,0);
then
intGt(ass[i],0);
else
true;
end matchcontinue;
end isAssignedSaveEnhanced;

protected function onefreeMatchingBFS1
"function onefreeMatchingBFS1
author: Frenkel TUD 2012-05"
input BackendDAE.IncidenceMatrixElement rows;
input Integer c;
input BackendDAE.IncidenceMatrix mt;
input array<Integer> ass1;
input array<Integer> ass2;
input BackendDAE.IncidenceMatrixElement inNextQeue;
output BackendDAE.IncidenceMatrixElement outNextQeue;
algorithm
outNextQeue := matchcontinue(rows,c,mt,ass1,ass2,inNextQeue)
local
Integer r;
BackendDAE.IncidenceMatrixElement vareqns;
case (r::{},_,_,_,_,_)
equation
// print("Assign Var" +& intString(r) +& " with Eqn " +& intString(c) +& "\n");
// assigen
_ = arrayUpdate(ass1,r,c);
_ = arrayUpdate(ass2,c,r);
vareqns = List.removeOnTrue(ass2, isAssignedSaveEnhanced, mt[r]);
then
listAppend(inNextQeue,vareqns);
else then inNextQeue;
end matchcontinue;
end onefreeMatchingBFS1;

protected function processComps4New
"function: processComps4
author: Frenkel TUD 2012-12
Expand Down
1 change: 1 addition & 0 deletions Compiler/BackEnd/SimCodeUtil.mo
Expand Up @@ -4181,6 +4181,7 @@ algorithm
case({},_,_,_,_,_,_,_) then (iVars,iEquations,iuniqueEqIndex,itempvars,iNumStateSets);
case(BackendDAE.STATESET(rang=rang,state=crset,crA=crA,varA=aVars,statescandidates=statevars,ovars=dstatesvars,eqns=ceqns,oeqns=oeqns,crJ=crJ,varJ=varJ)::sets,_,_,_,_,_,_,_)
equation
// ToDo: get Equations for Jac from the strong component with crset equation
// add vars for A
vars = BackendVariable.addVars(aVars,iVars);
// replace der in equations
Expand Down

0 comments on commit 47dc5c2

Please sign in to comment.