Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit ee4deab

Browse files
kabdelhakOpenModelica-Hudson
authored andcommitted
[BE] Add unique index of stateSets as attribute
Belonging to [master]: - #3046
1 parent 3f5cb68 commit ee4deab

4 files changed

Lines changed: 14 additions & 13 deletions

File tree

Compiler/BackEnd/BackendDAE.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ type StateSets = list<StateSet> "List of StateSets";
609609
public
610610
uniontype StateSet
611611
record STATESET
612+
Integer index;
612613
Integer rang; // how many states are needed?
613614
list< .DAE.ComponentRef> state;
614615
.DAE.ComponentRef crA "set.x=A*states";

Compiler/BackEnd/IndexReduction.mo

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import List;
7272
import Matching;
7373
import SCode;
7474
import Sorting;
75+
import SymbolicJacobian;
7576
import System;
7677
import Util;
7778

@@ -1311,7 +1312,7 @@ protected function dynamicStateSelectionWork
13111312
output BackendDAE.EqSystem osyst;
13121313
output BackendDAE.Shared oshared;
13131314
output HashTableCrIntToExp.HashTable oHt;
1314-
output Integer oSetIndex;
1315+
output Integer oSetIndex=iSetIndex;
13151316
protected
13161317
BackendDAE.StateOrder so;
13171318
BackendDAE.ConstraintEquations orgEqnsLst;
@@ -1544,7 +1545,7 @@ protected function addStateSets
15441545
input StateSets iTplLst;
15451546
input Integer iSetIndex;
15461547
input BackendDAE.EqSystem inSystem;
1547-
output Integer oSetIndex;
1548+
output Integer oSetIndex=iSetIndex;
15481549
output BackendDAE.EqSystem oSystem;
15491550
algorithm
15501551
(oSetIndex,oSystem) := match(iTplLst,inSystem)
@@ -1644,8 +1645,8 @@ algorithm
16441645
stateCandidates := List.map1(stateCandidates,BackendVariable.setVarKind,BackendDAE.DUMMY_STATE());
16451646
otherVars := List.map1(otherVars,BackendVariable.setVarKind,BackendDAE.DUMMY_STATE());
16461647

1648+
oStateSets := BackendDAE.STATESET(oSetIndex,rang,crset,crA,aVars,stateCandidates,otherVars,cEqnsLst,oEqnLst,crJ,varJ,BackendDAE.EMPTY_JACOBIAN())::oStateSets;
16471649
oSetIndex := oSetIndex + 1;
1648-
oStateSets := BackendDAE.STATESET(rang,crset,crA,aVars,stateCandidates,otherVars,cEqnsLst,oEqnLst,crJ,varJ,BackendDAE.EMPTY_JACOBIAN())::oStateSets;
16491650
end for;
16501651
end generateStateSets;
16511652

@@ -1663,7 +1664,7 @@ protected function setStartExp
16631664
input Integer size;
16641665
input Integer iIndex;
16651666
output BackendDAE.Var outVar;
1666-
output Integer oIndex;
1667+
output Integer oIndex=iIndex;
16671668
protected
16681669
DAE.Exp e;
16691670
algorithm
@@ -1690,7 +1691,7 @@ protected function selectStates
16901691
output BackendDAE.EqSystem osyst;
16911692
output BackendDAE.Shared oshared;
16921693
output HashTableCrIntToExp.HashTable oHt;
1693-
output Integer oSetIndex;
1694+
output Integer oSetIndex=iSetIndex;
16941695
algorithm
16951696
(osyst,oshared,oHt,oSetIndex) := matchcontinue inSystem
16961697
local
@@ -1777,7 +1778,7 @@ protected function selectStatesWork
17771778
output BackendDAE.EqSystem osyst;
17781779
output BackendDAE.Shared oshared;
17791780
output HashTableCrIntToExp.HashTable oHt;
1780-
output Integer oSetIndex;
1781+
output Integer oSetIndex=iSetIndex;
17811782
algorithm
17821783
(osyst,oshared,oHt,oSetIndex) :=
17831784
matchcontinue (inSystem, iOrgEqnsLst)

