Add testcase for heuristic

parent c7b0d536
......@@ -2,7 +2,10 @@ package de.monticore.lang.monticar.generator.middleware.clustering;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ConnectorSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosConnectionSymbol;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.lang.monticar.ts.references.MCTypeReference;
import de.se_rwth.commons.logging.Log;
import java.util.*;
......@@ -62,4 +65,17 @@ public class AutomaticClusteringHelper {
});
}
public static double getTypeCostHeuristic(PortSymbol port){
return getTypeCostHeuristic(port.getTypeReference());
}
public static double getTypeCostHeuristic(MCTypeReference<? extends MCTypeSymbol> typeReference) {
//TODO: implement
//TODO: base types (Q,Z,B,C)
//TODO: Matrix types(recursive?)
//TODO: structs
return 0;
}
}
......@@ -15,10 +15,7 @@ import org.junit.Test;
import smile.clustering.SpectralClustering;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
......@@ -190,4 +187,35 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
distributedTargetGenerator.generate(componentInstanceSymbol,taggingResolver);
}
@Test
public void testCostHeuristic(){
TaggingResolver taggingResolver = AbstractSymtabTest.createSymTabAndTaggingResolver(TEST_PATH);
//CostHeuristic
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("test.costHeuristic", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
double inC = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inC").get());
double inQ = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inQ").get());
double inZ = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inZ").get());
double inB = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inB").get());
assertTrue(inC > inQ);
assertTrue(inQ > inZ);
assertTrue(inZ > inB);
double inQVec = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inQVec").get());
double inQVec2 = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inQVec2").get());
double inQMat = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inQMat").get());
double inQMat2 = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inQMat2").get());
assertTrue(inQVec2 > inQVec);
assertTrue(inQMat2 > inQMat);
double inPos = AutomaticClusteringHelper.getTypeCostHeuristic(componentInstanceSymbol.getPort("inPos").get());
}
}
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