Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work From Home & MWCOG extensions #9

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion activitysim/abm/models/work_from_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ def work_from_home(persons_merged, persons, chunk_size, trace_hh_id):
"""
This model predicts whether a person (worker) works from home. The output
from this model is TRUE (if works from home) or FALSE (works away from home).
The workplace location choice is overridden for workers who work from home
and set to -1.
"""

trace_label = "work_from_home"
model_settings_file_name = "work_from_home.yaml"

choosers = persons_merged.to_frame()
model_settings = config.read_model_settings(model_settings_file_name)
chooser_filter_column_name = model_settings.get("CHOOSER_FILTER_COLUMN_NAME")
chooser_filter_column_name = model_settings.get(
"CHOOSER_FILTER_COLUMN_NAME", "is_worker"
)
choosers = choosers[choosers[chooser_filter_column_name]]
logger.info("Running %s with %d persons", trace_label, len(choosers))

Expand Down Expand Up @@ -154,6 +158,17 @@ def work_from_home(persons_merged, persons, chunk_size, trace_hh_id):
persons[chooser_filter_column_name] & ~persons["work_from_home"]
)

# setting workplace_zone_id to -1 if person works from home
# this will exclude them from the telecommute frequency model choosers
# See https://github.com/ActivitySim/activitysim/issues/627
dest_choice_column_name = model_settings.get(
"DEST_CHOICE_COLUMN_NAME", "workplace_zone_id"
)
if dest_choice_column_name in persons.columns:
persons[dest_choice_column_name] = np.where(
persons.work_from_home == True, -1, persons[dest_choice_column_name]
)

pipeline.replace_table("persons", persons)

tracing.print_summary("work_from_home", persons.work_from_home, value_counts=True)
Expand Down
5 changes: 5 additions & 0 deletions activitysim/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,11 @@ def filter_warnings():
".*object-dtype columns with all-bool values will not be included in reductions.*"
),
)
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=".*will attempt to set the values inplace instead of always setting a new array.*",
)

# beginning in sharrow version 2.5, a CacheMissWarning is emitted when a sharrow
# flow cannot be loaded from cache and needs to be compiled. These are performance
Expand Down
4 changes: 0 additions & 4 deletions activitysim/examples/prototype_mwcog/extensions/__init__.py

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading