Skip to content

Commit fdfd6ac

Browse files
kabdelhakadrpo
authored andcommitted
[BE] rename incidence to adjacency matrix
- misleading name incidence matrix changed to adjacency matrix - all instances of incidence Incidence and INCIDENCE have been replaced
1 parent 315a2d2 commit fdfd6ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1869
-1873
lines changed

OMCompiler/Compiler/BackEnd/AdjacencyMatrix.mo

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ public function traverseAdjacencyMatrix<T>
6565
output BackendDAE.AdjacencyMatrix outM;
6666
output T outTypeA;
6767
partial function FuncType
68-
input BackendDAE.IncidenceMatrixElement elem;
68+
input BackendDAE.AdjacencyMatrixElement elem;
6969
input Integer pos;
7070
input T inTpl;
7171
output list<Integer> outList;
7272
output T outTpl;
7373
end FuncType;
7474
algorithm
75-
(outM, outTypeA) := traverseIncidenceMatrix1(inM, func, 1, arrayLength(inM), inTypeA);
75+
(outM, outTypeA) := traverseAdjacencyMatrix1(inM, func, 1, arrayLength(inM), inTypeA);
7676
end traverseAdjacencyMatrix;
7777

78-
protected function traverseIncidenceMatrix1<T>
78+
protected function traverseAdjacencyMatrix1<T>
7979
input BackendDAE.AdjacencyMatrix inM;
8080
input FuncType func;
8181
input Integer pos "iterated 1..len";
@@ -84,18 +84,18 @@ protected function traverseIncidenceMatrix1<T>
8484
output BackendDAE.AdjacencyMatrix outM;
8585
output T outTypeA;
8686
partial function FuncType
87-
input BackendDAE.IncidenceMatrixElement elem;
87+
input BackendDAE.AdjacencyMatrixElement elem;
8888
input Integer pos;
8989
input T inTpl;
9090
output list<Integer> outList;
9191
output T outTpl;
9292
end FuncType;
9393
algorithm
94-
(outM, outTypeA) := traverseIncidenceMatrix2(inM, func, pos, len, intGt(pos, len), inTypeA);
94+
(outM, outTypeA) := traverseAdjacencyMatrix2(inM, func, pos, len, intGt(pos, len), inTypeA);
9595
annotation(__OpenModelica_EarlyInline = true);
96-
end traverseIncidenceMatrix1;
96+
end traverseAdjacencyMatrix1;
9797

98-
protected function traverseIncidenceMatrix2<T>
98+
protected function traverseAdjacencyMatrix2<T>
9999
input BackendDAE.AdjacencyMatrix inM;
100100
input FuncType func;
101101
input Integer pos "iterated 1..len";
@@ -105,7 +105,7 @@ protected function traverseIncidenceMatrix2<T>
105105
output BackendDAE.AdjacencyMatrix outM;
106106
output T outTypeA;
107107
partial function FuncType
108-
input BackendDAE.IncidenceMatrixElement elem;
108+
input BackendDAE.AdjacencyMatrixElement elem;
109109
input Integer pos;
110110
input T inTpl;
111111
output list<Integer> outList;
@@ -124,13 +124,13 @@ algorithm
124124
case false equation
125125
(eqns, extArg) = func(inM[pos], pos, inTypeA);
126126
eqns1 = List.removeOnTrue(pos, intLt, eqns);
127-
(m1, extArg1) = traverseIncidenceMatrixList(eqns1, inM, func, arrayLength(inM), pos, extArg);
128-
(m2, extArg2) = traverseIncidenceMatrix2(m1, func, pos+1, len, intGt(pos+1, len), extArg1);
127+
(m1, extArg1) = traverseAdjacencyMatrixList(eqns1, inM, func, arrayLength(inM), pos, extArg);
128+
(m2, extArg2) = traverseAdjacencyMatrix2(m1, func, pos+1, len, intGt(pos+1, len), extArg1);
129129
then (m2, extArg2);
130130
end match;
131-
end traverseIncidenceMatrix2;
131+
end traverseAdjacencyMatrix2;
132132

