slim.simulation.organisation module
This module provides the main entry point to any simulation task.
- class slim.simulation.organisation.Organisation(cfg: Config, *args, **kwargs)
Bases:
objectAn organisation is a cooperative of
farm.Farms. At every time step farms handle the population update logic and produce a number of offspring, which the Organisation is supposed to handle.Furthermore, farms regularly send messages to their farms about their statuses. An organisation can recommend farms to apply treatment if one of those has surpassed critical levels (see
handle_farm_messages()).Ultimately, farm updates are used to recompute the external pressure.
- Parameters
cfg – a Configuration
*args – other constructing parameters passed to the underlying
farm.Farms.ray_address – if using multiprocessing, pass the address to ray
ray_redis_password – if using multiprocessing, pass the redis password to ray.
- get_external_pressure() Tuple[int, GenoRates]
Get the external pressure. Callers of this function should then invoke some distribution to sample the obtained number of lice that respects the probabilities.
For example:
>>> org = Organisation(...) >>> n, p = org.get_external_pressure() >>> new_lice = lice_population.from_ratios(p, n)
- Returns
a pair (number of new lice from reservoir, the ratios to sample from)
- property get_gym_space
- reset()
- step(cur_date: dt.datetime, actions: SAMPLED_ACTIONS) Tuple[Dict[int, float], Dict[str, Any]]
Perform an update across all farms. After that, some offspring will be distributed into the farms while others will be dispersed into the reservoir, thus changing the global external pressure.
- Parameters
cur_date – the current date
actions – if given pass the action to the policy.
- Returns
the cumulated reward from all the farm updates, and logs generated by all the farms
- stop()
- to_json_dict()
- update_genetic_ratios(offspring: GenoDistrib)
Update the genetic ratios after an offspring update.
- Parameters
offspring – the offspring update
- update_offspring_average(offspring_per_farm: Dict[int, GenoDistrib])