|
16 | 16 |
|
17 | 17 |
|
18 | 18 | @orca.injectable() |
19 | | -def mode_choice_settings(configs_dir): |
| 19 | +def tour_mode_choice_settings(configs_dir): |
20 | 20 | with open(os.path.join(configs_dir, |
21 | 21 | "configs", |
22 | 22 | "tour_mode_choice.yaml")) as f: |
23 | 23 | return yaml.load(f) |
24 | 24 |
|
25 | 25 |
|
26 | 26 | @orca.injectable() |
27 | | -def mode_choice_spec_df(configs_dir): |
| 27 | +def tour_mode_choice_spec_df(configs_dir): |
28 | 28 | with open(os.path.join(configs_dir, |
29 | 29 | "configs", |
30 | 30 | "tour_mode_choice.csv")) as f: |
31 | 31 | return asim.read_model_spec(f) |
32 | 32 |
|
33 | 33 |
|
34 | 34 | @orca.injectable() |
35 | | -def mode_choice_coeffs(configs_dir): |
| 35 | +def tour_mode_choice_coeffs(configs_dir): |
36 | 36 | with open(os.path.join(configs_dir, |
37 | 37 | "configs", |
38 | 38 | "tour_mode_choice_coeffs.csv")) as f: |
39 | 39 | return pd.read_csv(f, index_col='Expression') |
40 | 40 |
|
41 | 41 |
|
42 | 42 | @orca.injectable() |
43 | | -def mode_choice_spec(mode_choice_spec_df, mode_choice_coeffs, |
44 | | - mode_choice_settings): |
45 | | - return _mode_choice_spec(mode_choice_spec_df, mode_choice_coeffs, |
46 | | - mode_choice_settings) |
| 43 | +def tour_mode_choice_spec(tour_mode_choice_spec_df, |
| 44 | + tour_mode_choice_coeffs, |
| 45 | + tour_mode_choice_settings): |
| 46 | + return _mode_choice_spec(tour_mode_choice_spec_df, |
| 47 | + tour_mode_choice_coeffs, |
| 48 | + tour_mode_choice_settings) |
| 49 | + |
| 50 | + |
| 51 | +@orca.injectable() |
| 52 | +def trip_mode_choice_settings(configs_dir): |
| 53 | + with open(os.path.join(configs_dir, |
| 54 | + "configs", |
| 55 | + "trip_mode_choice.yaml")) as f: |
| 56 | + return yaml.load(f) |
| 57 | + |
| 58 | + |
| 59 | +@orca.injectable() |
| 60 | +def trip_mode_choice_spec_df(configs_dir): |
| 61 | + with open(os.path.join(configs_dir, |
| 62 | + "configs", |
| 63 | + "trip_mode_choice.csv")) as f: |
| 64 | + return asim.read_model_spec(f) |
| 65 | + |
| 66 | + |
| 67 | +@orca.injectable() |
| 68 | +def trip_mode_choice_coeffs(configs_dir): |
| 69 | + with open(os.path.join(configs_dir, |
| 70 | + "configs", |
| 71 | + "trip_mode_choice_coeffs.csv")) as f: |
| 72 | + return pd.read_csv(f, index_col='Expression') |
| 73 | + |
| 74 | + |
| 75 | +@orca.injectable() |
| 76 | +def trip_mode_choice_spec(trip_mode_choice_spec_df, |
| 77 | + trip_mode_choice_coeffs, |
| 78 | + trip_mode_choice_settings): |
| 79 | + return _mode_choice_spec(trip_mode_choice_spec_df, |
| 80 | + trip_mode_choice_coeffs, |
| 81 | + trip_mode_choice_settings) |
47 | 82 |
|
48 | 83 |
|
49 | 84 | def _mode_choice_simulate(tours, skims, spec, additional_constants, omx=None): |
@@ -100,22 +135,43 @@ def get_segment_and_unstack(spec, segment): |
100 | 135 |
|
101 | 136 |
|
102 | 137 | @orca.step() |
103 | | -def mode_choice_simulate(tours_merged, |
104 | | - mode_choice_spec, |
105 | | - mode_choice_settings, |
106 | | - skims, omx_file): |
| 138 | +def tour_mode_choice_simulate(tours_merged, |
| 139 | + tour_mode_choice_spec, |
| 140 | + tour_mode_choice_settings, |
| 141 | + skims, omx_file): |
107 | 142 |
|
108 | 143 | tours = tours_merged.to_frame() |
109 | 144 |
|
110 | | - print mode_choice_spec.eatout |
111 | | - |
112 | 145 | # FIXME this only runs eatout |
113 | 146 | choices = _mode_choice_simulate( |
114 | 147 | tours[tours.tour_type == "eatout"], |
115 | 148 | skims, |
116 | | - get_segment_and_unstack(mode_choice_spec, 'eatout'), |
117 | | - mode_choice_settings['CONSTANTS'], |
| 149 | + get_segment_and_unstack(tour_mode_choice_spec, 'eatout'), |
| 150 | + tour_mode_choice_settings['CONSTANTS'], |
118 | 151 | omx=omx_file) |
119 | 152 |
|
120 | 153 | print "Choices:\n", choices.value_counts() |
121 | 154 | orca.add_column("tours", "mode", choices) |
| 155 | + |
| 156 | + |
| 157 | +@orca.step() |
| 158 | +def trip_mode_choice_simulate(tours_merged, |
| 159 | + trip_mode_choice_spec, |
| 160 | + trip_mode_choice_settings, |
| 161 | + skims, omx_file): |
| 162 | + |
| 163 | + # FIXME running the trips model on tours |
| 164 | + trips = tours_merged.to_frame() |
| 165 | + |
| 166 | + print trip_mode_choice_spec.eatout |
| 167 | + |
| 168 | + # FIXME this only runs eatout |
| 169 | + choices = _mode_choice_simulate( |
| 170 | + trips[trips.tour_type == "eatout"], |
| 171 | + skims, |
| 172 | + get_segment_and_unstack(trip_mode_choice_spec, 'eatout'), |
| 173 | + trip_mode_choice_settings['CONSTANTS'], |
| 174 | + omx=omx_file) |
| 175 | + |
| 176 | + print "Choices:\n", choices.value_counts() |
| 177 | + orca.add_column("trips", "mode", choices) |
0 commit comments