-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6086577
commit cf960b2
Showing
29 changed files
with
223 additions
and
33 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
**Matching Algorithm test models** | ||
|
||
This folder contains four test Modelica models, where the program constructs the corresponding SB-Graph, and then applies the matching algorithm for SB-Graphs implemented [here](https://github.com/CIFASIS/sb-graph/blob/739ba2969552fa3373137df29dcb045c397e3e93/sbg/sbg_algorithms.cpp#L671). It also contains the expected results for each of them. | ||
|
||
The models are the following: | ||
|
||
* A simple model with small algebraic loops disconnected from each other `Test1.mo` -> Expected results `results1.txt` | ||
* A model with connections between different indices `Test2.mo` -> Expected results `results2.txt` | ||
* Similar to Test2, but with border conditions changed `Test3.mo` -> Expected results `results3.txt` | ||
* Two copies of Test3 `Test4.mo` -> Expected results `results4.txt` | ||
|
||
In order to run the matching algorithm the following steps must be taken: | ||
|
||
* Install the ModelicaCC compiler as described [here](https://github.com/CIFASIS/modelicacc#installation) | ||
* From the ModelicaCC root folder run: `./bin/causalize ./test/mccprograms/matching/{TEST_MODEL} > {OUTPUT_MODEL}` where `{TEST_MODEL}` is one of the models defined above and `{OUTPUT_MODEL}` is the result output Modelica model. | ||
|
||
**Note:** | ||
The execution will generate a SBG.log file located in the same folder where the command is called, this file contains detailed information about the different steps taken by the matching algorithm | ||
and also information about the generated graph used by the algorithm. Additionally, a dot file with the definition of the graph is created, to generate a pdf file from the dot file, run: | ||
|
||
`dot -Grankdir=LR -Tpdf <PATH_TO_DOT_FILE>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
model Test1 | ||
constant Integer N = 100; | ||
Real a[N], b[N], x[N]; | ||
equation | ||
for i in 1:N loop | ||
a[i] = 2 * x[i] - b[i]; | ||
a[i] = 2 * b[i] - x[i]; | ||
der(x[i]) = 1 - a[i]; | ||
end for; | ||
end Test1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
model Test2 | ||
//Model with possibly wrong initial matching | ||
constant Integer N = 100; | ||
Real a[N], x[N], b[N]; | ||
equation | ||
for i in 2:N-1 loop | ||
der(x[i]) = a[i] - x[i]; | ||
a[i + 1] = a[i] + b[i]; | ||
b[i] = x[i - 1]; | ||
end for; | ||
b[1] = 0; | ||
b[N] = x[N - 1]; | ||
der(x[1]) = a[1] - x[1]; | ||
der(x[N]) = a[N] - x[N]; | ||
a[2] = a[1] + b[1]; | ||
a[N] = 1; | ||
end Test2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
model Test3 | ||
constant Integer N = 100; | ||
Real a[N], x[N], b[N]; | ||
equation | ||
for i in 2:N-1 loop | ||
der(x[i]) = a[i] - x[i]; | ||
a[i + 1] = a[i] + b[i]; | ||
b[i] = x[i - 1]; | ||
end for; | ||
b[1] = 0; | ||
b[N] = x[N - 1]; | ||
der(x[1]) = a[1] - x[1]; | ||
der(x[N]) = a[N] - x[N]; | ||
a[1] = 1; | ||
a[N] = a[N - 1] + b[N - 1]; | ||
end Test3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
model Test4 | ||
constant Integer N = 100000; | ||
Real a1[N], x1[N], b1[N]; | ||
Real a2[N], x2[N], b2[N]; | ||
/* | ||
Real a3[N], x3[N], b3[N]; | ||
Real a4[N], x4[N], b4[N]; | ||
Real a5[N], x5[N], b5[N]; | ||
Real a6[N], x6[N], b6[N]; | ||
Real a7[N], x7[N], b7[N]; | ||
Real a8[N], x8[N], b8[N]; | ||
*/ | ||
equation | ||
for i in 2:N-1 loop | ||
der(x1[i]) = a1[i] - x1[i]; | ||
a1[i + 1] = a1[i] + b1[i]; | ||
b1[i] = x1[i - 1]; | ||
end for; | ||
b1[1] = 0; | ||
b1[N] = x1[N - 1]; | ||
der(x1[1]) = a1[1] - x1[1]; | ||
der(x1[N]) = a1[N] - x1[N]; | ||
a1[1] = 1; | ||
a1[N] = a1[N - 1] + b1[N - 1]; | ||
|
||
for i in 2:N-1 loop | ||
der(x2[i]) = a2[i] - x2[i]; | ||
a2[i + 1] = a2[i] + b2[i]; | ||
b2[i] = x2[i - 1]; | ||
end for; | ||
b2[1] = 0; | ||
b2[N] = x2[N - 1]; | ||
der(x2[1]) = a2[1] - x2[1]; | ||
der(x2[N]) = a2[N] - x2[N]; | ||
a2[1] = 1; | ||
a2[N] = a2[N - 1] + b2[N - 1]; | ||
/* | ||
for i in 2:N-1 loop | ||
der(x3[i]) = a3[i] - x3[i]; | ||
a3[i + 1] = a3[i] + b3[i]; | ||
b3[i] = x3[i - 1]; | ||
end for; | ||
b3[1] = 0; | ||
b3[N] = x3[N - 1]; | ||
der(x3[1]) = a3[1] - x3[1]; | ||
der(x3[N]) = a3[N] - x3[N]; | ||
a3[1] = 1; | ||
a3[N] = a3[N - 1] + b3[N - 1]; | ||
for i in 2:N-1 loop | ||
der(x4[i]) = a4[i] - x4[i]; | ||
a4[i + 1] = a4[i] + b4[i]; | ||
b4[i] = x4[i - 1]; | ||
end for; | ||
b4[1] = 0; | ||
b4[N] = x4[N - 1]; | ||
der(x4[1]) = a4[1] - x4[1]; | ||
der(x4[N]) = a4[N] - x4[N]; | ||
a4[1] = 1; | ||
a4[N] = a4[N - 1] + b4[N - 1]; | ||
for i in 2:N-1 loop | ||
der(x5[i]) = a5[i] - x5[i]; | ||
a5[i + 1] = a5[i] + b5[i]; | ||
b5[i] = x5[i - 1]; | ||
end for; | ||
b5[1] = 0; | ||
b5[N] = x5[N - 1]; | ||
der(x5[1]) = a5[1] - x5[1]; | ||
der(x5[N]) = a5[N] - x5[N]; | ||
a5[1] = 1; | ||
a5[N] = a5[N - 1] + b5[N - 1]; | ||
for i in 2:N-1 loop | ||
der(x6[i]) = a6[i] - x6[i]; | ||
a6[i + 1] = a6[i] + b6[i]; | ||
b6[i] = x6[i - 1]; | ||
end for; | ||
b6[1] = 0; | ||
b6[N] = x6[N - 1]; | ||
der(x6[1]) = a6[1] - x6[1]; | ||
der(x6[N]) = a6[N] - x6[N]; | ||
a6[1] = 1; | ||
a6[N] = a6[N - 1] + b6[N - 1]; | ||
for i in 2:N-1 loop | ||
der(x7[i]) = a7[i] - x7[i]; | ||
a7[i + 1] = a7[i] + b7[i]; | ||
b7[i] = x7[i - 1]; | ||
end for; | ||
b7[1] = 0; | ||
b7[N] = x7[N - 1]; | ||
der(x7[1]) = a7[1] - x7[1]; | ||
der(x7[N]) = a7[N] - x7[N]; | ||
a7[1] = 1; | ||
a7[N] = a7[N - 1] + b7[N - 1]; | ||
for i in 2:N-1 loop | ||
der(x8[i]) = a8[i] - x8[i]; | ||
a8[i + 1] = a8[i] + b8[i]; | ||
b8[i] = x8[i - 1]; | ||
end for; | ||
b8[1] = 0; | ||
b8[N] = x8[N - 1]; | ||
der(x8[1]) = a8[1] - x8[1]; | ||
der(x8[N]) = a8[N] - x8[N]; | ||
a8[1] = 1; | ||
a8[N] = a8[N - 1] + b8[N - 1]; | ||
*/ | ||
end Test4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Generated matching: | ||
{[1:1:100], [301:1:400], [501:1:600]} | ||
|
||
>>> Matched all unknowns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Generated matching: | ||
{[295:1:391], [99:1:195], [491:1:587], [590:1:590], [595:1:595], [588:1:588], [598:1:598], [392:1:392], [196:1:196], [592:1:592], [589:1:589], [594:1:594]} | ||
|
||
>>> Matched all unknowns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Generated matching: | ||
{[100:1:195], [297:1:387], [491:1:586], [594:1:594], [589:1:589], [598:1:598], [592:1:592], [196:1:196], [389:1:389], [390:1:390], [296:1:296], [295:1:295], [99:1:99], [388:1:388], [391:1:391], [587:1:587], [588:1:588], [595:1:595], [294:1:294], [590:1:590]} | ||
|
||
>>> Matched all unknowns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Generated matching: | ||
{[1199992:1:1199992], [1199987:1:1199987], [599994:1:599994], [599989:1:599989], [1199993:1:1199993], [1199986:1:1199986], [599992:1:599992], [1199996:1:1199996], [899993:1:899993], [899995:1:899995], [599987:1:599987], [499991:1:499991], [199996:1:199996], [99999:1:99999], [599998:1:599998], [100000:1:100000], [299997:1:299997], [299996:1:299996], [299995:1:299995], [699997:1:699997], [899994:1:899994], [599988:1:599988], [599995:1:599995], [1199990:1:1199990], [299994:1:299994], [599990:1:599990], [899992:1:899992], [1199988:1:1199988], [499992:1:599986], [100001:1:199995], [899996:1:999989], [299998:1:399991], [1099989:1:1199985], [699998:1:799994]} | ||
|
||
>>> Matched all unknowns |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.