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

Fix poll new data condition

parent 430962bf
No related branches found
No related tags found
No related merge requests found
......@@ -27,15 +27,16 @@ public class DynamicClusteringAMAS<T extends DataPoint> extends Amas<DynamicClus
protected void onSystemCycleBegin() {
if (logger.isLoggable(Level.INFO))
logger.info("---- BEGIN MAS CYCLE ----");
if (agents.isEmpty() || allAgentsAreDormant()) {
if (agents.isEmpty() || allAgentsAreReadyToStop()) {
var newDataPoint = environment.pollPendingDataPoint();
newDataPoint.ifPresent(dataPoint -> new DataPointAgent<T>(this, dataPoint));
}
}
private boolean allAgentsAreDormant() {
private boolean allAgentsAreReadyToStop() {
return agents.stream()
.noneMatch(agent -> agent instanceof ClusterAgent clusterAgent && !clusterAgent.readyToStop());
.noneMatch(agent -> (agent instanceof ClusterAgent clusterAgent && !clusterAgent.readyToStop()) ||
(agent instanceof DataPointAgent dataPointAgent && !dataPointAgent.readyToStop()));
}
@Override
......@@ -49,7 +50,6 @@ public class DynamicClusteringAMAS<T extends DataPoint> extends Amas<DynamicClus
@Override
public boolean stopCondition() {
return !environment.hasRemainingPendingAdditionDataPoints() &&
agents.stream().noneMatch(agent -> agent instanceof ClusterAgent clusterAgent && !clusterAgent.readyToStop()) &&
agents.stream().noneMatch(agent -> agent instanceof DataPointAgent);
allAgentsAreReadyToStop();
}
}
......@@ -142,6 +142,10 @@ public class DataPointAgent<T extends DataPoint> extends Agent<DynamicClustering
}
}
public boolean readyToStop() {
return false;
}
private record ClusterSimilarityScore<T extends DataPoint>(Cluster<T> cluster, float score) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment