Fix: Costs between components did not get added, Added test case to confirm

parent b6cebda6
Pipeline #104730 failed with stages
in 23 minutes and 28 seconds
......@@ -35,8 +35,8 @@ public class AutomaticClusteringHelper {
int index1 = subcompLabels.get(sourceCompOpt.getFullName());
int index2 = subcompLabels.get(targetCompOpt.getFullName());
res[index1][index2] = getTypeCostHeuristic(con.getSourcePort());
res[index2][index1] = getTypeCostHeuristic(con.getSourcePort());
res[index1][index2] += getTypeCostHeuristic(con.getSourcePort());
res[index2][index1] += getTypeCostHeuristic(con.getSourcePort());
});
......
......@@ -96,6 +96,31 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
}
}
@Test
public void testAdjacencyMatrixCreation2(){
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("lab.adjMatrixComp", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
List<EMAComponentInstanceSymbol> subcompsOrderedByName = ComponentHelper.getSubcompsOrderedByName(componentInstanceSymbol);
double[][] matrix = AutomaticClusteringHelper.createAdjacencyMatrix(subcompsOrderedByName,
ComponentHelper.getInnerConnectors(componentInstanceSymbol),
ComponentHelper.getLabelsForSubcomps(subcompsOrderedByName));
//sorted full name: sub1, sub2, sub3
double[][] expRes = {{0,10,20} //sub1
,{10,0,0} //sub2
,{20,0,0}}; //sub3
for(int i = 0; i< expRes.length; i++){
for(int j = 0; j < expRes[i].length;j++){
assertTrue(expRes[i][j] == matrix[i][j]);
}
}
}
@Test
public void testSpectralClustering(){
......
package lab;
component AdjMatrixComp{
component Sub1{
ports out Q qOut1,
out Q qOut2,
out Q qOut3;
}
component Sub2{
ports in Q qIn;
}
component Sub3{
ports in Q qIn1,
in Q qIn2;
}
instance Sub1 sub1;
instance Sub2 sub2;
instance Sub3 sub3;
connect sub1.qOut1 -> sub2.qIn;
connect sub1.qOut2 -> sub3.qIn1;
connect sub1.qOut3 -> sub3.qIn2;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment