rog_rl package¶
Submodules¶
rog_rl.agent module¶
-
class
rog_rl.agent.
DiseaseSimAgent
(unique_id, model, prob_agent_movement=0.0, moore=True)[source]¶ Bases:
mesa.agent.Agent
-
moore
= True¶
-
move_to
(new_position)[source]¶ Move the agent to a new location on the grid and do other associated house keeping tasks
- Update global observation in model
-
pos
= None¶
-
prob_agent_movement
= 0.0¶
-
rog_rl.agent_event module¶
rog_rl.agent_state module¶
rog_rl.benchmark module¶
rog_rl.cli module¶
Console script for rog_rl.
rog_rl.colors module¶
-
class
rog_rl.colors.
ANSI_COLOR_MAP
[source]¶ Bases:
object
-
BACK_BLACK
= '\x1b[40m'¶
-
BACK_BLUE
= '\x1b[44m'¶
-
BACK_CYAN
= '\x1b[46m'¶
-
BACK_GREEN
= '\x1b[42m'¶
-
BACK_MAGENTA
= '\x1b[45m'¶
-
BACK_RED
= '\x1b[41m'¶
-
BACK_RESET
= '\x1b[49m'¶
-
BACK_WHITE
= '\x1b[47m'¶
-
BACK_YELLOW
= '\x1b[43m'¶
-
FORE_BLACK
= '\x1b[30m'¶
-
FORE_BLUE
= '\x1b[34m'¶
-
FORE_CYAN
= '\x1b[36m'¶
-
FORE_GREEN
= '\x1b[32m'¶
-
FORE_MAGENTA
= '\x1b[35m'¶
-
FORE_RED
= '\x1b[31m'¶
-
FORE_RESET
= '\x1b[39m'¶
-
FORE_WHITE
= '\x1b[37m'¶
-
FORE_YELLOW
= '\x1b[33m'¶
-
-
class
rog_rl.colors.
Colors
[source]¶ Bases:
object
Reference : https://materialuicolors.co/ # Level : 600
Can potentially use : https://github.com/secretBiology/SecretColors/
-
AMBER
= (255, 179, 0)¶
-
BLUE
= (30, 136, 229)¶
-
BLUE_GREY
= (84, 110, 122)¶
-
BROWN
= (109, 76, 65)¶
-
CYAN
= (0, 172, 193)¶
-
DEEP_ORANGE
= (244, 81, 30)¶
-
DEEP_PURPLE
= (94, 53, 177)¶
-
GREEN
= (67, 160, 71)¶
-
GREY
= (117, 117, 117)¶
-
INDIGO
= (57, 73, 171)¶
-
LIGHT_BLUE
= (3, 155, 229)¶
-
LIGHT_GREEN
= (124, 179, 66)¶
-
LIGHT_GREY
= (234, 237, 237)¶
-
LIME
= (192, 202, 51)¶
-
ORANGE
= (251, 140, 0)¶
-
PINK
= (216, 27, 96)¶
-
PURPLE
= (142, 36, 170)¶
-
RED
= (229, 57, 53)¶
-
TEAL
= (0, 137, 123)¶
-
WHITE
= (255, 255, 255)¶
-
YELLOW
= (253, 216, 53)¶
-
rog_rl.contact_network module¶
rog_rl.disease_planner module¶
-
class
rog_rl.disease_planner.
DiseasePlannerBase
(random=False)[source]¶ Bases:
object
This class plans the schedule of different state transitions for a disease
-
class
rog_rl.disease_planner.
SEIRDiseasePlanner
(latent_period_mu=8, latent_period_sigma=4, incubation_period_mu=20, incubation_period_sigma=12, recovery_period_mu=56, recovery_period_sigma=4, random=False)[source]¶ Bases:
rog_rl.disease_planner.DiseasePlannerBase
This class plans the schedule of different state transitions for a disease
-
class
rog_rl.disease_planner.
SimpleSEIRDiseasePlanner
(latent_period=2, incubation_period=5, recovery_period=14, random=False)[source]¶ Bases:
rog_rl.disease_planner.SEIRDiseasePlanner
This class plans the schedule of different state transitions for a disease
rog_rl.env module¶
-
class
rog_rl.env.
RogSimEnv
(config={})[source]¶ Bases:
gym.core.Env
-
close
()[source]¶ Override close in your subclass to perform any necessary cleanup.
Environments will automatically close() themselves when garbage collected or when the program exits.
-
dummy_env_step
()[source]¶ Implements a fake env.step for faster Integration Testing with RL experiments framework
-
get_current_game_metrics
(dummy_simulation=False)[source]¶ Returns a dictionary containing important game metrics
-
get_current_game_score
()[source]¶ Returns the current game score
- The game score is currently represented as :
- (percentage of susceptibles left in the population)
-
render
(mode='human')[source]¶ This methods provides the option to render the environment’s behavior to a window which should be readable to the human eye if mode is set to ‘human’.
-
reset
()[source]¶ Resets the environment to an initial state and returns an initial observation.
Note that this function should not reset the environment’s random number generator(s); random variables in the environment’s state should be sampled independently between multiple calls to reset(). In other words, each call of reset() should yield an environment suitable for a new episode, independent of previous episodes.
- Returns:
- observation (object): the initial observation.
-
seed
(seed=None)[source]¶ Sets the seed for this env’s random number generator(s).
- Note:
- Some environments use multiple pseudorandom number generators. We want to capture all such seeds used in order to ensure that there aren’t accidental correlations between multiple generators.
- Returns:
- list<bigint>: Returns the list of seeds used in this env’s random
- number generators. The first value in the list should be the “main” seed, or the value which a reproducer should pass to ‘seed’. Often, the main seed equals the provided ‘seed’, but this won’t be true if seed=None, for example.
-
step
(action)[source]¶ Run one timestep of the environment’s dynamics. When end of episode is reached, you are responsible for calling reset() to reset this environment’s state.
Accepts an action and returns a tuple (observation, reward, done, info).
- Args:
- action (object): an action provided by the agent
- Returns:
- observation (object): agent’s observation of the current environment reward (float) : amount of reward returned after previous action done (bool): whether the episode has ended, in which case further step() calls will return undefined results info (dict): contains auxiliary diagnostic information (helpful for debugging, and sometimes learning)
-
rog_rl.model module¶
-
class
rog_rl.model.
DiseaseSimModel
(width=50, height=50, population_density=0.75, vaccine_density=0, initial_infection_fraction=0.1, initial_vaccination_fraction=0.0, prob_infection=0.2, prob_agent_movement=0.0, disease_planner_config={'incubation_period_mu': 20, 'incubation_period_sigma': 0, 'latent_period_mu': 8, 'latent_period_sigma': 0, 'recovery_period_mu': 56, 'recovery_period_sigma': 0}, max_timesteps=200, early_stopping_patience=14, toric=True, seed=None)[source]¶ Bases:
mesa.model.Model
The model class holds the model-level attributes, manages the agents, and generally handles the global level of our model.
There is only one model-level parameter: how many agents the model contains. When a new model is started, we want it to populate itself with the given number of agents.
The scheduler is a special model component which controls the order in which agents are activated.
-
initialize_agents
(infection_fraction, vaccination_fraction)[source]¶ Intializes the intial agents on the grid
-
initialize_disease_planner
()[source]¶ Initializes a disease planner that the Agents can use to “schedule” infection progressions
-
initialize_observation
()[source]¶ Observation is a nd-array of shape (width, height, num_states) where each AgentState will be marked in a separate challenge for each of the cells
-
simulation_completion_checks
()[source]¶ - Simulation is complete if :
- if the timesteps have exceeded the number of max_timesteps
or - the fraction of susceptible population is <= 0 or - the fraction of susceptible population has not changed since the last N timesteps
-
rog_rl.renderer module¶
-
class
rog_rl.renderer.
Renderer
(grid_size=(30, 30))[source]¶ Bases:
object
-
post_render
(return_rgb_array=False)[source]¶ Some part of the code is taken from the file https://github.com/openai/gym/blob/master/gym/envs/classic_control/rendering.py The render method of class viewer clears the window. This also results in any text on the screen to be lost Hence we copy the contents of the render function and modify it
-
rog_rl.scheduler module¶
-
class
rog_rl.scheduler.
CustomScheduler
(model: mesa.model.Model)[source]¶ Bases:
mesa.time.RandomActivation
-
add
(agent: mesa.agent.Agent) → None[source]¶ Add an Agent object to the schedule.
- Args:
- agent: An Agent to be added to the schedule. NOTE: The agent must have a step() method.
-
get_agent_count_by_state
(state: rog_rl.agent_state.AgentState) → int[source]¶ Returns the current number of agents in a particular state.
-
get_agent_fraction_by_state
(state: rog_rl.agent_state.AgentState) → int[source]¶ Returns the current number of agents in a particular state.
-
rog_rl.server module¶
Configure visualization elements and instantiate a server
rog_rl.vaccination_response module¶
rog_rl.visualization module¶
Module contents¶
Top-level package for Rog RL.