Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Middleware
Commits
b165a3be
Commit
b165a3be
authored
Mar 12, 2019
by
Alexander David Hellwig
Browse files
Clean up tests: add seed AffinityPropagation tests, Ignore JsonCliTest(no assertions)
parent
6def08a0
Pipeline
#111058
passed with stages
in 16 minutes and 33 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/middleware/clustering/algorithms/AffinityPropagationAlgorithm.java
View file @
b165a3be
...
...
@@ -8,10 +8,7 @@ import de.monticore.lang.monticar.generator.middleware.clustering.ClusteringInpu
import
org.apache.commons.math3.linear.Array2DRowRealMatrix
;
import
org.apache.commons.math3.linear.RealMatrix
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.*
;
public
class
AffinityPropagationAlgorithm
implements
ClusteringAlgorithm
{
...
...
@@ -31,7 +28,13 @@ public class AffinityPropagationAlgorithm implements ClusteringAlgorithm {
RealMatrix
mat
=
new
Array2DRowRealMatrix
(
clusteringInput
.
getAdjacencyMatrix
());
AffinityPropagation
clustering
=
new
AffinityPropagationParameters
().
fitNewModel
(
mat
);
AffinityPropagation
clustering
;
if
(
args
.
length
==
2
&&
args
[
0
]
==
AffinityPropagationBuilder
.
AffinityPropagationParameters
.
SEED
){
clustering
=
new
AffinityPropagationParameters
().
setSeed
(
new
Random
((
Long
)
args
[
1
])).
fitNewModel
(
mat
);
}
else
{
clustering
=
new
AffinityPropagationParameters
().
fitNewModel
(
mat
);
}
final
int
[]
labels
=
clustering
.
getLabels
();
...
...
src/main/java/de/monticore/lang/monticar/generator/middleware/clustering/algorithms/AffinityPropagationBuilder.java
0 → 100644
View file @
b165a3be
package
de.monticore.lang.monticar.generator.middleware.clustering.algorithms
;
import
smile.clustering.DBSCAN
;
public
class
AffinityPropagationBuilder
{
private
Long
seed
;
// parameter list, true if mandatory
public
enum
AffinityPropagationParameters
{
SEED
(
false
);
private
Boolean
mandatory
;
AffinityPropagationParameters
(
Boolean
mandatory
)
{
this
.
mandatory
=
mandatory
;
}
public
Boolean
isMandatory
()
{
return
this
.
mandatory
;
}
}
public
AffinityPropagationBuilder
()
{
}
public
AffinityPropagationBuilder
(
long
seed
)
{
this
.
seed
=
seed
;
}
public
void
setSeed
(
long
seed
)
{
this
.
seed
=
seed
;
}
public
AffinityPropagationAlgorithm
build
()
{
AffinityPropagationAlgorithm
affinityPropagationAlgorithm
=
new
AffinityPropagationAlgorithm
();
if
(
seed
==
null
){
return
affinityPropagationAlgorithm
;
}
else
{
affinityPropagationAlgorithm
.
setArgs
(
new
Object
[]{
AffinityPropagationParameters
.
SEED
,
seed
});
return
affinityPropagationAlgorithm
;
}
}
}
src/test/java/de/monticore/lang/monticar/generator/middleware/AutomaticClusteringTest.java
View file @
b165a3be
...
...
@@ -556,6 +556,10 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
DBSCANClusteringBuilder
.
DBSCANParameters
.
DBSCAN_RADIUS
,
10.0
};
break
;
case
AFFINITY_CLUSTERER:
params
=
new
Object
[]{
AffinityPropagationBuilder
.
AffinityPropagationParameters
.
SEED
,
104L
};
}
testCreateClusters
(
ClusteringAlgorithmFactory
.
getFromKind
(
kind
),
params
,
componentInstanceSymbol
,
modelName
);
}
...
...
@@ -824,7 +828,7 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
RealMatrix
mat
=
new
Array2DRowRealMatrix
(
adjMatrix
);
AffinityPropagation
clustering
=
new
AffinityPropagationParameters
().
fitNewModel
(
mat
);
AffinityPropagation
clustering
=
new
AffinityPropagationParameters
().
setSeed
(
new
Random
(
104
)).
fitNewModel
(
mat
);
final
int
[]
labels
=
clustering
.
getLabels
();
for
(
int
label
:
labels
)
{
...
...
@@ -853,7 +857,7 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
RealMatrix
mat
=
new
Array2DRowRealMatrix
(
adjMatrix
);
AffinityPropagation
clustering
=
new
AffinityPropagationParameters
().
fitNewModel
(
mat
);
AffinityPropagation
clustering
=
new
AffinityPropagationParameters
().
setSeed
(
new
Random
(
104
)).
fitNewModel
(
mat
);
final
int
[]
labels
=
clustering
.
getLabels
();
for
(
int
label
:
labels
)
{
...
...
@@ -883,7 +887,7 @@ public class AutomaticClusteringTest extends AbstractSymtabTest{
RealMatrix
mat
=
new
Array2DRowRealMatrix
(
adjMatrix
);
AffinityPropagation
clustering
=
new
AffinityPropagationParameters
().
fitNewModel
(
mat
);
AffinityPropagation
clustering
=
new
AffinityPropagationParameters
().
setSeed
(
new
Random
(
104
)).
fitNewModel
(
mat
);
final
int
[]
labels
=
clustering
.
getLabels
();
for
(
int
label
:
labels
)
{
...
...
src/test/java/de/monticore/lang/monticar/generator/middleware/JsonCliTest.java
View file @
b165a3be
...
...
@@ -4,6 +4,7 @@ import de.monticore.lang.monticar.generator.middleware.cli.DistributedTargetGene
import
org.junit.Ignore
;
import
org.junit.Test
;
@Ignore
(
"Not a test, does not assert anything"
)
public
class
JsonCliTest
{
@Test
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment