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@14704 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jan 7, 2013
1 parent f49a670 commit 5bb1ebb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackEnd/IndexReduction.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2392,11 +2392,11 @@ algorithm
ne = BackendDAEUtil.systemSize(isyst);
// add the original equations to the systems
syst = BackendEquation.equationsAddDAE(eqnslst1, isyst);
// add the found state sets for dynamic state selection to the system
(setIndex,syst) = addStateSets(stateSets,iSetIndex,syst);
// change dummy states
dummyStates = List.map(dummyVars,BackendVariable.varCref);
(syst,ht) = addDummyStates(dummyStates,syst,iHt);
// add the found state sets for dynamic state selection to the system
(setIndex,syst) = addStateSets(stateSets,iSetIndex,syst);
// update IncidenceMatrix
(syst,m,_,mapEqnIncRow,mapIncRowEqn) = BackendDAEUtil.getIncidenceMatrixScalar(syst,BackendDAE.SOLVABLE(), SOME(funcs));
// genereate new Matching
Expand Down
30 changes: 22 additions & 8 deletions Compiler/BackEnd/RemoveSimpleEquations.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3214,13 +3214,16 @@ algorithm
list< BackendDAE.Var> varA,statescandidates,ovars,varJ;
list< BackendDAE.Equation> eqns,oeqns;
BackendVarTransform.VariableReplacements repl;
HashSet.HashSet hs;
Boolean b,b1;
case ({},_,_,_,_,_) then (listReverse(iAcc),inB,iStatesetrepl);
case (BackendDAE.STATESET(rang,states,crA,varA,statescandidates,ovars,eqns,oeqns,crJ,varJ)::stateSets,_,_,_,_,_)
equation
repl = getAliasReplacements(iStatesetrepl,aliasVars);
// do not replace the set variables
ovars = replaceOtherStateSetVars(ovars,vars,aliasVars,{});
hs = HashSet.emptyHashSet();
hs = List.fold(List.map(statescandidates,BackendVariable.varCref),BaseHashSet.add,hs);
ovars = replaceOtherStateSetVars(ovars,vars,aliasVars,hs,{});
(eqns,b) = BackendVarTransform.replaceEquations(eqns,repl,SOME(BackendVarTransform.skipPreChangeEdgeOperator));
(oeqns,b1) = BackendVarTransform.replaceEquations(oeqns,repl,SOME(BackendVarTransform.skipPreChangeEdgeOperator));
oeqns = List.fold(oeqns,removeEqualLshRshEqns,{});
Expand Down Expand Up @@ -3266,29 +3269,40 @@ protected function replaceOtherStateSetVars
author: Frenkel TUD 2012-12"
input list< BackendDAE.Var> iVarLst;
input BackendDAE.Variables vars;
input BackendDAE.Variables aliasVars;
input BackendDAE.Variables aliasVars;
input HashSet.HashSet hs;
input list< BackendDAE.Var> iAcc;
output list< BackendDAE.Var> oVarLst;
algorithm
oVarLst := matchcontinue(iVarLst,vars,aliasVars,iAcc)
oVarLst := matchcontinue(iVarLst,vars,aliasVars,hs,iAcc)
local
BackendDAE.Var var;
list< BackendDAE.Var> varlst;
DAE.ComponentRef cr;
DAE.Exp exp;
case ({},_,_,_) then iAcc;
case (var::varlst,_,_,_)
Boolean b;
case ({},_,_,_,_) then iAcc;
case (var::varlst,_,_,_,_)
equation
cr = BackendVariable.varCref(var);
false = BaseHashSet.has(cr,hs);
({var},_) = BackendVariable.getVar(cr,aliasVars);
exp = BackendVariable.varBindExp(var);
cr::{} = Expression.extractCrefsFromExp(exp);
b = BaseHashSet.has(cr,hs);
({var},_) = BackendVariable.getVar(cr,vars);
varlst = List.consOnTrue(not b, var, iAcc);
then
replaceOtherStateSetVars(varlst,vars,aliasVars,hs,varlst);
case (var::varlst,_,_,_,_)
equation
cr = BackendVariable.varCref(var);
true = BaseHashSet.has(cr,hs);
then
replaceOtherStateSetVars(varlst,vars,aliasVars,var::iAcc);
case (var::varlst,_,_,_)
replaceOtherStateSetVars(varlst,vars,aliasVars,hs,iAcc);
case (var::varlst,_,_,_,_)
then
replaceOtherStateSetVars(varlst,vars,aliasVars,var::iAcc);
replaceOtherStateSetVars(varlst,vars,aliasVars,hs,var::iAcc);
end matchcontinue;
end replaceOtherStateSetVars;

Expand Down

0 comments on commit 5bb1ebb

Please sign in to comment.