133-
protected function traverseIncidenceMatrixList<T>
133+
protected function traverseAdjacencyMatrixList<T>
134134
input list<Integer> inLst "elements to traverse";
135135
input BackendDAE.AdjacencyMatrix inM;
136136
input FuncType func;
@@ -140,7 +140,7 @@ protected function traverseIncidenceMatrixList<T>
140140
output BackendDAE.AdjacencyMatrix outM;
141141
output T outTypeA;
142142
partial function FuncType
143-
input BackendDAE.IncidenceMatrixElement elem;
143+
input BackendDAE.AdjacencyMatrixElement elem;
144144
input Integer pos;
145145
input T inTpl;
146146
output list<Integer> outList;
@@ -165,24 +165,24 @@ algorithm
165165
(eqns, extArg) = func(inM[pos], pos, inTypeA);
166166
eqns1 = List.removeOnTrue(maxpos, intLt, eqns);
167167
alleqns = List.unionOnTrueList({rest, eqns1}, intEq);
168-
(m, extArg1) = traverseIncidenceMatrixList(alleqns, inM, func, len, maxpos, extArg);
168+
(m, extArg1) = traverseAdjacencyMatrixList(alleqns, inM, func, len, maxpos, extArg);
169169
then (m, extArg1);
170170

171171
case (pos::rest) equation
172172
// do not leave the list
173173
true = intLt(pos, len+1);
174-
(m, extArg) = traverseIncidenceMatrixList(rest, inM, func, len, maxpos, inTypeA);
174+
(m, extArg) = traverseAdjacencyMatrixList(rest, inM, func, len, maxpos, inTypeA);
175175
then (m, extArg);
176176

177177
else equation
178178
true = Flags.isSet(Flags.FAILTRACE);
179-
Debug.trace("- BackendDAEOptimize.traverseIncidenceMatrixList failed\n");
179+
Debug.trace("- BackendDAEOptimize.traverseAdjacencyMatrixList failed\n");
180180
then fail();
181181
end matchcontinue;
182-
end traverseIncidenceMatrixList;
182+
end traverseAdjacencyMatrixList;
183183

184184
public function getOtherEqSysAdjacencyMatrix
185-
"This function removes tvar and res from incidence matrix."
185+
"This function removes tvar and res from adjacency matrix."
186186
input BackendDAE.AdjacencyMatrix m;
187187
input Integer size;
188188
input Integer index;
@@ -219,7 +219,7 @@ algorithm
219219
end isAssigned;
220220

221221
public function transposeAdjacencyMatrix
222-
"Calculates the transpose of the incidence matrix,
222+
"Calculates the transpose of the adjacency matrix,
223223
i.e. which equations each variable is present in."
224224
input BackendDAE.AdjacencyMatrix m;
225225
input Integer nRowsMt;
@@ -263,7 +263,7 @@ algorithm
263263
end transposeRow;
264264

265265
public function absAdjacencyMatrix "author: PA
266-
Applies absolute value to all entries in the incidence matrix.
266+
Applies absolute value to all entries in the adjacency matrix.
267267
This can be used when e.g. der(x) and x are considered the same variable."
268268
input BackendDAE.AdjacencyMatrix m;
269269
output BackendDAE.AdjacencyMatrix res;

OMCompiler/Compiler/BackEnd/BackendDAE.mo

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -674,17 +674,13 @@ end TimeEvent;
674674
// AdjacencyMatrixes
675675
//
676676
public
677-
type IncidenceMatrixElementEntry = Integer;
678-
type IncidenceMatrixElement = list<IncidenceMatrixElementEntry>;
679-
type IncidenceMatrix = array<IncidenceMatrixElement> "array<list<Integer>>";
680-
type IncidenceMatrixT = IncidenceMatrix
677+
type AdjacencyMatrixElementEntry = Integer;
678+
type AdjacencyMatrixElement = list<AdjacencyMatrixElementEntry>;
679+
type AdjacencyMatrix = array<AdjacencyMatrixElement> "array<list<Integer>>";
680+
type AdjacencyMatrixT = AdjacencyMatrix
681681
"a list of equation indices (1..n), one for each variable. Equations that -only-
682682
contain the state variable and not the derivative have a negative index.";
683683

684-
public
685-
type AdjacencyMatrix = IncidenceMatrix;
686-
type AdjacencyMatrixT = IncidenceMatrixT;
687-
688684
type AdjacencyMatrixMapping = tuple<array<list<Integer>>, array<Integer>, IndexType, Boolean, Boolean>
689685
"a mapping for adjacency matrices that contains:
690686
array<list<Integer>>: array index -> scalar index list
@@ -724,12 +720,12 @@ type Constraints = list<.DAE.Constraint> "Constraints on the solvability of the
724720

725721
public
726722
uniontype IndexType
727-
record ABSOLUTE "incidence matrix with absolute indexes" end ABSOLUTE;
728-
record NORMAL "incidence matrix with positive/negative indexes" end NORMAL;
729-
record SOLVABLE "incidence matrix with only solvable entries, for example {a,b,c}[d] then d is skipped" end SOLVABLE;
730-
record BASECLOCK_IDX "incidence matrix for base-clock partitioning" end BASECLOCK_IDX;
731-
record SUBCLOCK_IDX "incidence matrix for sub-clock partitioning" end SUBCLOCK_IDX;
732-
record SPARSE "incidence matrix as normal, but add for inputs also a value" end SPARSE;
723+
record ABSOLUTE "adjacency matrix with absolute indexes" end ABSOLUTE;
724+
record NORMAL "adjacency matrix with positive/negative indexes" end NORMAL;
725+
record SOLVABLE "adjacency matrix with only solvable entries, for example {a,b,c}[d] then d is skipped" end SOLVABLE;
726+
record BASECLOCK_IDX "adjacency matrix for base-clock partitioning" end BASECLOCK_IDX;
727+
record SUBCLOCK_IDX "adjacency matrix for sub-clock partitioning" end SUBCLOCK_IDX;
728+
record SPARSE "adjacency matrix as normal, but add for inputs also a value" end SPARSE;
733729
end IndexType;
734730

735731
//

OMCompiler/Compiler/BackEnd/BackendDAECreate.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ algorithm
173173
NONE()
174174
));
175175
BackendDAEUtil.checkBackendDAEWithErrorMsg(outBackendDAE);
176-
BackendDAEUtil.checkIncidenceMatrixSolvability(syst, functionTree,BackendDAEUtil.isInitializationDAE(outBackendDAE.shared));
176+
BackendDAEUtil.checkAdjacencyMatrixSolvability(syst, functionTree,BackendDAEUtil.isInitializationDAE(outBackendDAE.shared));
177177
if Flags.isSet(Flags.DUMP_BACKENDDAE_INFO) then
178178
Error.addSourceMessage(Error.BACKENDDAEINFO_LOWER,{String(BackendEquation.equationArraySize(syst.orderedEqs)), String(BackendVariable.varsSize(syst.orderedVars))},AbsynUtil.dummyInfo);
179179
end if;

OMCompiler/Compiler/BackEnd/BackendDAEEXT.mo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ end getF;
204204
see: http://bmi.osu.edu/~kamer/index.html
205205
*****************************************/
206206

207-
public function setIncidenceMatrix "author: Frenkel TUD 2012-04"
207+
public function setAdjacencyMatrix "author: Frenkel TUD 2012-04"
208208
input Integer nv;
209209
input Integer ne;
210210
input Integer nz;
211211
input array<list<Integer>> m;
212212

213-
external "C" BackendDAEEXT_setIncidenceMatrix(nv,ne,nz,m) annotation(Library = "omcruntime");
214-
end setIncidenceMatrix;
213+
external "C" BackendDAEEXT_setAdjacencyMatrix(nv,ne,nz,m) annotation(Library = "omcruntime");
214+
end setAdjacencyMatrix;
215215

216216
/* TODO: Implement an external C function for bootstrapped omc or remove me. DO NOT SIMPLY REMOVE THIS COMMENT
217217
public function cheapmatching

0 commit comments

Comments
 (0)