Skip to content

Commit

Permalink
updated transit pass subsidy model
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekyadav26 committed Oct 24, 2023
1 parent fbcc9a1 commit 372da21
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 21 additions & 5 deletions activitysim/abm/models/transit_pass_subsidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,38 @@
tracing,
workflow,
)
from activitysim.core.configuration.base import PreprocessorSettings, PydanticReadable
from activitysim.core.configuration.logit import LogitComponentSettings

logger = logging.getLogger("activitysim")


class TransitPassSubsidySettings(LogitComponentSettings, extra="forbid"):
"""
Settings for the `transit_pass_subsidy` component.
"""

preprocessor: PreprocessorSettings | None = None
"""Setting for the preprocessor."""


@workflow.step
def transit_pass_subsidy(
state: workflow.State,
persons_merged: pd.DataFrame,
persons: pd.DataFrame,
model_settings: TransitPassSubsidySettings | None = None,
model_settings_file_name: str = "transit_pass_subsidy.yaml",
trace_label: str = "transit_pass_subsidy",
) -> None:
"""
Transit pass subsidy model.
"""

trace_label = "transit_pass_subsidy"
model_settings_file_name = "transit_pass_subsidy.yaml"
if model_settings is None:
model_settings = TransitPassSubsidySettings.read_settings_file(
state.filesystem,
model_settings_file_name,
)

choosers = persons_merged
logger.info("Running %s with %d persons", trace_label, len(choosers))
Expand All @@ -40,7 +56,7 @@ def transit_pass_subsidy(
constants = config.get_model_constants(model_settings)

# - preprocessor
preprocessor_settings = model_settings.get("preprocessor", None)
preprocessor_settings = model_settings.preprocessor
if preprocessor_settings:
locals_d = {}
if constants is not None:
Expand All @@ -54,7 +70,7 @@ def transit_pass_subsidy(
trace_label=trace_label,
)

model_spec = state.filesystem.read_model_spec(file_name=model_settings["SPEC"])
model_spec = state.filesystem.read_model_spec(model_settings.SPEC)
coefficients_df = state.filesystem.read_model_coefficients(model_settings)
model_spec = simulate.eval_coefficients(
state, model_spec, coefficients_df, estimator
Expand Down
2 changes: 1 addition & 1 deletion activitysim/abm/models/work_from_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class WorkFromHomeSettings(LogitComponentSettings, extra="forbid"):

preprocessor: PreprocessorSettings | None = None
WORK_FROM_HOME_ALT: int
WORK_FROM_HOME_ITERATIONS: int
WORK_FROM_HOME_ITERATIONS: int | None = None
CHOOSER_FILTER_COLUMN_NAME: str = "is_worker"
WORK_FROM_HOME_CHOOSER_FILTER: str = None
WORK_FROM_HOME_COEFFICIENT_CONSTANT: float = None
Expand Down

0 comments on commit 372da21

Please sign in to comment.