Exemplo n.º 1
0
 def __init__(self, iterable=None, n=None, size=0.0, rotation=0.0):
     JsonList.__init__(self, iterable, list_type=Transformation)
     if n:
         for a in range(n):
             self.append(
                 Transformation(
                     float(size),
                     float(rotation) + float(a) * (360.0 / float(n))))
Exemplo n.º 2
0
 def __init__(self,
              iterable=None,
              world=None,
              cell_group_builder: Cell_group_builder = None):
     if cell_group_builder is None:
         cell_group_builder = []
     JsonList.__init__(self, iterable, list_type=Cell)
     if world:
         for cell_id in cell_group_builder:
             self.append(world.cells[cell_id])
Exemplo n.º 3
0
 def get_incomplete_episodes(self,
                             threshold_step_count: int = 30,
                             agent_name: str = "prey") -> JsonList:
     incomplete_episodes = JsonList(list_type=int)
     for i, episode in enumerate(self.episodes):
         agent_trajectory = episode.trajectories.get_agent_trajectory(
             agent_name)
         if len(agent_trajectory) == 0:
             continue
         if len(agent_trajectory) < threshold_step_count:
             incomplete_episodes.append(i)
     return incomplete_episodes
Exemplo n.º 4
0
 def get_broken_trajectory_episodes(self,
                                    threshold_distance: float = .1,
                                    agent_name: str = "prey") -> JsonList:
     broken_trajectory_episodes = JsonList(list_type=int)
     for i, episode in enumerate(self.episodes):
         agent_trajectory = episode.trajectories.get_agent_trajectory(
             agent_name)
         last_location = None
         for step in agent_trajectory:
             if last_location is not None:
                 if last_location.dist(step.location) > threshold_distance:
                     broken_trajectory_episodes.append(i)
                     break
             last_location = step.location
     return broken_trajectory_episodes
Exemplo n.º 5
0
 def get_wrong_goal_episodes(self,
                             goal: Coordinates = Coordinates(20, 0),
                             agent_name: str = "prey") -> JsonList:
     world = World.get_from_parameters_names(self.world_configuration_name,
                                             "canonical")
     wrong_goal_episodes = JsonList(list_type=int)
     for i, episode in enumerate(self.episodes):
         agent_trajectory = episode.trajectories.get_agent_trajectory(
             agent_name)
         if len(agent_trajectory) == 0:
             continue
         episode_goal_location = agent_trajectory[-1].location
         episode_goal_index = world.cells.find(episode_goal_location)
         episode_goal_coordinates = world.cells[
             episode_goal_index].coordinates
         if not episode_goal_coordinates == goal:
             wrong_goal_episodes.append(i)
     return wrong_goal_episodes
Exemplo n.º 6
0
    def __init__(self,
                 spatial_entropy: float = float(0),
                 spatial_espinometry: float = float(0),
                 spatial_connections: JsonList = None,
                 spatial_connections_derivative: JsonList = None,
                 spatial_centrality: JsonList = None,
                 spatial_centrality_derivative: JsonList = None,
                 visual_entropy: float = float(0),
                 visual_espinometry: float = float(0),
                 visual_connections: JsonList = None,
                 visual_connections_derivative: JsonList = None,
                 visual_centrality: JsonList = None,
                 visual_centrality_derivative: JsonList = None):
        self.spatial_entropy = spatial_entropy
        self.spatial_espinometry = spatial_espinometry
        if spatial_connections:
            self.spatial_connections = spatial_connections
        else:
            self.spatial_connections = JsonList(list_type=int)
        if spatial_connections_derivative:
            self.spatial_connections_derivative = spatial_connections_derivative
        else:
            self.spatial_connections_derivative = JsonList(list_type=int)
        if spatial_centrality:
            self.spatial_centrality = spatial_centrality
        else:
            self.spatial_centrality = JsonList(list_type=float)
        if spatial_centrality_derivative:
            self.spatial_centrality_derivative = spatial_centrality_derivative
        else:
            self.spatial_centrality_derivative = JsonList(list_type=float)

        self.visual_entropy = visual_entropy
        self.visual_espinometry = visual_espinometry
        if visual_connections:
            self.visual_connections = visual_connections
        else:
            self.visual_connections = JsonList(list_type=int)
        if visual_connections_derivative:
            self.visual_connections_derivative = visual_connections_derivative
        else:
            self.visual_connections_derivative = JsonList(list_type=int)
        if visual_centrality:
            self.visual_centrality = visual_centrality
        else:
            self.visual_centrality = JsonList(list_type=float)
        if visual_centrality_derivative:
            self.visual_centrality_derivative = visual_centrality_derivative
        else:
            self.visual_centrality_derivative = JsonList(list_type=float)
Exemplo n.º 7
0
 def get_centrality(self, depth: int = 1) -> JsonList:
     cell_map = Cell_map(self.configuration.cell_coordinates)
     counters = [1 for x in self.cells]
     new_counters = [0 for x in self.cells]
     for i in range(depth):
         for cell_index, cell in enumerate(self.cells):
             if cell.occluded:
                 continue
             for connection in self.configuration.connection_pattern:
                 connection_index = cell_map[cell.coordinates + connection]
                 if connection_index == -1 or self.cells[
                         connection_index].occluded:
                     continue
                 new_counters[cell_index] += counters[connection_index]
         counters = [x for x in new_counters]
     return JsonList(iterable=[c / max(counters) for c in counters],
                     list_type=float)
Exemplo n.º 8
0
 def __init__(self,
              start_time: datetime = None,
              time_stamp: float = 0.0,
              end_time: datetime = None,
              trajectories: Trajectories = None,
              captures: JsonList = None):
     if not start_time:
         start_time = datetime.now()
     self.start_time = start_time
     self.time_stamp = time_stamp
     if not end_time:
         end_time = datetime.now()
     self.end_time = end_time
     if trajectories is None:
         trajectories = Trajectories()
     self.trajectories = trajectories
     if captures is None:
         captures = JsonList(list_type=int)
     self.captures = captures
Exemplo n.º 9
0
 def __init__(self, iterable=None):
     JsonList.__init__(self, iterable, list_type=int)
Exemplo n.º 10
0
 def __init__(self, iterable=None):
     JsonList.__init__(self, iterable, list_type=Location)
Exemplo n.º 11
0
 def remove_episodes(self, episode_list: JsonList) -> None:
     for episode_index in episode_list:
         self.episodes[episode_index].trajectories = Trajectories()
         self.episodes[episode_index].captures = JsonList(list_type=int)
Exemplo n.º 12
0
 def __init__(self, iterable=None):
     JsonList.__init__(self, iterable, list_type=Coordinates)