pam.policy.modifiers
AddActivity(activities)
#
Modifier()
#
Bases: ABC
Base class for modifiers - these are classes which change activities in a person's plan.
In general a modifer should be able to be applied on three levels Household - apply change to all activities in all person's plans in household Person - apply change to all activities in a person's plan Activity - apply change to individual activity in a person's plan
Not all modifiers will satisfy this of course, e.g. ReduceSharedActivity only works on a household level as the activites for removal need to be shared within a household.
apply_to(household, person=None, activities=None)
abstractmethod
#
Uses self.probability to decide if household/person/activity should be selected.
PARAMETER | DESCRIPTION |
---|---|
household |
TYPE:
|
person |
Defaults to None.
TYPE:
|
activities |
Defaults to None. |
Source code in pam/policy/modifiers.py
MoveActivityTourToHomeLocation(activities, location='home', new_mode='walk')
#
Bases: Modifier
Moves a tour of activities to home location.
A tour is defined as a list of activities sandwiched between two home activities.
PARAMETER | DESCRIPTION |
---|---|
activities |
List of activities to be considered in a tour. Any combination of activities in activities sandwiched by home activities will be selected Does not require an exact match. E.g. if passed ['shop_food', 'shop_other'] if a person has a tour of only 'shop_food', the location of that activity will be changed. |
location |
Location to which the tour should be moved. Defaults to "home".
TYPE:
|
new_mode |
Mode used in the legs to/from the activity when we relocate the activity. Defaults to "walk".
TYPE:
|
Source code in pam/policy/modifiers.py
activities = activities
instance-attribute
#
default = location
instance-attribute
#
new_mode = new_mode
instance-attribute
#
apply_to(household, person=None, activities=None)
#
Source code in pam/policy/modifiers.py
is_part_of_tour(act, tours)
#
matching_activity_tours(plan, p)
#
move_activities(person, p, new_mode='walk')
#
Source code in pam/policy/modifiers.py
move_household_activities(household, new_mode='walk')
#
move_individual_activities(person, activities, new_mode='walk')
#
Source code in pam/policy/modifiers.py
move_person_activities(person, new_mode='walk')
#
ReduceSharedActivity(activities)
#
Bases: Modifier
Policy that needs to be applied on a household level. For activities shared within a household (Activity.act (type of activity), start/end times and locations match). Randomly assigns a person whose activities will be retained and deletes the shared activities from other persons in household.
PARAMETER | DESCRIPTION |
---|---|
activities |
List of activities that should be considered for sharing. Does not require an exact match. E.g. if passed ['shop_food', 'shop_other'] if a household has an only 'shop_food' shared activity, that will be reduced. |
Source code in pam/policy/modifiers.py
activities = activities
instance-attribute
#
apply_to(household, person=None, activities=None)
#
Source code in pam/policy/modifiers.py
is_activity_for_removal(p)
#
people_who_share_activities_for_removal(household)
#
Source code in pam/policy/modifiers.py
remove_activities(person, shared_activities_for_removal)
#
Source code in pam/policy/modifiers.py
remove_household_activities(household)
#
Source code in pam/policy/modifiers.py
RemoveActivity(activities)
#
Bases: Modifier
Removes specified activities.
PARAMETER | DESCRIPTION |
---|---|
activities |
List of activities to be removed. |