Skip to content
Snippets Groups Projects
Commit 08264b03 authored by Alexandre's avatar Alexandre
Browse files

Fix cluster size and bucket id

parent 453ccdb4
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,7 @@ public class ClusterAgent<T extends DataPoint> extends Agent<DynamicClusteringAM ...@@ -46,6 +46,7 @@ public class ClusterAgent<T extends DataPoint> extends Agent<DynamicClusteringAM
else else
cluster = new Cluster<T>(dataPoint); cluster = new Cluster<T>(dataPoint);
amas.getMasSettings().database().add(cluster.getRepresentative()); amas.getMasSettings().database().add(cluster.getRepresentative());
getAmas().getEnvironment().assignToBucket(cluster.getRepresentative().getBucketId(), this);
} }
public enum State {DORMANT, WAITING_FOR_DISTANCE, DEAD} public enum State {DORMANT, WAITING_FOR_DISTANCE, DEAD}
...@@ -222,6 +223,8 @@ public class ClusterAgent<T extends DataPoint> extends Agent<DynamicClusteringAM ...@@ -222,6 +223,8 @@ public class ClusterAgent<T extends DataPoint> extends Agent<DynamicClusteringAM
if (getAmas().getMasSettings().amasOptions().contains(AMASOption.KeepAllDataPoints)) if (getAmas().getMasSettings().amasOptions().contains(AMASOption.KeepAllDataPoints))
((ExtendedCluster<T>) cluster).addClusterContent((ExtendedCluster<T>) otherCluster); ((ExtendedCluster<T>) cluster).addClusterContent((ExtendedCluster<T>) otherCluster);
else
cluster.addClusterContent(otherCluster);
} }
...@@ -229,6 +232,7 @@ public class ClusterAgent<T extends DataPoint> extends Agent<DynamicClusteringAM ...@@ -229,6 +232,7 @@ public class ClusterAgent<T extends DataPoint> extends Agent<DynamicClusteringAM
protected void onDestroy() { protected void onDestroy() {
nextState = State.DEAD; nextState = State.DEAD;
amas.getMasSettings().database().remove(cluster.getRepresentative()); amas.getMasSettings().database().remove(cluster.getRepresentative());
getAmas().getEnvironment().removeFromBucket(cluster.getRepresentative().getBucketId(), this);
} }
......
...@@ -22,9 +22,13 @@ public class Cluster<T extends DataPoint> { ...@@ -22,9 +22,13 @@ public class Cluster<T extends DataPoint> {
this.representative = representative; this.representative = representative;
this.size = 1; this.size = 1;
} }
public void addDataPoint(T dataPoint) { public void addDataPoint(T dataPoint) {
size++; size++;
} }
public void addClusterContent(Cluster<T> otherCluster) {
size += otherCluster.size;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment