june.policy.leisure_policies¶
-
class
june.policy.leisure_policies.
ChangeLeisureProbability
(start_time: str, end_time: str, leisure_activities_probabilities: Dict[str, Dict[str, Dict[str, float]]])¶ Changes the probability of the specified leisure activities.
start_time : starting time of the policy.
end_time : end time of the policy.
- leisure_activities_probabilitiesdictionary where the first key is an age range, and the second a
number with the new probability for the activity in that age. Example: * leisure_activities_probabilities = {“pubs” : {“men” :{“0-50” : 0.5, “50-99” : 0.2}, “women” : {“0-70” : 0.2, “71-99” : 0.8}}}
-
__init__
(start_time: str, end_time: str, leisure_activities_probabilities: Dict[str, Dict[str, Dict[str, float]]])¶ Changes the probability of the specified leisure activities.
start_time : starting time of the policy.
end_time : end time of the policy.
- leisure_activities_probabilitiesdictionary where the first key is an age range, and the second a
number with the new probability for the activity in that age. Example: * leisure_activities_probabilities = {“pubs” : {“men” :{“0-50” : 0.5, “50-99” : 0.2}, “women” : {“0-70” : 0.2, “71-99” : 0.8}}}
-
apply
(leisure: june.groups.leisure.leisure.Leisure)¶ Changes probabilities of doing leisure activities according to the policies specified. The current probabilities are stored in the policies, and restored at the end of the policy time span. Keep this in mind when trying to stack policies that modify the same social venue.
-
get_spec
() → str¶ Returns the speciailization of the policy.
-
is_active
(date: datetime.datetime) → bool¶ Returns true if the policy is active, false otherwise
- date:
date to check
-
static
read_date
(date: Union[str, datetime.datetime]) → datetime.datetime¶ Read date in two possible formats, either string or datetime.date, both are translated into datetime.datetime to be used by the simulator
- date:
date to translate into datetime.datetime
date in datetime format
-
_abc_impl
= <_abc_data object>¶
-
class
june.policy.leisure_policies.
CloseLeisureVenue
(start_time: Union[str, datetime.datetime], end_time: Union[str, datetime.datetime], venues_to_close='cinemas', 'groceries')¶ Template for policies that will close types of leisure venues
- start_time:
date at which to start applying the policy
- end_time:
date from which the policy won’t apply
- venues_to_close:
list of leisure venues that will close
-
__init__
(start_time: Union[str, datetime.datetime], end_time: Union[str, datetime.datetime], venues_to_close='cinemas', 'groceries')¶ Template for policies that will close types of leisure venues
- start_time:
date at which to start applying the policy
- end_time:
date from which the policy won’t apply
- venues_to_close:
list of leisure venues that will close
-
apply
(leisure: june.groups.leisure.leisure.Leisure)¶
-
get_spec
() → str¶ Returns the speciailization of the policy.
-
is_active
(date: datetime.datetime) → bool¶ Returns true if the policy is active, false otherwise
- date:
date to check
-
static
read_date
(date: Union[str, datetime.datetime]) → datetime.datetime¶ Read date in two possible formats, either string or datetime.date, both are translated into datetime.datetime to be used by the simulator
- date:
date to translate into datetime.datetime
date in datetime format
-
_abc_impl
= <_abc_data object>¶
-
class
june.policy.leisure_policies.
LeisurePolicies
(policies: List[june.policy.policy.Policy])¶ A collection of like policies active on the same date
-
__init__
(policies: List[june.policy.policy.Policy])¶ A collection of like policies active on the same date
-
apply
(date: <module 'datetime' from '/home/sadie/anaconda3/envs/june/lib/python3.8/datetime.py'>, leisure: june.groups.leisure.leisure.Leisure)¶ Applies leisure policies. There are currently two types of leisure policies implemented: CloseLeisureVenue, and ChangeLeisureProbability. To ensure compatibility when adding multiple policies of the same type, we “clear” the leisure module at the beginning of each application, ie, we set closed_venues = set(), and the original probabilities for each social venue distributor. We then apply the policies currently active at the given date.
-
classmethod
from_policies
(policies: june.policy.policy.Policies)¶
-
get_active
(date: <module 'datetime' from '/home/sadie/anaconda3/envs/june/lib/python3.8/datetime.py'>)¶
-
original_leisure_probabilities_per_venue
= None¶
-
policy_type
= 'leisure'¶
-
-
class
june.policy.leisure_policies.
LeisurePolicy
(start_time: Union[str, datetime.datetime], end_time: Union[str, datetime.datetime])¶ Template for a general policy.
- start_time:
date at which to start applying the policy
- end_time:
date from which the policy won’t apply
-
__init__
(start_time: Union[str, datetime.datetime], end_time: Union[str, datetime.datetime])¶ Template for a general policy.
- start_time:
date at which to start applying the policy
- end_time:
date from which the policy won’t apply
-
get_spec
() → str¶ Returns the speciailization of the policy.
-
is_active
(date: datetime.datetime) → bool¶ Returns true if the policy is active, false otherwise
- date:
date to check
-
static
read_date
(date: Union[str, datetime.datetime]) → datetime.datetime¶ Read date in two possible formats, either string or datetime.date, both are translated into datetime.datetime to be used by the simulator
- date:
date to translate into datetime.datetime
date in datetime format
-
_abc_impl
= <_abc_data object>¶