alternative cummulative successful ants measurement
This commit is contained in:
parent
74d59ecc2e
commit
960b4b1ca0
3
agent.py
3
agent.py
@ -113,8 +113,8 @@ class RandomWalkerAnt(Agent):
|
|||||||
self.energy = self.model.e_0
|
self.energy = self.model.e_0
|
||||||
|
|
||||||
#now look for other pheromone
|
#now look for other pheromone
|
||||||
self.drop_pheromone = "B"
|
|
||||||
self.look_for_pheromone = "A"
|
self.look_for_pheromone = "A"
|
||||||
|
self.drop_pheromone = "B"
|
||||||
|
|
||||||
self._prev_pos = neighbor
|
self._prev_pos = neighbor
|
||||||
self._next_pos = self.pos
|
self._next_pos = self.pos
|
||||||
@ -133,6 +133,7 @@ class RandomWalkerAnt(Agent):
|
|||||||
|
|
||||||
self._prev_pos = neighbor
|
self._prev_pos = neighbor
|
||||||
self._next_pos = self.pos
|
self._next_pos = self.pos
|
||||||
|
self.model.successful_ants += 1
|
||||||
|
|
||||||
|
|
||||||
# recruit new ants
|
# recruit new ants
|
||||||
|
1
main.py
1
main.py
@ -187,6 +187,7 @@ def check_ants_follow_gradient():
|
|||||||
# main()
|
# main()
|
||||||
|
|
||||||
from model import kwargs_paper_setup1 as kwargs
|
from model import kwargs_paper_setup1 as kwargs
|
||||||
|
# kwargs["N_m"] = 10000
|
||||||
model = ActiveWalkerModel(**kwargs)
|
model = ActiveWalkerModel(**kwargs)
|
||||||
|
|
||||||
from hexplot import plot_hexagon
|
from hexplot import plot_hexagon
|
||||||
|
10
model.py
10
model.py
@ -100,6 +100,7 @@ class ActiveWalkerModel(Model):
|
|||||||
self.q_tr : float = q_tr # threshold under which ant cannot distinguish concentrations
|
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.e_min : float = e_min # energy at which walker dies
|
||||||
self.N_f : int = N_f #num food sources
|
self.N_f : int = N_f #num food sources
|
||||||
|
self.successful_ants = 0 # for viviane's graph
|
||||||
|
|
||||||
fields=["A", "B", "nests", "food", "res"]
|
fields=["A", "B", "nests", "food", "res"]
|
||||||
self.schedule = SimultaneousActivation(self)
|
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(
|
self.datacollector = DataCollector(
|
||||||
# model_reporters={"agent_dens": lambda m: m.agent_density()},
|
# model_reporters={"agent_dens": lambda m: m.agent_density()},
|
||||||
model_reporters = {"pheromone_a": lambda m: m.grid.fields["A"],
|
model_reporters = {"pheromone_a": lambda m: m.grid.fields["A"],
|
||||||
"pheromone_b": lambda m: m.grid.fields["B"],
|
"pheromone_b": lambda m: m.grid.fields["B"],
|
||||||
"alive_ants": lambda m: self.schedule.get_agent_count(),
|
"alive_ants": lambda m: m.schedule.get_agent_count(),
|
||||||
"sucessful_walkers": lambda m: subset_agent_count(self),
|
"sucessful_walkers": lambda m: m.successful_ants,
|
||||||
#"connectivity": lambda m: check_food_source_connectivity(self.grid_food,current_paths),
|
#"connectivity": lambda m: check_food_source_connectivity(self.grid_food,current_paths),
|
||||||
},
|
},
|
||||||
agent_reporters={}
|
agent_reporters={}
|
||||||
|
Loading…
Reference in New Issue
Block a user