Commit 1c45718a authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Cache score if metric is not changed

parent 40c2735c
...@@ -29,6 +29,8 @@ public class ClusteringResult { ...@@ -29,6 +29,8 @@ public class ClusteringResult {
private int componentNumber; private int componentNumber;
private boolean valid; private boolean valid;
private Metric metric; private Metric metric;
private double score;
private boolean sameMetric = false;
private ClusteringResult(ClusteringInput clusteringInput, AlgorithmCliParameters parameters, private ClusteringResult(ClusteringInput clusteringInput, AlgorithmCliParameters parameters,
List<Set<EMAComponentInstanceSymbol>> clustering, long duration, int componentNumber, boolean valid, Metric metric) { List<Set<EMAComponentInstanceSymbol>> clustering, long duration, int componentNumber, boolean valid, Metric metric) {
...@@ -80,11 +82,18 @@ public class ClusteringResult { ...@@ -80,11 +82,18 @@ public class ClusteringResult {
} }
public void setMetric(Metric metric){ public void setMetric(Metric metric){
this.metric = metric; if (this.metric != metric) {
this.metric = metric;
sameMetric = false;
}
} }
public double getScore(){ public double getScore(){
return metric.getScore(this); if (!sameMetric) {
sameMetric = true;
score = metric.getScore(this);
}
return score;
} }
public EMAComponentInstanceSymbol getComponent() { public EMAComponentInstanceSymbol getComponent() {
......
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