Fix typo: clustring -> clustering

parent 685288af
...@@ -12,7 +12,7 @@ o Order all sub components by name (neccessary for the adjacency matrix). ...@@ -12,7 +12,7 @@ o Order all sub components by name (neccessary for the adjacency matrix).
o Create adjacency matrix to use with a clustering algorithm, with subcomponents as nodes and connectors between subcomponents as vertices. Sift out all connectors to the super component. o Create adjacency matrix to use with a clustering algorithm, with subcomponents as nodes and connectors between subcomponents as vertices. Sift out all connectors to the super component.
2) Feed adjacency matrix into the selected clustering algorithm 2) Feed adjacency matrix into the selected clustering algorithm
o We are using the machine learning library "smile ml" (see: https://github.com/haifengl/smile) which provides a broad range of different clustering and partitioning approaches. As a prime example we are using "spectral clustering" here. For a closer look at this approach, see the section below. o We are using the machine learning library "smile ml" (see: https://github.com/haifengl/smile) which provides a broad range of different clustering and partitioning approaches. As a prime example we are using "spectral clustering" here. For a closer look at this approach, see the section below.
o The clustring algorithm yields multiple cluster labels with the clustered entries of the adjacency matrix assigned to them. We have to convert them back to a set of symbol tables of components representing the clusters. o The clustering algorithm yields multiple cluster labels with the clustered entries of the adjacency matrix assigned to them. We have to convert them back to a set of symbol tables of components representing the clusters.
3) Generate middleware tags separating the clusters 3) Generate middleware tags separating the clusters
o This will build the cluster-to-ROS connections. o This will build the cluster-to-ROS connections.
o We won’t take account of ports of the super component and only consider connected top level components. o We won’t take account of ports of the super component and only consider connected top level components.
......
...@@ -2,6 +2,7 @@ package de.monticore.lang.monticar.generator.middleware; ...@@ -2,6 +2,7 @@ package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.cli.ClusteringParameters;
import de.monticore.lang.monticar.generator.middleware.clustering.ClusterFromTagsHelper; import de.monticore.lang.monticar.generator.middleware.clustering.ClusterFromTagsHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.*; import de.monticore.lang.monticar.generator.middleware.helpers.*;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl; import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
...@@ -26,6 +27,7 @@ public class DistributedTargetGenerator extends CMakeGenerator { ...@@ -26,6 +27,7 @@ public class DistributedTargetGenerator extends CMakeGenerator {
private Set<String> subDirs = new HashSet<>(); private Set<String> subDirs = new HashSet<>();
private ClusteringParameters clusteringParameters;
public DistributedTargetGenerator() { public DistributedTargetGenerator() {
} }
......
...@@ -13,19 +13,19 @@ public class CliParameters { ...@@ -13,19 +13,19 @@ public class CliParameters {
private Set<String> generators; private Set<String> generators;
private String emadlBackend; private String emadlBackend;
private Boolean writeTagFile; private Boolean writeTagFile;
private ClustringParameters clustringParameters; private ClusteringParameters clusteringParameters;
public CliParameters() { public CliParameters() {
} }
public CliParameters(String modelsDir, String outputDir, String rootModel, Set<String> generators, String emadlBackend, Boolean writeTagFile, ClustringParameters clustringParameters) { public CliParameters(String modelsDir, String outputDir, String rootModel, Set<String> generators, String emadlBackend, Boolean writeTagFile, ClusteringParameters clusteringParameters) {
this.modelsDir = modelsDir; this.modelsDir = modelsDir;
this.outputDir = outputDir; this.outputDir = outputDir;
this.rootModel = rootModel; this.rootModel = rootModel;
this.generators = generators; this.generators = generators;
this.emadlBackend = emadlBackend; this.emadlBackend = emadlBackend;
this.writeTagFile = writeTagFile; this.writeTagFile = writeTagFile;
this.clustringParameters = clustringParameters; this.clusteringParameters = clusteringParameters;
} }
public String getModelsDir() { public String getModelsDir() {
...@@ -52,8 +52,8 @@ public class CliParameters { ...@@ -52,8 +52,8 @@ public class CliParameters {
return writeTagFile == null ? DEFAULT_WRITE_TAG_FILE : writeTagFile; return writeTagFile == null ? DEFAULT_WRITE_TAG_FILE : writeTagFile;
} }
public Optional<ClustringParameters> getClustringParameters() { public Optional<ClusteringParameters> getClusteringParameters() {
return Optional.ofNullable(clustringParameters); return Optional.ofNullable(clusteringParameters);
} }
} }
...@@ -6,12 +6,12 @@ import java.util.ArrayList; ...@@ -6,12 +6,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
public class ClustringParameters { public class ClusteringParameters {
private Integer numberOfClusters; private Integer numberOfClusters;
private ResultChoosingStrategy chooseBy = ResultChoosingStrategy.bestWithFittingN; private ResultChoosingStrategy chooseBy = ResultChoosingStrategy.bestWithFittingN;
private List<AlgorithmCliParameters> algorithmParameters = new ArrayList<>(); private List<AlgorithmCliParameters> algorithmParameters = new ArrayList<>();
public ClustringParameters() { public ClusteringParameters() {
} }
public Optional<Integer> getNumberOfClusters() { public Optional<Integer> getNumberOfClusters() {
......
...@@ -12,7 +12,7 @@ public class AffinityPropagationCliParameters extends AlgorithmCliParameters{ ...@@ -12,7 +12,7 @@ public class AffinityPropagationCliParameters extends AlgorithmCliParameters{
} }
@Override @Override
public ClusteringAlgorithm asClustringAlgorithm() { public ClusteringAlgorithm asClusteringAlgorithm() {
return new AffinityPropagationAlgorithm(); return new AffinityPropagationAlgorithm();
} }
......
...@@ -18,7 +18,7 @@ public abstract class AlgorithmCliParameters { ...@@ -18,7 +18,7 @@ public abstract class AlgorithmCliParameters {
return name; return name;
} }
public abstract ClusteringAlgorithm asClustringAlgorithm(); public abstract ClusteringAlgorithm asClusteringAlgorithm();
public abstract List<Object> asAlgorithmArgs(); public abstract List<Object> asAlgorithmArgs();
......
...@@ -23,7 +23,7 @@ public class DBScanCliParameters extends AlgorithmCliParameters { ...@@ -23,7 +23,7 @@ public class DBScanCliParameters extends AlgorithmCliParameters {
} }
@Override @Override
public ClusteringAlgorithm asClustringAlgorithm() { public ClusteringAlgorithm asClusteringAlgorithm() {
DBSCANClusteringAlgorithm dbscanClusteringAlgorithm = new DBSCANClusteringAlgorithm(); DBSCANClusteringAlgorithm dbscanClusteringAlgorithm = new DBSCANClusteringAlgorithm();
dbscanClusteringAlgorithm.setArgs(asAlgorithmArgs()); dbscanClusteringAlgorithm.setArgs(asAlgorithmArgs());
return dbscanClusteringAlgorithm; return dbscanClusteringAlgorithm;
......
...@@ -23,7 +23,7 @@ public class MarkovCliParameters extends AlgorithmCliParameters { ...@@ -23,7 +23,7 @@ public class MarkovCliParameters extends AlgorithmCliParameters {
} }
@Override @Override
public ClusteringAlgorithm asClustringAlgorithm() { public ClusteringAlgorithm asClusteringAlgorithm() {
MarkovClusteringAlgorithm markovClusteringAlgorithm = new MarkovClusteringAlgorithm(); MarkovClusteringAlgorithm markovClusteringAlgorithm = new MarkovClusteringAlgorithm();
markovClusteringAlgorithm.setArgs(asAlgorithmArgs()); markovClusteringAlgorithm.setArgs(asAlgorithmArgs());
return markovClusteringAlgorithm; return markovClusteringAlgorithm;
......
...@@ -23,7 +23,7 @@ public class SpectralClusteringCliParameters extends AlgorithmCliParameters { ...@@ -23,7 +23,7 @@ public class SpectralClusteringCliParameters extends AlgorithmCliParameters {
} }
@Override @Override
public ClusteringAlgorithm asClustringAlgorithm() { public ClusteringAlgorithm asClusteringAlgorithm() {
SpectralClusteringAlgorithm clusteringAlgorithm = new SpectralClusteringAlgorithm(); SpectralClusteringAlgorithm clusteringAlgorithm = new SpectralClusteringAlgorithm();
clusteringAlgorithm.setArgs(asAlgorithmArgs()); clusteringAlgorithm.setArgs(asAlgorithmArgs());
return clusteringAlgorithm; return clusteringAlgorithm;
......
...@@ -15,7 +15,7 @@ public class UnknownAlgorithmCliParameters extends AlgorithmCliParameters { ...@@ -15,7 +15,7 @@ public class UnknownAlgorithmCliParameters extends AlgorithmCliParameters {
} }
@Override @Override
public ClusteringAlgorithm asClustringAlgorithm() { public ClusteringAlgorithm asClusteringAlgorithm() {
return null; return null;
} }
......
...@@ -2,7 +2,7 @@ package de.monticore.lang.monticar.generator.middleware; ...@@ -2,7 +2,7 @@ package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.monticar.generator.middleware.cli.CliParametersLoader; import de.monticore.lang.monticar.generator.middleware.cli.CliParametersLoader;
import de.monticore.lang.monticar.generator.middleware.cli.CliParameters; import de.monticore.lang.monticar.generator.middleware.cli.CliParameters;
import de.monticore.lang.monticar.generator.middleware.cli.ClustringParameters; import de.monticore.lang.monticar.generator.middleware.cli.ClusteringParameters;
import de.monticore.lang.monticar.generator.middleware.cli.ResultChoosingStrategy; import de.monticore.lang.monticar.generator.middleware.cli.ResultChoosingStrategy;
import de.monticore.lang.monticar.generator.middleware.cli.algorithms.*; import de.monticore.lang.monticar.generator.middleware.cli.algorithms.*;
import org.junit.Test; import org.junit.Test;
...@@ -27,27 +27,27 @@ public class ParameterLoadingTest { ...@@ -27,27 +27,27 @@ public class ParameterLoadingTest {
@Test @Test
public void testClusterParamsDefaultValues() throws FileNotFoundException { public void testClusterParamsDefaultValues() throws FileNotFoundException {
CliParameters params = loadCliParameters("clusterParamsDefaultValues"); CliParameters params = loadCliParameters("clusterParamsDefaultValues");
ClustringParameters clustringParameters = params.getClustringParameters().get(); ClusteringParameters clusteringParameters = params.getClusteringParameters().get();
assertFalse(clustringParameters.getNumberOfClusters().isPresent()); assertFalse(clusteringParameters.getNumberOfClusters().isPresent());
assertEquals(ResultChoosingStrategy.bestWithFittingN, clustringParameters.getChooseBy()); assertEquals(ResultChoosingStrategy.bestWithFittingN, clusteringParameters.getChooseBy());
assertTrue(clustringParameters.getAlgorithmParameters().isEmpty()); assertTrue(clusteringParameters.getAlgorithmParameters().isEmpty());
} }
@Test @Test
public void testClusterParamsNoAlgo() throws FileNotFoundException { public void testClusterParamsNoAlgo() throws FileNotFoundException {
CliParameters params = loadCliParameters("clusterParamsNoAlgo"); CliParameters params = loadCliParameters("clusterParamsNoAlgo");
ClustringParameters clustringParameters = params.getClustringParameters().get(); ClusteringParameters clusteringParameters = params.getClusteringParameters().get();
assertEquals(3, (long) clustringParameters.getNumberOfClusters().get()); assertEquals(3, (long) clusteringParameters.getNumberOfClusters().get());
assertEquals(ResultChoosingStrategy.bestOverall, clustringParameters.getChooseBy()); assertEquals(ResultChoosingStrategy.bestOverall, clusteringParameters.getChooseBy());
assertTrue(clustringParameters.getAlgorithmParameters().isEmpty()); assertTrue(clusteringParameters.getAlgorithmParameters().isEmpty());
} }
@Test @Test
public void testClusterParamsAllAlgos() throws FileNotFoundException { public void testClusterParamsAllAlgos() throws FileNotFoundException {
CliParameters params = loadCliParameters("clusterParamsAllAlgos"); CliParameters params = loadCliParameters("clusterParamsAllAlgos");
ClustringParameters clustringParameters = params.getClustringParameters().get(); ClusteringParameters clusteringParameters = params.getClusteringParameters().get();
List<AlgorithmCliParameters> algorithmParameters = clustringParameters.getAlgorithmParameters(); List<AlgorithmCliParameters> algorithmParameters = clusteringParameters.getAlgorithmParameters();
assertEquals(4, algorithmParameters.size()); assertEquals(4, algorithmParameters.size());
Map<String, AlgorithmCliParameters> nameToParams = new HashMap<>(); Map<String, AlgorithmCliParameters> nameToParams = new HashMap<>();
...@@ -88,9 +88,9 @@ public class ParameterLoadingTest { ...@@ -88,9 +88,9 @@ public class ParameterLoadingTest {
@Test @Test
public void testClusterParamsInvalidAlgos() throws FileNotFoundException { public void testClusterParamsInvalidAlgos() throws FileNotFoundException {
CliParameters params = loadCliParameters("clusterParamsInvalidAlgos"); CliParameters params = loadCliParameters("clusterParamsInvalidAlgos");
ClustringParameters clustringParameters = params.getClustringParameters().get(); ClusteringParameters clusteringParameters = params.getClusteringParameters().get();
List<AlgorithmCliParameters> algorithmParameters = clustringParameters.getAlgorithmParameters(); List<AlgorithmCliParameters> algorithmParameters = clusteringParameters.getAlgorithmParameters();
assertEquals(2, algorithmParameters.size()); assertEquals(2, algorithmParameters.size());
assertTrue(algorithmParameters.get(0) instanceof UnknownAlgorithmCliParameters); assertTrue(algorithmParameters.get(0) instanceof UnknownAlgorithmCliParameters);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"outputDir": "target/cliTest/validConfigFile", "outputDir": "target/cliTest/validConfigFile",
"rootModel": "tests.a.addComp", "rootModel": "tests.a.addComp",
"generators": ["cpp","roscpp"], "generators": ["cpp","roscpp"],
"clustringParameters":{ "clusteringParameters":{
"algorithmParameters":[ "algorithmParameters":[
{ {
"name":"SpectralClustering", "name":"SpectralClustering",
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
"outputDir": "target/cliTest/validConfigFile", "outputDir": "target/cliTest/validConfigFile",
"rootModel": "tests.a.addComp", "rootModel": "tests.a.addComp",
"generators": ["cpp","roscpp"], "generators": ["cpp","roscpp"],
"clustringParameters":{ "clusteringParameters":{
} }
} }
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"outputDir": "target/cliTest/validConfigFile", "outputDir": "target/cliTest/validConfigFile",
"rootModel": "tests.a.addComp", "rootModel": "tests.a.addComp",
"generators": ["cpp","roscpp"], "generators": ["cpp","roscpp"],
"clustringParameters":{ "clusteringParameters":{
"algorithmParameters":[ "algorithmParameters":[
{ {
"name":"Invalid" "name":"Invalid"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"outputDir": "target/cliTest/validConfigFile", "outputDir": "target/cliTest/validConfigFile",
"rootModel": "tests.a.addComp", "rootModel": "tests.a.addComp",
"generators": ["cpp","roscpp"], "generators": ["cpp","roscpp"],
"clustringParameters":{ "clusteringParameters":{
"numberOfClusters":3, "numberOfClusters":3,
"chooseBy":"bestOverall" "chooseBy":"bestOverall"
} }
......
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