-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'verification-fixes' of https://github.com/ActivitySim/a…
…ctivitysim into verification-fixes
- Loading branch information
Showing
43 changed files
with
288 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# ActivitySim | ||
# See full license in LICENSE.txt. | ||
|
||
from __future__ import (absolute_import, division, print_function, ) | ||
from future.standard_library import install_aliases | ||
install_aliases() # noqa: E402 | ||
|
||
from future.utils import iteritems | ||
|
||
import logging | ||
|
||
import pandas as pd | ||
|
||
from activitysim.core import tracing | ||
from activitysim.core import config | ||
from activitysim.core import pipeline | ||
from activitysim.core import simulate | ||
from activitysim.core import inject | ||
from activitysim.core.mem import force_garbage_collect | ||
|
||
from activitysim.core.interaction_sample_simulate import interaction_sample_simulate | ||
from activitysim.core.interaction_sample import interaction_sample | ||
|
||
from .util import expressions | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@inject.step() | ||
def free_parking( | ||
persons_merged, persons, households, | ||
skim_dict, skim_stack, | ||
chunk_size, trace_hh_id, locutor): | ||
""" | ||
""" | ||
|
||
trace_label = 'free_parking' | ||
model_settings = config.read_model_settings('free_parking.yaml') | ||
|
||
choosers = persons_merged.to_frame() | ||
choosers = choosers[choosers.workplace_taz > -1] | ||
|
||
logger.info("Running %s with %d persons", trace_label, len(choosers)) | ||
|
||
constants = config.get_model_constants(model_settings) | ||
|
||
# - preprocessor | ||
preprocessor_settings = model_settings.get('preprocessor', None) | ||
if preprocessor_settings: | ||
|
||
locals_d = {} | ||
if constants is not None: | ||
locals_d.update(constants) | ||
|
||
expressions.assign_columns( | ||
df=choosers, | ||
model_settings=preprocessor_settings, | ||
locals_dict=locals_d, | ||
trace_label=trace_label) | ||
|
||
model_spec = simulate.read_model_spec(file_name='free_parking.csv') | ||
nest_spec = config.get_logit_model_settings(model_settings) | ||
|
||
choices = simulate.simple_simulate( | ||
choosers=choosers, | ||
spec=model_spec, | ||
nest_spec=nest_spec, | ||
locals_d=constants, | ||
chunk_size=chunk_size, | ||
trace_label=trace_label, | ||
trace_choice_name='free_parking_at_work') | ||
|
||
persons = persons.to_frame() | ||
|
||
# no need to reindex as we used all households | ||
free_parking_alt = model_settings['FREE_PARKING_ALT'] | ||
choices = (choices == free_parking_alt) | ||
persons['free_parking_at_work'] = choices.reindex(persons.index).fillna(0).astype(bool) | ||
|
||
pipeline.replace_table("persons", persons) | ||
|
||
tracing.print_summary('free_parking', persons.free_parking_at_work, value_counts=True) | ||
|
||
if trace_hh_id: | ||
tracing.trace_df(persons, | ||
label=trace_label, | ||
warn_if_empty=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Description,Expression,free,pay | ||
,@df.workplace_county_id == ID_SAN_FRANCISCO,-2.6403, | ||
,@df.workplace_county_id == ID_SANTA_CLARA,0.2118, | ||
,@df.workplace_county_id == ID_ALAMEDA,-0.1092, | ||
Very high income household dummy,@df.income>=100000,0.2300, | ||
High income housheold dummy,@(df.income>=60000) & (df.income<100000),0.2300, | ||
Household size is greater than 3 dummy,@df.hhsize>3,0.2530, | ||
More automobiles than workers dummy,@df.auto_ownership>df.num_workers,0.2310, | ||
Fewer automobiles than workers dummy,@df.auto_ownership<df.num_workers,-1.4790, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#LOGIT_TYPE: NL | ||
LOGIT_TYPE: MNL | ||
|
||
FREE_PARKING_ALT: 0 | ||
|
||
CONSTANTS: | ||
ID_SAN_FRANCISCO: 1 | ||
ID_SAN_MATEO: 2 | ||
ID_SANTA_CLARA: 3 | ||
ID_ALAMEDA: 4 | ||
ID_CONTRA_COSTA: 5 | ||
ID_SOLANO: 6 | ||
ID_NAPA: 7 | ||
ID_SONOMA: 8 | ||
ID_MARIN: 9 | ||
|
||
preprocessor: | ||
SPEC: free_parking_annotate_persons_preprocessor | ||
DF: persons | ||
TABLES: | ||
- land_use |
2 changes: 2 additions & 0 deletions
2
activitysim/abm/test/configs/free_parking_annotate_persons_preprocessor.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Description,Target,Expression | ||
,workplace_county_id,"reindex(land_use.county_id, persons.workplace_taz)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.