diff --git a/activitysim/abm/models/joint_tour_destination.py b/activitysim/abm/models/joint_tour_destination.py index e10fa2c34..8e7c940db 100644 --- a/activitysim/abm/models/joint_tour_destination.py +++ b/activitysim/abm/models/joint_tour_destination.py @@ -326,8 +326,8 @@ def joint_tour_destination( person that's making the tour) """ - trace_label = 'non_mandatory_tour_destination' - model_settings_file_name = 'non_mandatory_tour_destination.yaml' + trace_label = 'joint_tour_destination' + model_settings_file_name = 'joint_tour_destination.yaml' model_settings = config.read_model_settings(model_settings_file_name) logsum_column_name = model_settings.get('DEST_CHOICE_LOGSUM_COLUMN_NAME') diff --git a/activitysim/abm/models/util/vectorize_tour_scheduling.py b/activitysim/abm/models/util/vectorize_tour_scheduling.py index bd0eee021..f71e45b24 100644 --- a/activitysim/abm/models/util/vectorize_tour_scheduling.py +++ b/activitysim/abm/models/util/vectorize_tour_scheduling.py @@ -76,6 +76,10 @@ def _compute_logsums(alt_tdd, tours_merged, tour_purpose, model_settings, trace_ locals_dict.update(constants) locals_dict.update(skims) + # constrained coefficients can appear in expressions + coefficients = simulate.get_segment_coefficients(logsum_settings, tour_purpose) + locals_dict.update(coefficients) + # - run preprocessor to annotate choosers # allow specification of alternate preprocessor for nontour choosers preprocessor = model_settings.get('LOGSUM_PREPROCESSOR', 'preprocessor') @@ -92,17 +96,12 @@ def _compute_logsums(alt_tdd, tours_merged, tour_purpose, model_settings, trace_ trace_label=trace_label) # - compute logsums - - coefficients = simulate.get_segment_coefficients(logsum_settings, tour_purpose) logsum_spec = simulate.read_model_spec(file_name=logsum_settings['SPEC']) logsum_spec = simulate.eval_coefficients(logsum_spec, coefficients, estimator=None) nest_spec = config.get_logit_model_settings(logsum_settings) nest_spec = simulate.eval_nest_coefficients(nest_spec, coefficients) - # constrained coefficients can appear in expressions - locals_dict.update(coefficients) - logsums = simulate.simple_simulate_logsums( choosers, logsum_spec, diff --git a/activitysim/core/simulate.py b/activitysim/core/simulate.py index 9e8af50df..cb8fc6494 100644 --- a/activitysim/core/simulate.py +++ b/activitysim/core/simulate.py @@ -140,7 +140,11 @@ def read_model_coefficients(model_settings=None, file_name=None): file_name = model_settings['COEFFICIENTS'] file_path = config.config_file_path(file_name) - coefficients = pd.read_csv(file_path, comment='#', index_col='coefficient_name') + try: + coefficients = pd.read_csv(file_path, comment='#', index_col='coefficient_name') + except ValueError: + logger.exception("Coefficient File Invalid: %s" % str(file_path)) + raise return coefficients @@ -188,7 +192,11 @@ def read_model_coefficient_template(model_settings): coeffs_file_name = model_settings['COEFFICIENT_TEMPLATE'] file_path = config.config_file_path(coeffs_file_name) - template = pd.read_csv(file_path, comment='#', index_col='coefficient_name') + try: + template = pd.read_csv(file_path, comment='#', index_col='coefficient_name') + except ValueError: + logger.exception("Coefficient Template File Invalid: %s" % str(file_path)) + raise # by convention, an empty cell in the template indicates that # the coefficient name should be propogated to across all segments diff --git a/activitysim/examples/example_mtc/configs/joint_tour_destination.yaml b/activitysim/examples/example_mtc/configs/joint_tour_destination.yaml index 36d67bc30..a9cb3fe43 100644 --- a/activitysim/examples/example_mtc/configs/joint_tour_destination.yaml +++ b/activitysim/examples/example_mtc/configs/joint_tour_destination.yaml @@ -10,13 +10,15 @@ SEGMENTS: - eatout - social - SAMPLE_SIZE: 30 +# we can't use use household income_segment as this will also be set for non-workers +CHOOSER_SEGMENT_COLUMN_NAME: tour_type + SIMULATE_CHOOSER_COLUMNS: - tour_type - TAZ - - household_id + - person_id LOGSUM_SETTINGS: tour_mode_choice.yaml diff --git a/activitysim/examples/example_mtc/configs/non_mandatory_tour_destination_coeffs.csv b/activitysim/examples/example_mtc/configs/non_mandatory_tour_destination_coeffs.csv index bf02b811f..4096d6e3a 100644 --- a/activitysim/examples/example_mtc/configs/non_mandatory_tour_destination_coeffs.csv +++ b/activitysim/examples/example_mtc/configs/non_mandatory_tour_destination_coeffs.csv @@ -3,7 +3,7 @@ coef_mode_logsum,0.6755,F coef_escort_dist_0_2,-0.1499,F coef_eatout_dist_0_2,-0.5609,F coef_eatout_social_0_2,-0.5609,F -coef_eatout_dist_0_2,-0.7841,F +#coef_eatout_dist_0_2,-0.7841,F coef_othdiscr_dist_0_2,-0.1677,F coef_escort_dist_2_5,-0.8671,F coef_shopping_dist_2_5,-0.5655,F