Model Module Documentation

Model

class soba.models.generalModel.GeneralModel(width, height, seed=1561971992, timeByStep=60)[source]

Base Class to create simulation models. It creates and manages space and agents.

Attributes:
height: Height in number of grid cells. width: Width in number of grid cells. schedule: BaseScheduler object for agent activation. grid: Grid object to implement space. running: Parameter to control the models execution. NStep: Measure of the number of steps. occupants: List of Occupant objects created. agents: List of the all Agent objects created. asciMap: Representation of the map as ASCI used to get FOV information. seed: Seed employ in random generations. finishSimulation: Parameter to stop the software simulation.
Methods:
finishTheSimulation: Finish with the execution of the simulation software. run_model: Model execution. step: Execution of the scheduler steps.
finishTheSimulation()[source]

Finish with the execution of the simulation software.

step()[source]

Main step of the simulation, execution of the scheduler steps.

Continuous Model

class soba.models.continuousModel.ContinuousModel(width, height, jsonMap, jsonsOccupants, seed=datetime.datetime(2019, 7, 1, 9, 6, 32, 573465), scale=0.5, timeByStep=60)[source]
Base Class to create simulation models on a simplified space based on rooms.
Attributes:
Those inherited from the Occupant class. rooms: List of Room objects. walls: List of Wall objects. pois: List of Pois objects. generalItems: List of GeneralItem objects. doors: List of Door objects.
Methods:
createOccupants: Create occupants of the ContinuousOccupant type. getScaledCoordinate: Gets the value of a coordinate or a cell size scaled. setMap: Define the map plane distribution. getAsciMap: Get the plane of the grid in an ASCII format, such as a matrix, to apply the fov algorithm. thereIsClosedDoor: Check if one door is closed or open. getDoorInPos: Get a Door object in a position given. getOccupantsPos: Get a Occupant objects in a position given. thereIsOccupant: Check if there is any Occupant object in a position given. getOccupantId: Get the occupant with the unique_id given. getPOIsId: Get the pois object with the id given. getPOIsPos: Get the position of a poi object. checkFreePOI: Check if one Point of interest is free (there is no occupant on this). xyInGrid: Check if one position is inside the grid. nearPos: Check if two positions are consecutive.
checkFreePOI(p)[source]
Check if one Point of interest is free (there is no occupant on this).
Args:
p: Poi object.

Return: True (yes), False (no).

createAvatar(idAvatar, pos, color='red', initial_state='walking')[source]

Create one avatar

createOccupants(jsonsOccupants)[source]
Create occupants of the ContinuousOccupant type.
Args:
jsonOccupants: Json of description of the occupants.
getAsciMap()[source]

Get the plane of the grid in an ASCII format, such as a matrix, to apply the fov algorithm.

getDoorInPos(pos)[source]
Get a Door object in a position given.
Args:
pos: Position of the door as (x, y).

Return: Door object or false.

getOccupantId(Id)[source]
Get the occupant with the unique_id given.
Args:
Id: Unique_id given as number

Return: Occupant object or False.

getOccupantsPos(pos)[source]
Get a Occupant objects in a position given.
Args:
pos: Position as (x, y).

Return: List of Cccupant objects.

getPOIsId(poiId)[source]
Get the pois object with the id given.
Args:
poiId: poi id given as number

Return: list of pois object or False.

getPOIsPos(poiPos)[source]
Get the position of a poi object.
Args:
poiPos: position as (x, y)

Return: poi object or False.

getScaledCoordinate(coordenate, scale)[source]
Gets the value of a coordinate or a cell size scaled to the size of the grid in relation to a given scale.
Args:
coordenate: Coordenate value to be scale scale: Value of the scale to be applied.

Return: value of the coordinate.

nearPos(pos1, pos2)[source]
Check if two positions are consecutive.
Args:
pos1: Position as (x, y). pos2: Position as (x, y).

Return: True (yes), False (no).

setMap(jsonMap, scale)[source]
Define the map plane distribution.
Args:
jsonMap: Json of description of the map plane. scale: Value of the scale.
step()[source]

Main step of the simulation, execution of the scheduler steps.

thereIsClosedDoor(pos)[source]
Check if one door is closed or open.
Args:
pos: Position of the door as (x, y).

Return: State of the door as boolean.

thereIsOccupant(pos)[source]
Check if there is any Occupant object in a position given.
Args:
pos: Position as (x, y).

Return: True (yes), False (no).

