def agents_three_circle(size=10): agents = Agents(agent_type=ThreeCircle) group = AgentGroup(agent_type=ThreeCircle, size=size, attributes=attributes) agents.add_non_overlapping_group( group, position_gen=lambda: np.random.uniform(-10.0, 10.0, 2)) return agents
def test_agent_agent_block_list(benchmark, size, agent_type, algorithm): # Grow the area with size. Keeps agent density constant. area_size = np.sqrt(2 * size) agents = Agents(agent_type=agent_type) group = AgentGroup(agent_type=agent_type, size=size, attributes=attributes) agents.add_non_overlapping_group( group, position_gen=lambda: np.random.uniform(-area_size, area_size, 2)) benchmark(agent_agent_block_list, agents.array) assert True
def _default_agents(self): agents = Agents(agent_type=self.agent_type) group = AgentGroup(agent_type=self.agent_type, size=self.size, attributes=self.attributes) agents.add_non_overlapping_group( group, position_gen=self.field.sample_spawn(0)) return agents
def _observe_agents(self, change): if self.agent_type is not None: agents = Agents(agent_type=self.agent_type) group = AgentGroup(agent_type=self.agent_type, size=self.size, attributes=self.attributes) agents.add_non_overlapping_group(group, position_gen=lambda: np.array( (0, 0))) self.agents = agents
def _default_agents(self): agents = Agents(agent_type=self.agent_type) for spawn, name in enumerate( ['finlandiahall', 'foyer', 'helsinkihall']): group = AgentGroup(agent_type=self.agent_type, size=getattr(self, f'size_{name}'), attributes=self.attributes(has_target=True, is_follower=False)) agents.add_non_overlapping_group( group, position_gen=self.field.sample_spawn(spawn), obstacles=geom_to_linear_obstacles(self.field.obstacles)) return agents
def _default_agents(self): agents = Agents(agent_type=self.agent_type) group_active = AgentGroup( agent_type=self.agent_type, size=self.size_leaders, attributes=self.attributes(has_target=True, is_follower=False)) group_herding = AgentGroup( agent_type=self.agent_type, size=self.size_herding, attributes=self.attributes(has_target=False, is_follower=True)) for group in (group_active, group_herding): agents.add_non_overlapping_group( group, position_gen=self.field.sample_spawn(0), obstacles=geom_to_linear_obstacles(self.field.obstacles)) return agents
def _default_agents(self): agents = Agents(agent_type=self.agent_type) obstacles = geom_to_linear_obstacles(self.field.obstacles) # Add new spawns to the field for the leaders self.field.spawns.extend([ rectangle(25, 45, 10, 10), rectangle(80, 65, 10, 10), rectangle(75, 35, 10, 10), rectangle(35, 5, 10, 10), ]) for i in range(self.size_leaders): group_leader = AgentGroup( agent_type=self.agent_type, size=1, attributes=self.attributes(target=i, is_follower=False)) agents.add_non_overlapping_group( group_leader, position_gen=self.field.sample_spawn(i + 1), obstacles=obstacles) group_herding = AgentGroup( agent_type=self.agent_type, size=self.size_herding, attributes=self.attributes(target=NO_TARGET, is_follower=True)) agents.add_non_overlapping_group( group_herding, position_gen=self.field.sample_spawn(0), obstacles=obstacles) return agents
def _default_agents(self): agents = Agents(agent_type=self.agent_type) group1 = AgentGroup(size=self.size // 2, agent_type=self.agent_type, attributes=self.attributes1) group2 = AgentGroup(size=self.size // 2, agent_type=self.agent_type, attributes=self.attributes2) agents.add_non_overlapping_group( group=group1, position_gen=self.field.sample_spawn(0)) agents.add_non_overlapping_group( group=group2, position_gen=self.field.sample_spawn(1)) return agents
def _default_agents(self): agents = Agents(agent_type=self.agent_type) group_leader = AgentGroup(agent_type=self.agent_type, size=self.size_leaders, attributes=self.attributes(is_leader=True)) agents.add_non_overlapping_group( group_leader, position_gen=self.field.sample_spawn(0)) group_herding = AgentGroup(agent_type=self.agent_type, size=self.size_herding, attributes=self.attributes(is_leader=False)) agents.add_non_overlapping_group( group_herding, position_gen=self.field.sample_spawn(0)) return agents
def _default_agents(self): agents = Agents(agent_type=self.agent_type) group_leader = AgentGroup(agent_type=self.agent_type, size=self.size_leaders, attributes=self.attributes(is_leader=True)) agents.add_non_overlapping_group( group_leader, position_gen=lambda: np.array((self.horizontal_ratio * self.width, self.vertical_ratio * self.height))) group_herding = AgentGroup(agent_type=self.agent_type, size=self.size_herding, attributes=self.attributes(is_leader=False)) agents.add_non_overlapping_group( group_herding, position_gen=self.field.sample_spawn(0)) return agents
def _observe_agents(self, change): if self.agent_type is not None: agents = Agents(agent_type=self.agent_type) group = AgentGroup(agent_type=self.agent_type, size=1, attributes=partial(self.attributes, orientation=0.0)) agents.add_non_overlapping_group( group, position_gen=lambda: self.start_pos1) group = AgentGroup(agent_type=self.agent_type, size=1, attributes=partial(self.attributes, orientation=np.pi)) agents.add_non_overlapping_group( group, position_gen=lambda: self.start_pos2) self.agents = agents
def _default_agents(self): agents = Agents(agent_type=self.agent_type) return agents
def test_agents(agent_type, attributes): agents = Agents(agent_type=agent_type) group = AgentGroup(size=SIZE, agent_type=agent_type, attributes=attributes) agents.add_non_overlapping_group( group=group, position_gen=lambda: np.random.uniform(XMIN, XMAX, 2)) assert True
def _default_agents(self): agents = Agents(agent_type=self.agent_type) # Generate iterators for group of leaders. #target_exits = [0,1,0] #cells = [913,695,652] target_exits = [] cells = [] n_guides = len(target_exits) speed_left = "fast" speed_lower = "fast" speed_right = "fast" speed_upper = "fast" # Exiting agents in left spawn group_follower_spawn_left = AgentGroup( agent_type=self.agent_type, size=getattr(self, 'size_spawn_left'), attributes=self.attributes(familiar=2, has_target=True, is_follower=True)) agents.add_non_overlapping_group( speed_left, "spawn_left", group_follower_spawn_left, position_gen=False, position_iter=iter([]), spawn=0, obstacles=geom_to_linear_obstacles(self.field.obstacles)) # Exiting agents in lower spawn group_follower_spawn_lower = AgentGroup( agent_type=self.agent_type, size=getattr(self, 'size_spawn_lower'), attributes=self.attributes(familiar=3, has_target=True, is_follower=True)) agents.add_non_overlapping_group( speed_lower, "spawn_lower", group_follower_spawn_lower, position_gen=False, position_iter=iter([]), spawn=0, obstacles=geom_to_linear_obstacles(self.field.obstacles)) # Exiting agents in right spawn group_follower_spawn_right = AgentGroup( agent_type=self.agent_type, size=getattr(self, 'size_spawn_right'), attributes=self.attributes(familiar=0, has_target=True, is_follower=True)) agents.add_non_overlapping_group( speed_right, "spawn_right", group_follower_spawn_right, position_gen=False, position_iter=iter([]), spawn=2, obstacles=geom_to_linear_obstacles(self.field.obstacles)) # Exiting agents in upper spawn group_follower_spawn_upper = AgentGroup( agent_type=self.agent_type, size=getattr(self, 'size_spawn_upper'), attributes=self.attributes(familiar=1, has_target=True, is_follower=True)) agents.add_non_overlapping_group( speed_upper, "spawn_upper", group_follower_spawn_upper, position_gen=False, position_iter=iter([]), spawn=3, obstacles=geom_to_linear_obstacles(self.field.obstacles)) if n_guides != 0: init_pos = self.generate_leader_pos(cells, n_guides) print(init_pos) # init_pos = [[8, 6]] target_exits = iter(target_exits) init_pos = iter(init_pos) # Guides in Variance Dilemma group_leader = AgentGroup( agent_type=self.agent_type, size=n_guides, attributes=self.attributes_leader(target_iter=target_exits, has_target=True, is_follower=False)) agents.add_non_overlapping_group( "group_leader", group_leader, position_gen=True, position_iter=init_pos, spawn=0, obstacles=geom_to_linear_obstacles(self.field.obstacles)) return agents