Refactoring: Add ClusteringAlgorithm arguments as state

parent 5ff6f51c
......@@ -24,7 +24,9 @@ public class DBScanCliParameters extends AlgorithmCliParameters {
@Override
public ClusteringAlgorithm asClustringAlgorithm() {
return new DBSCANClusteringAlgorithm();
DBSCANClusteringAlgorithm dbscanClusteringAlgorithm = new DBSCANClusteringAlgorithm();
dbscanClusteringAlgorithm.setArgs(asAlgorithmArgs());
return dbscanClusteringAlgorithm;
}
@Override
......@@ -55,4 +57,12 @@ public class DBScanCliParameters extends AlgorithmCliParameters {
public Optional<Double> getRadius() {
return Optional.ofNullable(radius);
}
public void setMinPts(Integer min_pts) {
this.min_pts = min_pts;
}
public void setRadius(Double radius) {
this.radius = radius;
}
}
......@@ -24,7 +24,9 @@ public class MarkovCliParameters extends AlgorithmCliParameters {
@Override
public ClusteringAlgorithm asClustringAlgorithm() {
return new MarkovClusteringAlgorithm();
MarkovClusteringAlgorithm markovClusteringAlgorithm = new MarkovClusteringAlgorithm();
markovClusteringAlgorithm.setArgs(asAlgorithmArgs());
return markovClusteringAlgorithm;
}
@Override
......@@ -69,4 +71,20 @@ public class MarkovCliParameters extends AlgorithmCliParameters {
public Optional<Double> getZeroMax() {
return Optional.ofNullable(zero_max);
}
public void setMaxResidual(Double max_residual) {
this.max_residual = max_residual;
}
public void setGammaExp(Double gamma_exp) {
this.gamma_exp = gamma_exp;
}
public void setLoopGain(Double loop_gain) {
this.loop_gain = loop_gain;
}
public void setZeroMax(Double zero_max) {
this.zero_max = zero_max;
}
}
......@@ -24,7 +24,9 @@ public class SpectralClusteringCliParameters extends AlgorithmCliParameters {
@Override
public ClusteringAlgorithm asClustringAlgorithm() {
return new SpectralClusteringAlgorithm();
SpectralClusteringAlgorithm clusteringAlgorithm = new SpectralClusteringAlgorithm();
clusteringAlgorithm.setArgs(asAlgorithmArgs());
return clusteringAlgorithm;
}
@Override
......@@ -68,4 +70,16 @@ public class SpectralClusteringCliParameters extends AlgorithmCliParameters {
public Optional<Double> getSigma() {
return Optional.ofNullable(sigma);
}
public void setNumberOfClusters(Integer numberOfClusters) {
this.numberOfClusters = numberOfClusters;
}
public void setL(Integer l) {
this.l = l;
}
public void setSigma(Double sigma) {
this.sigma = sigma;
}
}
......@@ -7,5 +7,13 @@ import java.util.Set;
// product if for clustering factory
public interface ClusteringAlgorithm {
public List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args);
List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args);
//TODO: add arguments as typed state of the algorithms
default List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component){
return cluster(component ,getArgs());
}
List<Object> getArgs();
}
......@@ -13,6 +13,17 @@ import java.util.*;
public class AffinityPropagationAlgorithm implements ClusteringAlgorithm {
private List<Object> args;
public void setArgs(List<Object> args) {
this.args = args;
}
@Override
public List<Object> getArgs() {
return args;
}
@Override
public List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args) {
......
......@@ -11,6 +11,17 @@ import java.util.*;
// DBSCAN clusterer product implementation
public class DBSCANClusteringAlgorithm implements ClusteringAlgorithm {
private List<Object> args;
public void setArgs(List<Object> args) {
this.args = args;
}
@Override
public List<Object> getArgs() {
return args;
}
@Override
public List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args) {
......
......@@ -15,6 +15,17 @@ import java.util.*;
// markov mcl clusterer product implementation
public class MarkovClusteringAlgorithm implements ClusteringAlgorithm {
private List<Object> args;
public void setArgs(List<Object> args) {
this.args = args;
}
@Override
public List<Object> getArgs() {
return args;
}
private static Dataset[] getClustering(Dataset data, SparseMatrix matrix) {
int[] sparseMatrixSize = matrix.getSize();
......
......@@ -11,6 +11,17 @@ import java.util.*;
// spectral clusterer product implementation
public class SpectralClusteringAlgorithm implements ClusteringAlgorithm {
private List<Object> args;
public void setArgs(List<Object> args) {
this.args = args;
}
@Override
public List<Object> getArgs() {
return args;
}
@Override
public List<Set<EMAComponentInstanceSymbol>> cluster(EMAComponentInstanceSymbol component, Object... args) {
......
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