xyInGrid(pos)[source]
Check if one position is inside the grid.
Args:
pos: Position as (x, y).

Return: True (yes), False (no).

Rooms Model

class soba.models.roomsModel.RoomsModel(width, height, jsonRooms, jsonsOccupants, seed=1561971992, timeByStep=60)[source]

Base Class to create simulation models on a simplified space based on rooms.

Attributes:
Those inherited from the Occupant class. rooms: List of Room objects. Those inherited from the Occupant class. rooms: List of Room objects. walls: List of Wall objects. pois: List of Pois objects. generalItems: List of GeneralItem objects. doors: List of Door objects.
Methods:
createOccupants: Create occupants of the RoomsOccupant type. createRooms: Create the rooms in the grid space. setMap: Define the map plane distribution. createDoors: Create the doors in the grid space. createWalls: Create the walls in the grid space. thereIsClosedDoor: Check if one door is closed or open. thereIsOtherOccupantInRoom: Evaluate if there is another occupant apart of the past as a parameter in a room. thereIsSomeOccupantInRoom: Evaluate if there is any occupant in a room. thereIsOccupantInRoom: Evaluate if there is one specific occupant in a room. getRoom: Get one Room Object by position. pushAgentRoom: Add one agent to a room. popAgentRoom: Remove one agent from a room. openDoor: Change the status of the door to open. closeDoor: Change the status of the door to close.
closeDoor(agent, room1, room2)[source]
Change the status of the door to close (False).
Args:
agent: Agent object which want to close the door. room1, room2: The two common rooms of the door as Room object.
createDoors()[source]

Create the doors in the grid space.

createOccupants(jsonsOccupants)[source]
Create occupants of the RoomsOccupant type.
Args:
jsonOccupants: Json of description of the occupants.
createRooms(jsonRooms)[source]
Create the rooms in the grid space.
Args:
jsonRooms: Json of description of the map plane.
createWalls()[source]

Create the walls in the grid space.

getRoom(pos)[source]
Get one Room Object by position.
Args:
pos: Position of the grid as (x,y).

Return: Room Object or False

openDoor(agent, room1, room2)[source]
Change the status of the door to open (True).
Args:
agent: Agent object which want to open the door. room1, room2: The two common rooms of the door as Room object.
popAgentRoom(agent, pos)[source]
Remove one agent from a room.
Args:
agent: Agent Object pos: Position of the grid as (x,y)
pushAgentRoom(agent, pos)[source]
Add one agent to a room.
Args:
agent: Agent Object pos: Position of the grid as (x,y)
setMap()[source]

Define the map plane distribution.

step()[source]

Main step of the simulation, execution of the scheduler steps.

thereIsClosedDoor(beforePos, nextPos)[source]
Check if one door is closed or open.
Args:
beforePos, nextPos: The two common positions of the door as (x, y).

Return: True (closed) or False (opened).

thereIsOccupantInRoom(room, agent)[source]
Evaluate if there is one specific occupant in a room.
Args:
room: Room object to be checked.

Return: True (yes), False (no)

thereIsOtherOccupantInRoom(room, agent)[source]
Evaluate if there is another occupant apart of the past as a parameter in a room.
Args:
room: Room object to be checked. agent: Occupant object to be ignored.

Return: True (yes), False (no)

thereIsSomeOccupantInRoom(room)[source]
Evaluate if there is any occupant in a room.
Args:
room: Room object to be checked.

Return: True (yes), False (no)

Time Control

class soba.models.timeControl.Time(model, timeByStep=60, day=1, hour=7, minute=50, seg=0, microsecond=0)[source]

Class that inherits of the Agent class to manage the time in sexagesimal units.

Attributes:
clock: Clock for time monitoring during simulation. timeByStep: Time in seconds associated with each step. startDay: Time of the beginning of a day in the simulation. endDay: Time of the end of a day in the simulation.
Methods:
step: Advance of the clock in a step. increaseTime: Increase the value of the clock a given time. decreaseTime: Decrease the value of the clock a given time.
decreaseTime(days=0, hours=0, minutes=0, seconds=0, microseconds=0)[source]
Decrease the value of the clock a given time.
Args:
seconds, days, hours, minutes, microseconds: Time value to be decrease.

Return: The new Clock object.

increaseTime(seconds=0, days=0, hours=0, minutes=0, microseconds=0)[source]
Increase the value of the clock a given time.
Args:
seconds, days, hours, minutes, microseconds: Time value to be increase.

Return: The new Clock object.

step()[source]

Advance of the clock in a step.