Space Module Documentation¶
Grid¶
In the file grid.py it is defined the class Grid, which implements the space where take place the simulation as a grid (x, y).
-
class
grid.Grid(width, height)¶ Class to implement the space where take place the simulation as a grid (x, y).
- Attributes:
- height: Height in number of grid cells. width: Width in number of grid cells. grid: List of rows x, rows are lists of positions y. That is, a matrix of positions [x][y].
- Methods:
- get_all_item: Get all the elements that have been placed in the grid. get_items_in_pos: Gets the elements located in a grid position. move_item: Change the position of a grid element. place_item: Place an element in a grid position. remove_item: Remove an item from the grid. is_cell_empty: Evaluate if a cell does not contain any item.
-
get_all_item()¶ - Get all the elements that have been placed in the grid.
- Return: List of items.
-
get_items_in_pos(pos)¶ - Gets the elements located in a grid position.
- Args:
- pos: Position of the grid as (x, y).
Return: List of items.
-
is_cell_empty(pos)¶ - Evaluate if a cell does not contain any item.
- Args:
- pos: Position of the grid as (x, y).
Return: True (yes) or False (no).
-
move_item(item, pos)¶ - Change the position of a grid element.
- Args:
- item: Element in the grid. pos: New position of the item.
-
place_item(item, pos)¶ - Place an element in a grid position.
- Args:
- pos: Position of the grid as (x, y). item: Element outside the grid.
-
remove_item(pos, item)¶ - Remove an item from the grid.
- Args:
- pos: Position of the grid as (x, y). item: Element inside the grid.
Items in continuous modeling¶
In the file continuousItems.py four classes are defined to implement the elements of the physical space in a continuous model:
-GeneralItem: Class that implements generic elements positioned on the map with the effect of being impenetrable. -Door: Class that implements bulding plane doors. -Wall: Class that implements building walls. -Poi: Class that implements points of interest where Occupancy objects perform certain actions.
-
class
continuousItems.Door(model, pos1, pos2, rot, state=True)¶ - Class that implements bulding plane doors.
- Attributes:
- state: Door status, open (True) or closed (False). pos1: First position to access to the door. pos2: Second position to access to the door. rot: Door orientation in the grid (‘x’ or ‘y’).
- Methods:
- open: Change the status of the door to open. close: Change the status of the door to close.
-
close()¶ Change the status of the door to close (False)
-
open()¶ Change the status of the door to open (True)
-
class
continuousItems.GeneralItem(model, pos, color=None)¶ - Class that implements generic elements positioned on the map with the effect of being impenetrable.
- Attributes:
- pos: Position where the object is located. color: Color with which the object will be represented in the visualization.
-
class
continuousItems.Poi(model, pos, ide, share=True, color=None)¶ - Class that implements relevant elements in the simulations: points of interest where Occupancy objects perform certain actions by associating these points with certain states.
- Attributes:
- pos: Position where the object is located. ide: Unique identifier associated with the point of interest. share: Define if the poi can be shared by more than one occupant. color: Color with which the object will be represented in the visualization.
-
class
continuousItems.Wall(block1, block2, block3, color=None)¶ - Class that implements building walls.
- Attributes:
- block1, block2, block3: lists of positions that contain positions between which an
- occupant can move obeying with the impenetrability of the wall.
color: Color with which the object will be represented in the visualization.
Items in simplified modeling¶
- In the file continuousItems.py three classes are defined to implement the elements
of the physical space in a simplified model based on a room distribution:
-Room: Class that implements the rooms through which the Agent/Ocupant objects are located, move and where activities are carried out. -Door: Class that implements bulding plane doors. -Wall: Class that implements building walls.
-
class
roomsItems.Door(room1=False, room2=False, state=False)¶ - Class that implements bulding plane doors.
- Attributes:
- state: Door status, open (True) or closed (False). room1: First room to croos the door. room2: Second room to croos the door.
- Methods:
- open: Change the status of the door to open. close: Change the status of the door to close.
-
close()¶ Change the status of the door to closed (False)
-
open()¶ Change the status of the door to open (True)
-
class
roomsItems.Room(name, conectedTo, dx, dy, pos=(0, 0))¶ - Class that implements the rooms through which the Agent/Ocupant objects are located, move and where activities are carried out.
- Attributes:
- name: Unique name of the room. roomsConected: List of accessible rooms from this room. dx: Size in the ordinate x (meters). dy: Size in the ordinate y (meters). pos: Position of the room (x, y). agentsInRoom: List of agent objects in the room walls: List of Wall objects of the room. doors: List of Doors objects of the room.
-
class
roomsItems.Wall(room1=False, room2=False)¶ - Class that implements building walls.
- Attributes:
- room1: First room to croos the door. room2: Second room to croos the door.