Skip to content

Commit

Permalink
Merge pull request #9 from camsys/wfh_zone_setting
Browse files Browse the repository at this point in the history
Work From Home & MWCOG extensions
  • Loading branch information
jpn-- authored Jan 27, 2023
2 parents 27429d0 + 9133c2e commit 5eebf18
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 372 deletions.
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

0 comments on commit 5eebf18

Please sign in to comment.