Class DefaultSwarm
java.lang.Object
com.tnsai.coordination.groups.DefaultAgentGroup
com.tnsai.coordination.groups.swarm.DefaultSwarm
- All Implemented Interfaces:
com.tnsai.agents.groups.AgentGroup,Swarm
Default implementation of Swarm.
Provides decentralized agent coordination with:
- Pheromone-based indirect communication
- Configurable neighbor detection
- Multiple swarm intelligence algorithms
- Automatic tick-based updates
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSwarm(String id, String name, String description, SwarmBehavior behavior, SwarmIntelligence intelligence, NeighborDetection neighborDetection, int neighborRadius, double pheromoneDecay, com.tnsai.agents.groups.GroupPolicy policy) Creates a new DefaultSwarm. -
Method Summary
Modifier and TypeMethodDescriptionvoidTriggers pheromone decay across all locations.voiddepositPheromone(String location, PheromoneType type, double intensity) Deposits a pheromone at the specified location.Executes a collective exploration task.Executes a collective exploration task with context.exploreAsync(String task) Async exploration.Gets the current swarm behavior.Gets the shared environment/blackboard.Gets the swarm intelligence strategy.Gets the neighbor detection strategy.intGets the neighbor detection radius.List<com.tnsai.agents.Agent> getNeighbors(String agentId) Gets neighbors of an agent within detection radius.doubleGets the pheromone decay rate.doublegetPheromoneIntensity(String location, PheromoneType type) Gets the pheromone intensity at a location.getPheromonesAt(String location) Gets all pheromones at a location.getState()Gets current swarm state snapshot.booleanChecks if swarm is currently running.voidRuns the swarm for specified duration.voidsetBehavior(SwarmBehavior behavior) Sets the swarm behavior.voidsetNeighborRadius(int radius) Sets the neighbor detection radius.Executes a collective optimization/solving task.Executes a collective optimization with context.solveAsync(String problem) Async solving.voidstop()Stops the swarm execution.voidtick()Triggers one swarm tick (update cycle).toString()Methods inherited from class com.tnsai.coordination.groups.DefaultAgentGroup
addLifecycleListener, addMember, addMembershipListener, assignTask, broadcast, dissolve, electLeader, electLeader, findMembers, getDescription, getEventBus, getId, getLeader, getLifecycle, getMember, getMembers, getMembershipManager, getMetrics, getName, getPolicy, hasMember, notifyTaskComplete, notifyTaskFailed, removeLifecycleListener, removeMember, removeMembershipListener, scatter, scatter, scatterAsync, setPolicy, start, stopNowMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.tnsai.agents.groups.AgentGroup
addLifecycleListener, addMember, addMembershipListener, assignTask, broadcast, broadcast, dissolve, electLeader, electLeader, findMembers, getDescription, getEventBus, getId, getLeader, getLifecycle, getMember, getMemberCount, getMembers, getMembershipManager, getMetrics, getName, getPolicy, hasMember, isActive, isDissolved, removeLifecycleListener, removeMember, removeMembershipListener, scatter, scatter, scatterAsync, setPolicy, start, stopNow
-
Constructor Details
-
DefaultSwarm
public DefaultSwarm(String id, String name, String description, SwarmBehavior behavior, SwarmIntelligence intelligence, NeighborDetection neighborDetection, int neighborRadius, double pheromoneDecay, com.tnsai.agents.groups.GroupPolicy policy) Creates a new DefaultSwarm.- Parameters:
id- swarm IDname- swarm namedescription- descriptionbehavior- initial behaviorintelligence- intelligence algorithmneighborDetection- neighbor detection strategyneighborRadius- neighbor radiuspheromoneDecay- pheromone decay ratepolicy- group policy
-
-
Method Details
-
getBehavior
Description copied from interface:SwarmGets the current swarm behavior.- Specified by:
getBehaviorin interfaceSwarm- Returns:
- behavior type
-
setBehavior
Description copied from interface:SwarmSets the swarm behavior.- Specified by:
setBehaviorin interfaceSwarm- Parameters:
behavior- new behavior
-
getIntelligence
Description copied from interface:SwarmGets the swarm intelligence strategy.- Specified by:
getIntelligencein interfaceSwarm- Returns:
- intelligence strategy
-
getNeighborDetection
Description copied from interface:SwarmGets the neighbor detection strategy.- Specified by:
getNeighborDetectionin interfaceSwarm- Returns:
- neighbor detection
-
depositPheromone
Description copied from interface:SwarmDeposits a pheromone at the specified location.Pheromones are indirect signals that influence other swarm members' behavior.
- Specified by:
depositPheromonein interfaceSwarm- Parameters:
location- location identifiertype- pheromone typeintensity- signal strength (0.0 to 1.0)
-
getPheromoneIntensity
Description copied from interface:SwarmGets the pheromone intensity at a location.- Specified by:
getPheromoneIntensityin interfaceSwarm- Parameters:
location- location identifiertype- pheromone type- Returns:
- intensity (0.0 to 1.0)
-
getPheromonesAt
Description copied from interface:SwarmGets all pheromones at a location.- Specified by:
getPheromonesAtin interfaceSwarm- Parameters:
location- location identifier- Returns:
- map of pheromone types to intensities
-
getPheromoneDecay
public double getPheromoneDecay()Description copied from interface:SwarmGets the pheromone decay rate.- Specified by:
getPheromoneDecayin interfaceSwarm- Returns:
- decay rate per tick
-
decayPheromones
public void decayPheromones()Description copied from interface:SwarmTriggers pheromone decay across all locations.- Specified by:
decayPheromonesin interfaceSwarm
-
getNeighbors
Description copied from interface:SwarmGets neighbors of an agent within detection radius.- Specified by:
getNeighborsin interfaceSwarm- Parameters:
agentId- agent to check- Returns:
- list of neighboring agents
-
getNeighborRadius
public int getNeighborRadius()Description copied from interface:SwarmGets the neighbor detection radius.- Specified by:
getNeighborRadiusin interfaceSwarm- Returns:
- radius (interpretation depends on detection strategy)
-
setNeighborRadius
public void setNeighborRadius(int radius) Description copied from interface:SwarmSets the neighbor detection radius.- Specified by:
setNeighborRadiusin interfaceSwarm- Parameters:
radius- new radius
-
explore
Description copied from interface:SwarmExecutes a collective exploration task.Agents spread out and share discoveries via pheromones.
-
explore
Description copied from interface:SwarmExecutes a collective exploration task with context. -
solve
Description copied from interface:SwarmExecutes a collective optimization/solving task.Agents collaborate using swarm intelligence algorithms.
-
solve
Description copied from interface:SwarmExecutes a collective optimization with context. -
exploreAsync
Description copied from interface:SwarmAsync exploration.- Specified by:
exploreAsyncin interfaceSwarm- Parameters:
task- exploration task- Returns:
- future result
-
solveAsync
Description copied from interface:SwarmAsync solving.- Specified by:
solveAsyncin interfaceSwarm- Parameters:
problem- problem description- Returns:
- future result
-
getState
Description copied from interface:SwarmGets current swarm state snapshot. -
getEnvironment
Description copied from interface:SwarmGets the shared environment/blackboard.- Specified by:
getEnvironmentin interfaceSwarm- Returns:
- shared environment
-
tick
public void tick()Description copied from interface:SwarmTriggers one swarm tick (update cycle).During a tick:
- Pheromones decay
- Agents update positions
- Neighbors are recalculated
- Behaviors are executed
-
run
Description copied from interface:SwarmRuns the swarm for specified duration. -
stop
public void stop()Description copied from interface:SwarmStops the swarm execution.- Specified by:
stopin interfacecom.tnsai.agents.groups.AgentGroup- Specified by:
stopin interfaceSwarm- Overrides:
stopin classDefaultAgentGroup
-
isRunning
public boolean isRunning()Description copied from interface:SwarmChecks if swarm is currently running. -
toString
- Overrides:
toStringin classDefaultAgentGroup
-