Compiler/BackEnd/RemoveSimpleEquations.mo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,7 +3840,7 @@ algorithm
38403840
(oStateSets, outB, oStatesetrepl) := match(iStateSets, iStatesetrepl, vars, aliasVars, iAcc, inB)
38413841
local
38423842
BackendDAE.StateSets stateSets;
3843-
Integer rang;
3843+
Integer index, rang;
38443844
list< DAE.ComponentRef> states;
38453845
DAE.ComponentRef crA, crJ;
38463846
list< BackendDAE.Var> varA, statescandidates, ovars, varJ;
@@ -3850,7 +3850,7 @@ algorithm
38503850
Boolean b, b1;
38513851
BackendDAE.Jacobian jac;
38523852
case ({}, _, _, _, _, _) then (listReverse(iAcc), inB, iStatesetrepl);
3853-
case (BackendDAE.STATESET(rang, states, crA, varA, statescandidates, ovars, eqns, oeqns, crJ, varJ, jac)::stateSets, _, _, _, _, _)
3853+
case (BackendDAE.STATESET(index, rang, states, crA, varA, statescandidates, ovars, eqns, oeqns, crJ, varJ, jac)::stateSets, _, _, _, _, _)
38543854
equation
38553855
repl = getAliasReplacements(iStatesetrepl, aliasVars);
38563856
// do not replace the set variables
@@ -3861,7 +3861,7 @@ algorithm
38613861
(oeqns, b1) = BackendVarTransform.replaceEquations(oeqns, repl, SOME(BackendVarTransform.skipPreChangeEdgeOperator));
38623862
oeqns = List.fold(oeqns, removeEqualLshRshEqns, {});
38633863
oeqns = listReverse(oeqns);
3864-
(stateSets, b, oStatesetrepl) = removeAliasVarsStateSets(stateSets, SOME(repl), vars, aliasVars, BackendDAE.STATESET(rang, states, crA, varA, statescandidates, ovars, eqns, oeqns, crJ, varJ, jac)::iAcc, b or b1);
3864+
(stateSets, b, oStatesetrepl) = removeAliasVarsStateSets(stateSets, SOME(repl), vars, aliasVars, BackendDAE.STATESET(index, rang, states, crA, varA, statescandidates, ovars, eqns, oeqns, crJ, varJ, jac)::iAcc, b or b1);
38653865
then
38663866
(stateSets, b, oStatesetrepl);
38673867
end match;

Compiler/BackEnd/SymbolicJacobian.mo

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,7 +2945,7 @@ algorithm
29452945
BackendDAE.StateSet stateSet;
29462946
BackendDAE.Shared shared;
29472947

2948-
Integer rang;
2948+
Integer index, rang;
29492949
list<DAE.ComponentRef> state;
29502950
DAE.ComponentRef crA, crJ;
29512951
list<BackendDAE.Var> varA, varJ, statescandidates, ovars;
@@ -2963,7 +2963,7 @@ algorithm
29632963

29642964
String name;
29652965

2966-
case (BackendDAE.STATESET(rang=rang, state=state, crA=crA, varA=varA, statescandidates=statescandidates,
2966+
case (BackendDAE.STATESET(index=index, rang=rang, state=state, crA=crA, varA=varA, statescandidates=statescandidates,
29672967
ovars=ovars, eqns=eqns, oeqns=oeqns, crJ=crJ, varJ=varJ), _, _, _, _)
29682968
equation
29692969
// get state names
@@ -3002,11 +3002,10 @@ algorithm
30023002

30033003
//generate Jacobian name
30043004
name = "StateSetJac" + intString(System.tmpTickIndex(Global.backendDAE_jacobianSeq));
3005-
30063005
// generate generic Jacobian back end dae
30073006
(jacobian, shared) = getSymbolicJacobian(diffVars, cEqns, resVars, oEqns, oVars, inShared, allvars, name, false);
30083007

3009-
then (BackendDAE.STATESET(rang, state, crA, varA, statescandidates, ovars, eqns, oeqns, crJ, varJ, jacobian), shared);
3008+
then (BackendDAE.STATESET(index, rang, state, crA, varA, statescandidates, ovars, eqns, oeqns, crJ, varJ, jacobian), shared);
30103009
end match;
30113010
end calculateStateSetJacobian;
30123011

0 commit comments

Comments
 (0)