alternative cummulative successful ants measurement

This commit is contained in:
Alexander Bocken 2023-06-26 10:55:23 +02:00
parent 74d59ecc2e
commit 960b4b1ca0
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8
3 changed files with 22 additions and 24 deletions

View File

@ -113,8 +113,8 @@ class RandomWalkerAnt(Agent):
self.energy = self.model.e_0
#now look for other pheromone
self.drop_pheromone = "B"
self.look_for_pheromone = "A"
self.drop_pheromone = "B"
self._prev_pos = neighbor
self._next_pos = self.pos
@ -133,6 +133,7 @@ class RandomWalkerAnt(Agent):
self._prev_pos = neighbor
self._next_pos = self.pos
self.model.successful_ants += 1
# recruit new ants

View File

@ -187,6 +187,7 @@ def check_ants_follow_gradient():
# main()
from model import kwargs_paper_setup1 as kwargs
# kwargs["N_m"] = 10000
model = ActiveWalkerModel(**kwargs)
from hexplot import plot_hexagon

View File

@ -100,6 +100,7 @@ class ActiveWalkerModel(Model):
self.q_tr : float = q_tr # threshold under which ant cannot distinguish concentrations
self.e_min : float = e_min # energy at which walker dies
self.N_f : int = N_f #num food sources
self.successful_ants = 0 # for viviane's graph
fields=["A", "B", "nests", "food", "res"]
self.schedule = SimultaneousActivation(self)
@ -172,18 +173,13 @@ class ActiveWalkerModel(Model):
def subset_agent_count(self):
subset_agents = [agent for agent in self.schedule.agents if agent.sensitivity == self.s_0 and agent.look_for_pheromone == "B"]
count = float(len(subset_agents))
return count
self.datacollector = DataCollector(
# model_reporters={"agent_dens": lambda m: m.agent_density()},
model_reporters = {"pheromone_a": lambda m: m.grid.fields["A"],
"pheromone_b": lambda m: m.grid.fields["B"],
"alive_ants": lambda m: self.schedule.get_agent_count(),
"sucessful_walkers": lambda m: subset_agent_count(self),
"alive_ants": lambda m: m.schedule.get_agent_count(),
"sucessful_walkers": lambda m: m.successful_ants,
#"connectivity": lambda m: check_food_source_connectivity(self.grid_food,current_paths),
},
agent_reporters={}