Cache score if metric is not changed

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