diff --git a/example/configs/tour_departure_and_duration.csv b/example/configs/tour_departure_and_duration.csv deleted file mode 100644 index e501d097b..000000000 --- a/example/configs/tour_departure_and_duration.csv +++ /dev/null @@ -1 +0,0 @@ -Description,Expression,work Free-flow round trip auto time shift effects - departure,roundtrip_auto_time_to_work * start,0.00114 Free-flow round trip auto time shift effects - duration,roundtrip_auto_time_to_work * duration,0.00221 Part-time worker departure shift effects,(ptype == 2) * start,0.06736 Non-working adult duration shift effects,(ptype == 4) * duration,0.1207 University student departure shift effects,(ptype == 3) * start,0.05747 Household income departure shift effects,income_in_thousands * start,0.00021 Destination in CBD departure shift effects,workplace_in_cbd * start,0.04717 Destination in CBD duration shift effects,workplace_in_cbd * duration,0.08679 subsequent tour must start after previous tour ends,(start < end_of_previous_tour) & (tour_num == 2),-999 First of 2+ work tours departure shift effects,(tour_num == 1) * start,0.3033 First of 2+ work tours duration shift effects,(tour_num == 1) * duration,0.1861 Subsequent 2+ work departure tours shift effects,(tour_num == 2) * start,0.5381 Subsequent 2+ work duration tours shift effects,(tour_num == 2) * duration,0.3174 Household income -- Early departure interaction,(income_in_thousands > 100) & (start < 6),0.4854 Household income -- Late arrival interaction,(income_in_thousands > 100) & (end > 22),0.3839 Destination in CBD -- Early departure interaction,workplace_in_cbd & (start < 6),0.4566 Destination in CBD -- Late arrival interaction,workplace_in_cbd & (end > 22),0.2334 Rural household -- Early departure interaction,home_is_rural & (start < 6),0.4039 Rural household -- Late arrival interaction,home_is_rural & (end > 22),0.3451 Full-time worker -- duration < 9 hours interaction,(ptype == 1) & (duration < 9),1.257 Full-time worker -- 10 to 12 departure interaction,(ptype == 1) & (start > 9) & (start < 13),0.5182 Part-time worker -- 13 to 15 arrival interaction,(ptype == 2) & (end > 12) & (end < 16),0.5433 First of 2+ work tours- duration<8 hrs,(tour_num == 1) & (duration < 8),1.98 Subsequent of 2+ work tours- duration<8 hrs,(tour_num == 2) & (duration < 8),2.582 Work+school tours by worker- duration<8 hrs,(mandatory_tour_frequency == 'work_and_school') & is_worker & (duration < 8),0.9126 School+work tours by student- duration<8 hrs,(mandatory_tour_frequency == 'work_and_school') & is_student & (duration < 8),2.582 Mode Choice Logsum,mode_choice_logsum,1.027 Previously-scheduled tour ends in this departure hour,prev_tour_end == start,0.8935 Previously-scheduled tour begins in this arrival hour,prev_tour_begin == end,1.334 Adjacent window exists before this departure hour - first tour interaction,@@adjWindowBeforeThisHourAlt,0.1771 Adjacent window exists afetr this arrival hour - first tour interaction,@@adjWindowAfterThisHourAlt,0.3627 Adjacent window exists before this departure hour - second+ tour interaction,@@adjWindowBeforeThisHourAlt,0.2123 Adjacent window exists after this arrival hour - second+ tour interaction,@@adjWindowAfterThisHourAlt,0.1012 Remaining work/school tours to be scheduled / number of unscheduled hours,1 / @@remainingHoursAvailableAlt,18.68 Departure Constants -- Early (up to 5),start < 6,0.95273 Departure Constants -- AM peak 1 (6),start == 6,0.61618 Departure Constants -- AM peak 2 (7),start == 7,0 Departure Constants -- AM peak 3 (8),start == 8,0.25471 Departure Constants -- AM peak 4 (9),start == 9,1.25135 Departure Constants -- Midday 1 (10 to 12),(start > 9) & (start < 13),1.70587 Departure Constants -- Midday 2 (13 to 15),(start > 12) & (start < 16),1.69357 Departure Constants -- PM peak (16 to 18),(start > 15) & (start < 19),1.43999 Departure Constants -- Evening (19 to 21),(start > 18) & (start < 22),1.61051 Departure Constants -- Late (22 and later),start > 21,2.88342 Arrival Constants -- Early (up to 6),end < 7,0 Arrival Constants -- AM peak (7 to 9),(end > 6) & (end < 10),1.85452 Arrival Constants -- Midday 1 (10 to 12),(end > 9) & (end < 13),0.49597 Arrival Constants -- Midday 2 (13 to 14),(end > 12) & (end < 15),0.37855 Arrival Constants -- PM peak 1 (15),end == 15,0 Arrival Constants -- PM peak 2 (16),end == 16,0.27608 Arrival Constants -- PM peak 3 (17),end == 17,0.69959 Arrival Constants -- PM peak 4 (18),end == 18,0.79929 Arrival Constants -- Evening (19 to 21),(end > 18) & (end < 22),0.10357 Arrival Constants -- Late (22 and later),end > 21,0.96596 Duration Constants -- 0 to 2 hours,duration < 3,2.52827 Duration Constants -- 3 to 4 hours,(duration > 2) & (duration < 5),0.91897 Duration Constants -- 5 to 6 hours,(duration > 4) & (duration < 7),0.71855 Duration Constants -- 7 to 8 hours,(duration > 6) & (duration < 9),0.13962 Duration Constants -- 9 hours,duration == 9,0.05571 Duration Constants -- 10 hours,duration == 10,0 Duration Constants -- 11 hours,duration == 11,0.3478 Duration Constants -- 12 to 13 hours,(duration > 11) & (duration < 14),1.00822 Duration Constants -- 14 to 18 hours,(duration > 13) & (duration < 19),1.70186 \ No newline at end of file diff --git a/example/configs/tour_departure_and_duration_mandatory.csv b/example/configs/tour_departure_and_duration_mandatory.csv new file mode 100644 index 000000000..6a2afd916 --- /dev/null +++ b/example/configs/tour_departure_and_duration_mandatory.csv @@ -0,0 +1,64 @@ +Description,Expression,Coefficient +Free-flow round trip auto time shift effects - departure,roundtrip_auto_time_to_work * start,0.00114 +Free-flow round trip auto time shift effects - duration,roundtrip_auto_time_to_work * duration,0.00221 +Part-time worker departure shift effects,(ptype == 2) * start,0.06736 +Non-working adult duration shift effects,(ptype == 4) * duration,0.1207 +University student departure shift effects,(ptype == 3) * start,0.05747 +Household income departure shift effects,income_in_thousands * start,0.00021 +Destination in CBD departure shift effects,workplace_in_cbd * start,0.04717 +Destination in CBD duration shift effects,workplace_in_cbd * duration,0.08679 +subsequent tour must start after previous tour ends,(start < end_of_previous_tour) & (tour_num == 2),-999 +First of 2+ work tours departure shift effects,(tour_num == 1) * start,0.3033 +First of 2+ work tours duration shift effects,(tour_num == 1) * duration,0.1861 +Subsequent 2+ work departure tours shift effects,(tour_num == 2) * start,0.5381 +Subsequent 2+ work duration tours shift effects,(tour_num == 2) * duration,0.3174 +Household income -- Early departure interaction,(income_in_thousands > 100) & (start < 6),0.4854 +Household income -- Late arrival interaction,(income_in_thousands > 100) & (end > 22),0.3839 +Destination in CBD -- Early departure interaction,workplace_in_cbd & (start < 6),0.4566 +Destination in CBD -- Late arrival interaction,workplace_in_cbd & (end > 22),0.2334 +Rural household -- Early departure interaction,home_is_rural & (start < 6),0.4039 +Rural household -- Late arrival interaction,home_is_rural & (end > 22),0.3451 +Full-time worker -- duration < 9 hours interaction,(ptype == 1) & (duration < 9),1.257 +Full-time worker -- 10 to 12 departure interaction,(ptype == 1) & (start > 9) & (start < 13),0.5182 +Part-time worker -- 13 to 15 arrival interaction,(ptype == 2) & (end > 12) & (end < 16),0.5433 +First of 2+ work tours- duration<8 hrs,(tour_num == 1) & (duration < 8),1.98 +Subsequent of 2+ work tours- duration<8 hrs,(tour_num == 2) & (duration < 8),2.582 +Work+school tours by worker- duration<8 hrs,(mandatory_tour_frequency == 'work_and_school') & is_worker & (duration < 8),0.9126 +School+work tours by student- duration<8 hrs,(mandatory_tour_frequency == 'work_and_school') & is_student & (duration < 8),2.582 +Mode Choice Logsum,mode_choice_logsum,1.027 +Previously-scheduled tour ends in this departure hour,prev_tour_end == start,0.8935 +Previously-scheduled tour begins in this arrival hour,prev_tour_begin == end,1.334 +Adjacent window exists before this departure hour - first tour interaction,@@adjWindowBeforeThisHourAlt,0.1771 +Adjacent window exists afetr this arrival hour - first tour interaction,@@adjWindowAfterThisHourAlt,0.3627 +Adjacent window exists before this departure hour - second+ tour interaction,@@adjWindowBeforeThisHourAlt,0.2123 +Adjacent window exists after this arrival hour - second+ tour interaction,@@adjWindowAfterThisHourAlt,0.1012 +Remaining work/school tours to be scheduled / number of unscheduled hours,1 / @@remainingHoursAvailableAlt,18.68 +Departure Constants -- Early (up to 5),start < 6,0.95273 +Departure Constants -- AM peak 1 (6),start == 6,0.61618 +Departure Constants -- AM peak 2 (7),start == 7,0 +Departure Constants -- AM peak 3 (8),start == 8,0.25471 +Departure Constants -- AM peak 4 (9),start == 9,1.25135 +Departure Constants -- Midday 1 (10 to 12),(start > 9) & (start < 13),1.70587 +Departure Constants -- Midday 2 (13 to 15),(start > 12) & (start < 16),1.69357 +Departure Constants -- PM peak (16 to 18),(start > 15) & (start < 19),1.43999 +Departure Constants -- Evening (19 to 21),(start > 18) & (start < 22),1.61051 +Departure Constants -- Late (22 and later),start > 21,2.88342 +Arrival Constants -- Early (up to 6),end < 7,0 +Arrival Constants -- AM peak (7 to 9),(end > 6) & (end < 10),1.85452 +Arrival Constants -- Midday 1 (10 to 12),(end > 9) & (end < 13),0.49597 +Arrival Constants -- Midday 2 (13 to 14),(end > 12) & (end < 15),0.37855 +Arrival Constants -- PM peak 1 (15),end == 15,0 +Arrival Constants -- PM peak 2 (16),end == 16,0.27608 +Arrival Constants -- PM peak 3 (17),end == 17,0.69959 +Arrival Constants -- PM peak 4 (18),end == 18,0.79929 +Arrival Constants -- Evening (19 to 21),(end > 18) & (end < 22),0.10357 +Arrival Constants -- Late (22 and later),end > 21,0.96596 +Duration Constants -- 0 to 2 hours,duration < 3,2.52827 +Duration Constants -- 3 to 4 hours,(duration > 2) & (duration < 5),0.91897 +Duration Constants -- 5 to 6 hours,(duration > 4) & (duration < 7),0.71855 +Duration Constants -- 7 to 8 hours,(duration > 6) & (duration < 9),0.13962 +Duration Constants -- 9 hours,duration == 9,0.05571 +Duration Constants -- 10 hours,duration == 10,0 +Duration Constants -- 11 hours,duration == 11,0.3478 +Duration Constants -- 12 to 13 hours,(duration > 11) & (duration < 14),1.00822 +Duration Constants -- 14 to 18 hours,(duration > 13) & (duration < 19),1.70186 \ No newline at end of file diff --git a/example/configs/tour_departure_and_duration_nonmandatory.csv b/example/configs/tour_departure_and_duration_nonmandatory.csv new file mode 100644 index 000000000..b940c997a --- /dev/null +++ b/example/configs/tour_departure_and_duration_nonmandatory.csv @@ -0,0 +1,91 @@ +Description,,Expression,Coefficient +subsequet tour must start after previous tour ends,subsequentTour,start < end_of_previous_tour,999 +Free-flow round trip auto time shift effects - duration,,roundtrip_auto_time_to_work * duration,0.00474 +Shopping tour - departure shift effects,tourPurposeIsShopping,"(tour_type == ""shopping"") * start",0.06015 +Shopping tour - duration shift effects,tourPurposeIsShopping,"(tour_type == ""shopping"") * duration",0.1208 +Maintenance tour - departure shift effects,tourPurposeIsMaint,"(tour_type == ""oth_maint"") * start",0.1489 +Maintenance tour - departure shift effects,tourPurposeIsMaint,"(tour_type == ""oth_maint"") * duration",0.08372 +Visit tour - departure shift effects,tourPurposeIsVisit,"(tour_type == ""social"") * start",0.09688 +Visit tour - departure shift effects,tourPurposeIsVisit,"(tour_type == ""social"") * duration",0.1638 +Eat Out tour - departure shift effects,tourPurposeIsEatOut,"(tour_type == ""eatout"") * start",0.07549 +School child age 16+ - departure shift effects,studentDrivingAge,(ptype == 6) * start,0.07266 +School child age 16+ - duration shift effects,studentDrivingAge,(ptype == 6) * duration,0.2095 +School child age under 16 - departure shift effects,studentNonDrivingAge,(ptype == 7) * start,0.04657 +School child age under 16 - duration shift effects,studentNonDrivingAge,(ptype == 7) * duration,0.3272 +Destination in CBD - duration shift effects,destinationInCBD,duration,0.1067 +Number of mandatory tours - departure shift effects,,personMandatoryTotal * start,0.04673 +Number of joint tours - departure shift effects,,personJointTotal * start,0.05208 +Number of escort tours - departure shift effects,,personEscortTotal * start,0.02013 +Number of idividual non-mandatory tours (excluding escort) - departure shift effects,,personNonMandatoryTotalNoEscort * start,0.03896 +First of 2+ tours for same purpose - departure shift effect,firstTour,start,0.2364 +subsequent of 2+ tours for same purpose - duration shift effect,subsequentTour,duration,0.1731 +Maintenance tour - depart before 7,tourPurposeIsMaint,"(tour_type == ""oth_maint"") & (start < 7)",0.8826 +Shopping tour - depart before 8,tourPurposeIsShopping,"(tour_type == ""shopping"" & (start < 8)",1.037 +Shopping tour - arrive after 22,,"(tour_type == ""shopping"" & (end > 22)",0.6027 +School child under 16 - arrive after 22,studentNonDrivingAge,(ptype == 7) & (end > 22),1.18 +University student - arrive after 22,universityStudent,(ptype == 3) & (end > 22),0.5466 +Shopping tour - duration < 2 hours,tourPurposeIsShopping,"(tour_type == ""shopping"") & (duration < 2)",0.5168 +Discretionary tour - duration < 2 hours,tourPurposeIsDiscr,"(tour_type == ""othdisc"") & (duration < 2)",0.6974 +Adult with children in HH - arrive 19 - 21,personIsAdult * ( numChildrenInHH > 0 ),( end > 18 ) * ( end < 22 ),0.336 +Mode Choice Logsum,0,mode_choice_logsum,0 +Some previously-scheduled tour ends in this departure hour,,prev_tour_end == start,0.4562 +Some previously-scheduled tour begins in this arrival hour,,prev_tour_begin == end,0.3992 +Adjacent window exists before this departure hour - first tour interaction,firstTour,@@adjWindowBeforeThisHourAlt,0.00844 +Adjacent window exists afetr this arrival hour - first tour interaction,firstTour,@@adjWindowAfterThisHourAlt,0.0257 +Adjacent window exists before this departure hour - second+ tour interaction,subsequentTour,@@adjWindowBeforeThisHourAlt,0.0593 +Adjacent window exists after this arrival hour - second+ tour interaction,subsequentTour,@@adjWindowAfterThisHourAlt,0.02734 +Remaining individual non-mandatory tours to be scheduled / number of unscheduled hours,,@@remainingInmToursToAvailableHoursRatioAlt,13.63 +Departure Constants -- Early (up to 5),escortTour==0,"(tour_type != ""escort"") & (start < 6)",1.74014 +Departure Constants -- AM peak 1 (6),escortTour==0,"(tour_type != ""escort"") & (start == 6)",0.65416 +Departure Constants -- AM peak 2 (7),escortTour==0,"(tour_type != ""escort"") & (start == 7)",0.55428 +Departure Constants -- AM peak 3 (8),escortTour==0,"(tour_type != ""escort"") & (start == 8)",1.05056 +Departure Constants -- AM peak 4 (9),escortTour==0,"(tour_type != ""escort"") & (start == 9)",0.97157 +Departure Constants -- Midday 1 (10 to 12),escortTour==0,"(tour_type != ""escort"") & (start > 9) & (start < 13)",0.88199 +Departure Constants -- Midday 2 (13 to 15),escortTour==0,"(tour_type != ""escort"") & (start > 12) & (start < 16)",0.4111 +Departure Constants -- PM peak (16 to 18),escortTour==0,"(tour_type != ""escort"") & (start > 15) & (start < 19)",0 +Departure Constants -- Evening (19 to 21),escortTour==0,"(tour_type != ""escort"") & (start > 18) & (start < 22)",1.85648 +Departure Constants -- Late (22 and later),escortTour==0,"(tour_type != ""escort"") & (start > 21)",8.22888 +Arrival Constants -- Early (up to 6),escortTour==0,"(tour_type != ""escort"") & (end < 7)",0.05199 +Arrival Constants -- AM peak (7 to 9),escortTour==0,"(tour_type != ""escort"") & (end > 6) & (end < 10)",1.81482 +Arrival Constants -- Midday 1 (10 to 12),escortTour==0,"(tour_type != ""escort"") & (end > 9) & (end < 13)",0.00037 +Arrival Constants -- Midday 2 (13 to 14),escortTour==0,"(tour_type != ""escort"") & (end > 12) & (end < 15)",0.53212 +Arrival Constants -- PM peak 1 (15),escortTour==0,"(tour_type != ""escort"") & (end == 15)",0.62848 +Arrival Constants -- PM peak 2 (16),escortTour==0,"(tour_type != ""escort"") & (end == 16)",0.65052 +Arrival Constants -- PM peak 3 (17),escortTour==0,"(tour_type != ""escort"") & (end == 17)",0.40289 +Arrival Constants -- PM peak 4 (18),escortTour==0,"(tour_type != ""escort"") & (end == 18)",0.15421 +Arrival Constants -- Evening (19 to 21),escortTour==0,"(tour_type != ""escort"") & (end > 18) & (end < 22)",0 +Arrival Constants -- Late (22 and later),escortTour==0,"(tour_type != ""escort"") & (end > 21)",0.86667 +Duration Constants -- 0 to 1 hours,escortTour==0,"(tour_type != ""escort"") & (duration < 2)",0 +Duration Constants -- 2 to 3 hours,escortTour==0,"(tour_type != ""escort"") & (duration > 1) & (duration < 4)",0.05139 +Duration Constants -- 4 to 5 hours,escortTour==0,"(tour_type != ""escort"") & (duration > 3) & (duration < 6)",0.59395 +Duration Constants -- 6 to 7 hours,escortTour==0,"(tour_type != ""escort"") & (duration > 5) & (duration < 8)",0.95116 +Duration Constants -- 8 to 10 hours,escortTour==0,"(tour_type != ""escort"") & (duration > 7) & (duration < 11)",0.82811 +Duration Constants -- 11 to 13 hours,escortTour==0,"(tour_type != ""escort"") & (duration > 10) & (duration < 14)",0.95564 +Duration Constants -- 14 to 18 hours,escortTour==0,"(tour_type != ""escort"") & (duration > 13) & (duration < 19)",1.04258 +Escort Tour Departure Constants -- Early (up to 5),escortTour==1,"(tour_type == ""escort"") & (start < 6)",1.74014 +Escort Tour Departure Constants -- AM peak 1 (6),escortTour==1,"(tour_type == ""escort"") & (start == 6)",1.11236 +Escort Tour Departure Constants -- AM peak 2 (7),escortTour==1,"(tour_type == ""escort"") & (start == 7)",0.69879 +Escort Tour Departure Constants -- AM peak 3 (8),escortTour==1,"(tour_type == ""escort"") & (start == 8)",1.19627 +Escort Tour Departure Constants -- AM peak 4 (9),escortTour==1,"(tour_type == ""escort"") & (start == 9)",0.22526 +Escort Tour Departure Constants -- Midday 1 (10 to 12),escortTour==1,"(tour_type == ""escort"") & (start > 9) & (start < 13)",0.02866 +Escort Tour Departure Constants -- Midday 2 (13 to 15),escortTour==1,"(tour_type == ""escort"") & (start > 12) & (start < 16)",0 +Escort Tour Departure Constants -- PM peak (16 to 18),escortTour==1,"(tour_type == ""escort"") & (start > 15) & (start < 19)",1.18014 +Escort Tour Departure Constants -- Evening (19 to 21),escortTour==1,"(tour_type == ""escort"") & (start > 18) & (start < 22)",3.94873 +Escort Tour Departure Constants -- Late (22 and later),escortTour==1,"(tour_type == ""escort"") & (start > 21)",8.22888 +Escort Tour Arrival Constants -- Early (up to 6),escortTour==1,"(tour_type == ""escort"") & (end < 7)",0 +Escort Tour Arrival Constants -- AM peak (7 to 9),escortTour==1,"(tour_type == ""escort"") & (end > 6) & (end < 10)",0 +Escort Tour Arrival Constants -- Midday 1 (10 to 12),escortTour==1,"(tour_type == ""escort"") & (end > 9) & (end < 13)",0 +Escort Tour Arrival Constants -- Midday 2 (13 to 14),escortTour==1,"(tour_type == ""escort"") & (end > 12) & (end < 15)",0 +Escort Tour Arrival Constants -- PM peak 1 (15),escortTour==1,"(tour_type == ""escort"") & (end == 15)",0 +Escort Tour Arrival Constants -- PM peak 2 (16),escortTour==1,"(tour_type == ""escort"") & (end == 16)",0 +Escort Tour Arrival Constants -- PM peak 3 (17),escortTour==1,"(tour_type == ""escort"") & (end == 17)",0 +Escort Tour Arrival Constants -- PM peak 4 (18),escortTour==1,"(tour_type == ""escort"") & (end == 18)",0 +Escort Tour Arrival Constants -- Evening (19 to 21),escortTour==1,"(tour_type == ""escort"") & (end > 18) & (end < 22)",0.53692 +Escort Tour Arrival Constants -- Late (22 and later),escortTour==1,"(tour_type == ""escort"") & (end > 21)",1.00829 +Escort Tour Duration Constants -- 0 to 1 hours,escortTour==1,"(tour_type == ""escort"") & (duration < 2)",0 +Escort Tour Duration Constants -- 2 to 3 hours,escortTour==1,"(tour_type == ""escort"") & (duration > 1) & (duration < 4)",2.04201 +Escort Tour Duration Constants -- 4 to 5 hours,escortTour==1,"(tour_type == ""escort"") & (duration > 3) & (duration < 6)",2.88029 +Escort Tour Duration Constants -- 6 to 7 hours,escortTour==1,"(tour_type == ""escort"") & (duration > 5) & (duration < 8)",2.97353 +Escort Tour Duration Constants -- 8 to 10 hours,escortTour==1,"(tour_type == ""escort"") & (duration > 7) & (duration < 11)",3.02021 +Escort Tour Duration Constants -- 11 to 13 hours,escortTour==1,"(tour_type == ""escort"") & (duration > 10) & (duration < 14)",2.97436 +Escort Tour Duration Constants -- 14 to 18 hours,escortTour==1,"(tour_type == ""escort"") & (duration > 13) & (duration < 19)",2.50745 \ No newline at end of file diff --git a/example/models.py b/example/models.py index 840212d2b..1450e9003 100644 --- a/example/models.py +++ b/example/models.py @@ -12,6 +12,14 @@ MAX_NUM_CARS = 5 +""" +Definition of terms: + +CDAP = coordinated daily activity pattern +TDD = tour departure and duration +""" + + """ This part of this file is currently creating small tables to serve as alternatives in the various models @@ -50,7 +58,7 @@ def tot_tours(non_mandatory_tour_frequency_alts): @sim.table() -def tour_departure_and_duration_alts(): +def tdd_alts(): # right now this file just contains the start and end hour f = os.path.join("configs", "tour_departure_and_duration_alternatives.csv") @@ -59,10 +67,9 @@ def tour_departure_and_duration_alts(): # used to have duration in the actual alternative csv file, # but this is probably better as a computed column -@sim.column("tour_departure_and_duration_alts") -def duration(tour_departure_and_duration_alts): - return tour_departure_and_duration_alts.end - \ - tour_departure_and_duration_alts.start +@sim.column("tdd_alts") +def duration(tdd_alts): + return tdd_alts.end - tdd_alts.start """ @@ -144,8 +151,14 @@ def destination_choice_spec(): @sim.table() -def tour_departure_and_duration_spec(): - f = os.path.join('configs', 'tour_departure_and_duration.csv') +def tdd_mandatory_spec(): + f = os.path.join('configs', 'tour_departure_and_duration_mandatory.csv') + return asim.read_model_spec(f, stack=False) + + +@sim.table() +def tdd_non_mandatory_spec(): + f = os.path.join('configs', 'tour_departure_and_duration_nonmandatory.csv') return asim.read_model_spec(f, stack=False) @@ -354,7 +367,7 @@ def non_mandatory_tours(persons, # reformat with the columns given below tours = tours.stack().reset_index() - tours.columns = ["person_id", "trip_type", "num_tours"] + tours.columns = ["person_id", "tour_type", "num_tours"] # now do a repeat and a take, so if you have two trips of given type you # now have two rows, and zero trips yields zero rows @@ -365,7 +378,7 @@ def non_mandatory_tours(persons, """ Pretty basic at this point - trip table looks like this so far - person_id trip_type + person_id tour_type 0 4419 escort 1 4419 escort 2 4419 othmaint @@ -423,7 +436,7 @@ def mandatory_tours(persons): else: assert 0 - return pd.DataFrame(tours, columns=["person_id", "trip_type", "tour_num"]) + return pd.DataFrame(tours, columns=["person_id", "tour_type", "tour_num"]) sim.broadcast('persons', 'mandatory_tours', @@ -466,7 +479,7 @@ def destination_choice(non_mandatory_tours, choices_list = [] # segment by trip type and pick the right spec for each person type - for name, segment in choosers.groupby('trip_type'): + for name, segment in choosers.groupby('tour_type'): # FIXME - there are two options here escort with kids and without if name == "escort": @@ -475,7 +488,7 @@ def destination_choice(non_mandatory_tours, print "Running segment '%s' of size %d" % (name, len(segment)) choices, _ = \ - asim.simple_simulate(choosers, + asim.simple_simulate(segment, zones.to_frame(), destination_choice_spec[name], skims, @@ -494,17 +507,18 @@ def destination_choice(non_mandatory_tours, """ -This model predicts the departure time and duration of each activity +This model predicts the departure time and duration of each activity for +mandatory tours """ @sim.model() -def mandatory_tour_departure_and_duration(mandatory_tours, +def tour_departure_and_duration_mandatory(mandatory_tours, persons, households, land_use, - tour_departure_and_duration_alts, - tour_departure_and_duration_spec): + tdd_alts, + tdd_mandatory_spec): choosers = sim.merge_tables(mandatory_tours.name, tables=[mandatory_tours, persons, @@ -520,11 +534,17 @@ def mandatory_tour_departure_and_duration(mandatory_tours, first_tours = choosers[choosers.tour_num == 1] second_tours = choosers[choosers.tour_num == 2] - spec = tour_departure_and_duration_spec.work.head(27) - alts = tour_departure_and_duration_alts.to_frame() + spec = tdd_mandatory_spec.to_frame().head(27) + alts = tdd_alts.to_frame() print choosers.mandatory_tour_frequency.value_counts() - print spec + print spec.tail() + + # FIXME the "windowing" variables are not currently implemented + + # FIXME this version hard-codes the 2 passes of the mandatory models - + # FIXME the non-mandatory version below does not - might should use that + # FIXME kind of structure here instead? # this is a bit odd to python - we can't run through in for loops for # performance reasons - we first have to do a pass for the first tours and @@ -554,7 +574,63 @@ def mandatory_tour_departure_and_duration(mandatory_tours, # to actually use it we'll have ot go back and grab the start and end times print "Choices:\n", choices.describe() - sim.add_column("persons", "mandatory_tour_departure_and_duration", choices) + sim.add_column("mandatory_tours", "mandatory_tdd", choices) + + +""" +This model predicts the departure time and duration of each activity for +non-mandatory tours +""" + + +@sim.model() +def tour_departure_and_duration_non_mandatory(non_mandatory_tours, + persons, + households, + land_use, + tdd_alts, + tdd_non_mandatory_spec): + + tours = sim.merge_tables(non_mandatory_tours.name, + tables=[non_mandatory_tours, + persons, + households, + land_use]) + + print "Running %d non-mandatory tour scheduling choices" % len(tours) + + spec = tdd_non_mandatory_spec.Coefficient.head(4) + print spec + alts = tdd_alts.to_frame() + + max_num_trips = tours.groupby('person_id').size().max() + + # because this is Python, we have to vectorize everything by doing the + # "nth" trip for each person in a for loop (in other words, because each + # trip is dependent on the time windows left by the previous decision) - + # hopefully this will work out ok! + + choices = [] + + for i in range(max_num_trips): + + nth_tours = tours.groupby('person_id').nth(i) + + print "Running %d non-mandatory #%d tour choices" % \ + (len(nth_tours), i+1) + + nth_tours["end_of_previous_tour"] = -1 + + nth_choices, _ = \ + asim.simple_simulate(nth_tours, alts, spec, mult_by_alt_col=False) + + choices.append(nth_choices) + + choices = pd.concat(choices) + + print "Choices:\n", choices.describe() + + sim.add_column("non_mandatory_tours", "non_mandatory_tdd", choices) """ diff --git a/notebooks/simulation.ipynb b/notebooks/simulation.ipynb index d81303ad9..0a97dd600 100644 --- a/notebooks/simulation.ipynb +++ b/notebooks/simulation.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:2ac723c10479d39a6126f1871723950f6eb803212ddda416f1652722e84434c1" + "signature": "sha256:9a607455266c43290b762ebb7f1984d7fe8afb27633c63fe6568f0607f6e8de4" }, "nbformat": 3, "nbformat_minor": 0, @@ -46,17 +46,17 @@ "output_type": "stream", "stream": "stdout", "text": [ - "count 2513.000000\n", - "mean 719.074413\n", - "std 426.054061\n", + "count 2549.000000\n", + "mean 722.169086\n", + "std 425.570891\n", "min 1.000000\n", - "25% 356.000000\n", - "50% 720.000000\n", - "75% 1090.000000\n", + "25% 343.000000\n", + "50% 723.000000\n", + "75% 1087.000000\n", "max 1454.000000\n", "Name: TAZ, dtype: float64\n", - "Time to execute model 'workplace_location_simulate': 7.61s\n", - "Total time to execute: 7.61s\n" + "Time to execute model 'workplace_location_simulate': 8.85s\n", + "Total time to execute: 8.85s\n" ] } ], @@ -75,14 +75,14 @@ "output_type": "stream", "stream": "stdout", "text": [ - "count 2513.000000\n", - "mean 38.703832\n", - "std 24.329613\n", - "min 0.390000\n", - "25% 21.000000\n", - "50% 35.310000\n", - "75% 51.960000\n", - "max 137.480000\n", + "count 2549.000000\n", + "mean 39.473127\n", + "std 24.095286\n", + "min 0.430000\n", + "25% 21.450000\n", + "50% 37.150000\n", + "75% 53.480000\n", + "max 132.160000\n", "dtype: float64\n" ] } @@ -110,14 +110,14 @@ "output_type": "stream", "stream": "stdout", "text": [ - "2 477\n", - "3 379\n", - "1 94\n", - "4 38\n", - "0 12\n", + "2 489\n", + "3 365\n", + "1 78\n", + "4 61\n", + "0 7\n", "dtype: int64\n", - "Time to execute model 'auto_ownership_simulate': 0.55s\n", - "Total time to execute: 0.55s\n" + "Time to execute model 'auto_ownership_simulate': 0.72s\n", + "Total time to execute: 0.72s\n" ] } ], @@ -137,7 +137,7 @@ "stream": "stdout", "text": [ "Running model 'mandatory_tour_frequency'\n", - "863 persons run for mandatory tour model" + "856 persons run for mandatory tour model" ] }, { @@ -152,71 +152,238 @@ "output_type": "stream", "stream": "stdout", "text": [ - " count mean std \\\n", - "((ptype == 2) & nonstudent_to_school) * school1 4315 0 0 \n", - "((ptype == 2) & nonstudent_to_school) * work_and_school 4315 0 0 \n", - "((ptype == 4) & nonstudent_to_school) * school1 4315 0 0 \n", - "((ptype == 5) & nonstudent_to_school) * school1 4315 0 0 \n", - "((ptype == 6) & (auto_ownership == 0)) * school2 4315 0 0 \n", - "((ptype == 6) & (auto_ownership == 0)) * work_and_school 4315 0 0 \n", - "((ptype == 6) & non_family) * school1 4315 0 0 \n", - "((ptype == 6) & non_family) * work1 4315 0 0 \n", - "((ptype == 6) & non_family) * work_and_school 4315 0 0 \n", - "((ptype == 7) & non_family) * school1 4315 0 0 \n", - "((ptype == 7) & non_family) * work1 4315 0 0 \n", - "(~(school_taz > -1)) * school1 4315 0 0 \n", - "(~(school_taz > -1)) * school2 4315 0 0 \n", - "(~(school_taz > -1)) * work_and_school 4315 0 0 \n", - "(~(workplace_taz > -1)) * work1 4315 0 0 \n", - "(~(workplace_taz > -1)) * work2 4315 0 0 \n", - "(~(workplace_taz > -1)) * work_and_school 4315 0 0 \n", + " count \\\n", + "((ptype == 1) & (auto_ownership == 0)) * work2 4280 \n", + "((ptype == 1) & (auto_ownership == 0)) * work_and_school 4280 \n", + "((ptype == 2) & (auto_ownership == 0)) * work2 4280 \n", + "((ptype == 2) & (auto_ownership == 0)) * work_and_school 4280 \n", + "((ptype == 2) & nonstudent_to_school) * school1 4280 \n", + "((ptype == 2) & nonstudent_to_school) * work_and_school 4280 \n", + "((ptype == 4) & nonstudent_to_school) * school1 4280 \n", + "((ptype == 5) & (auto_ownership == 0)) * work2 4280 \n", + "((ptype == 5) & nonstudent_to_school) * school1 4280 \n", + "((ptype == 6) & (auto_ownership == 0)) * school2 4280 \n", + "((ptype == 6) & (auto_ownership == 0)) * work_and_school 4280 \n", + "((ptype == 6) & (distance_to_school < 3)) * school2 4280 \n", + "((ptype == 6) & (distance_to_work < 3 | distance_to_school < 3)) * work_and_school 4280 \n", + "((ptype == 6) & non_family) * school1 4280 \n", + "((ptype == 6) & non_family) * work1 4280 \n", + "((ptype == 6) & non_family) * work_and_school 4280 \n", + "((ptype == 6) * (num_young_children)) * school1 4280 \n", + "((ptype == 6) * (num_young_children)) * school2 4280 \n", + "((ptype == 6) * (num_young_children)) * work1 4280 \n", + "((ptype == 6) * (num_young_children)) * work_and_school 4280 \n", + "(~(school_taz > -1)) * school1 4280 \n", + "(~(school_taz > -1)) * school2 4280 \n", + "(~(school_taz > -1)) * work_and_school 4280 \n", + "(~(workplace_taz > -1)) * work1 4280 \n", + "(~(workplace_taz > -1)) * work2 4280 \n", + "(~(workplace_taz > -1)) * work_and_school 4280 \n", "\n", - " min 25% 50% 75% \\\n", - "((ptype == 2) & nonstudent_to_school) * school1 0 0 0 0 \n", - "((ptype == 2) & nonstudent_to_school) * work_and_school 0 0 0 0 \n", - "((ptype == 4) & nonstudent_to_school) * school1 0 0 0 0 \n", - "((ptype == 5) & nonstudent_to_school) * school1 0 0 0 0 \n", - "((ptype == 6) & (auto_ownership == 0)) * school2 0 0 0 0 \n", - "((ptype == 6) & (auto_ownership == 0)) * work_and_school 0 0 0 0 \n", - "((ptype == 6) & non_family) * school1 0 0 0 0 \n", - "((ptype == 6) & non_family) * work1 0 0 0 0 \n", - "((ptype == 6) & non_family) * work_and_school 0 0 0 0 \n", - "((ptype == 7) & non_family) * school1 0 0 0 0 \n", - "((ptype == 7) & non_family) * work1 0 0 0 0 \n", - "(~(school_taz > -1)) * school1 0 0 0 0 \n", - "(~(school_taz > -1)) * school2 0 0 0 0 \n", - "(~(school_taz > -1)) * work_and_school 0 0 0 0 \n", - "(~(workplace_taz > -1)) * work1 0 0 0 0 \n", - "(~(workplace_taz > -1)) * work2 0 0 0 0 \n", - "(~(workplace_taz > -1)) * work_and_school 0 0 0 0 \n", + " mean \\\n", + "((ptype == 1) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 1) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & nonstudent_to_school) * school1 0 \n", + "((ptype == 2) & nonstudent_to_school) * work_and_school 0 \n", + "((ptype == 4) & nonstudent_to_school) * school1 0 \n", + "((ptype == 5) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 5) & nonstudent_to_school) * school1 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * school2 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 6) & (distance_to_school < 3)) * school2 0 \n", + "((ptype == 6) & (distance_to_work < 3 | distance_to_school < 3)) * work_and_school 0 \n", + "((ptype == 6) & non_family) * school1 0 \n", + "((ptype == 6) & non_family) * work1 0 \n", + "((ptype == 6) & non_family) * work_and_school 0 \n", + "((ptype == 6) * (num_young_children)) * school1 0 \n", + "((ptype == 6) * (num_young_children)) * school2 0 \n", + "((ptype == 6) * (num_young_children)) * work1 0 \n", + "((ptype == 6) * (num_young_children)) * work_and_school 0 \n", + "(~(school_taz > -1)) * school1 0 \n", + "(~(school_taz > -1)) * school2 0 \n", + "(~(school_taz > -1)) * work_and_school 0 \n", + "(~(workplace_taz > -1)) * work1 0 \n", + "(~(workplace_taz > -1)) * work2 0 \n", + "(~(workplace_taz > -1)) * work_and_school 0 \n", "\n", - " max \n", - "((ptype == 2) & nonstudent_to_school) * school1 0 \n", - "((ptype == 2) & nonstudent_to_school) * work_and_school 0 \n", - "((ptype == 4) & nonstudent_to_school) * school1 0 \n", - "((ptype == 5) & nonstudent_to_school) * school1 0 \n", - "((ptype == 6) & (auto_ownership == 0)) * school2 0 \n", - "((ptype == 6) & (auto_ownership == 0)) * work_and_school 0 \n", - "((ptype == 6) & non_family) * school1 0 \n", - "((ptype == 6) & non_family) * work1 0 \n", - "((ptype == 6) & non_family) * work_and_school 0 \n", - "((ptype == 7) & non_family) * school1 0 \n", - "((ptype == 7) & non_family) * work1 0 \n", - "(~(school_taz > -1)) * school1 0 \n", - "(~(school_taz > -1)) * school2 0 \n", - "(~(school_taz > -1)) * work_and_school 0 \n", - "(~(workplace_taz > -1)) * work1 0 \n", - "(~(workplace_taz > -1)) * work2 0 \n", - "(~(workplace_taz > -1)) * work_and_school 0 \n", + " std \\\n", + "((ptype == 1) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 1) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & nonstudent_to_school) * school1 0 \n", + "((ptype == 2) & nonstudent_to_school) * work_and_school 0 \n", + "((ptype == 4) & nonstudent_to_school) * school1 0 \n", + "((ptype == 5) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 5) & nonstudent_to_school) * school1 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * school2 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 6) & (distance_to_school < 3)) * school2 0 \n", + "((ptype == 6) & (distance_to_work < 3 | distance_to_school < 3)) * work_and_school 0 \n", + "((ptype == 6) & non_family) * school1 0 \n", + "((ptype == 6) & non_family) * work1 0 \n", + "((ptype == 6) & non_family) * work_and_school 0 \n", + "((ptype == 6) * (num_young_children)) * school1 0 \n", + "((ptype == 6) * (num_young_children)) * school2 0 \n", + "((ptype == 6) * (num_young_children)) * work1 0 \n", + "((ptype == 6) * (num_young_children)) * work_and_school 0 \n", + "(~(school_taz > -1)) * school1 0 \n", + "(~(school_taz > -1)) * school2 0 \n", + "(~(school_taz > -1)) * work_and_school 0 \n", + "(~(workplace_taz > -1)) * work1 0 \n", + "(~(workplace_taz > -1)) * work2 0 \n", + "(~(workplace_taz > -1)) * work_and_school 0 \n", + "\n", + " min \\\n", + "((ptype == 1) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 1) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & nonstudent_to_school) * school1 0 \n", + "((ptype == 2) & nonstudent_to_school) * work_and_school 0 \n", + "((ptype == 4) & nonstudent_to_school) * school1 0 \n", + "((ptype == 5) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 5) & nonstudent_to_school) * school1 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * school2 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 6) & (distance_to_school < 3)) * school2 0 \n", + "((ptype == 6) & (distance_to_work < 3 | distance_to_school < 3)) * work_and_school 0 \n", + "((ptype == 6) & non_family) * school1 0 \n", + "((ptype == 6) & non_family) * work1 0 \n", + "((ptype == 6) & non_family) * work_and_school 0 \n", + "((ptype == 6) * (num_young_children)) * school1 0 \n", + "((ptype == 6) * (num_young_children)) * school2 0 \n", + "((ptype == 6) * (num_young_children)) * work1 0 \n", + "((ptype == 6) * (num_young_children)) * work_and_school 0 \n", + "(~(school_taz > -1)) * school1 0 \n", + "(~(school_taz > -1)) * school2 0 \n", + "(~(school_taz > -1)) * work_and_school 0 \n", + "(~(workplace_taz > -1)) * work1 0 \n", + "(~(workplace_taz > -1)) * work2 0 \n", + "(~(workplace_taz > -1)) * work_and_school 0 \n", + "\n", + " 25% \\\n", + "((ptype == 1) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 1) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & nonstudent_to_school) * school1 0 \n", + "((ptype == 2) & nonstudent_to_school) * work_and_school 0 \n", + "((ptype == 4) & nonstudent_to_school) * school1 0 \n", + "((ptype == 5) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 5) & nonstudent_to_school) * school1 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * school2 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 6) & (distance_to_school < 3)) * school2 0 \n", + "((ptype == 6) & (distance_to_work < 3 | distance_to_school < 3)) * work_and_school 0 \n", + "((ptype == 6) & non_family) * school1 0 \n", + "((ptype == 6) & non_family) * work1 0 \n", + "((ptype == 6) & non_family) * work_and_school 0 \n", + "((ptype == 6) * (num_young_children)) * school1 0 \n", + "((ptype == 6) * (num_young_children)) * school2 0 \n", + "((ptype == 6) * (num_young_children)) * work1 0 \n", + "((ptype == 6) * (num_young_children)) * work_and_school 0 \n", + "(~(school_taz > -1)) * school1 0 \n", + "(~(school_taz > -1)) * school2 0 \n", + "(~(school_taz > -1)) * work_and_school 0 \n", + "(~(workplace_taz > -1)) * work1 0 \n", + "(~(workplace_taz > -1)) * work2 0 \n", + "(~(workplace_taz > -1)) * work_and_school 0 \n", + "\n", + " 50% \\\n", + "((ptype == 1) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 1) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & nonstudent_to_school) * school1 0 \n", + "((ptype == 2) & nonstudent_to_school) * work_and_school 0 \n", + "((ptype == 4) & nonstudent_to_school) * school1 0 \n", + "((ptype == 5) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 5) & nonstudent_to_school) * school1 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * school2 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 6) & (distance_to_school < 3)) * school2 0 \n", + "((ptype == 6) & (distance_to_work < 3 | distance_to_school < 3)) * work_and_school 0 \n", + "((ptype == 6) & non_family) * school1 0 \n", + "((ptype == 6) & non_family) * work1 0 \n", + "((ptype == 6) & non_family) * work_and_school 0 \n", + "((ptype == 6) * (num_young_children)) * school1 0 \n", + "((ptype == 6) * (num_young_children)) * school2 0 \n", + "((ptype == 6) * (num_young_children)) * work1 0 \n", + "((ptype == 6) * (num_young_children)) * work_and_school 0 \n", + "(~(school_taz > -1)) * school1 0 \n", + "(~(school_taz > -1)) * school2 0 \n", + "(~(school_taz > -1)) * work_and_school 0 \n", + "(~(workplace_taz > -1)) * work1 0 \n", + "(~(workplace_taz > -1)) * work2 0 \n", + "(~(workplace_taz > -1)) * work_and_school 0 \n", + "\n", + " 75% \\\n", + "((ptype == 1) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 1) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & nonstudent_to_school) * school1 0 \n", + "((ptype == 2) & nonstudent_to_school) * work_and_school 0 \n", + "((ptype == 4) & nonstudent_to_school) * school1 0 \n", + "((ptype == 5) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 5) & nonstudent_to_school) * school1 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * school2 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 6) & (distance_to_school < 3)) * school2 0 \n", + "((ptype == 6) & (distance_to_work < 3 | distance_to_school < 3)) * work_and_school 0 \n", + "((ptype == 6) & non_family) * school1 0 \n", + "((ptype == 6) & non_family) * work1 0 \n", + "((ptype == 6) & non_family) * work_and_school 0 \n", + "((ptype == 6) * (num_young_children)) * school1 0 \n", + "((ptype == 6) * (num_young_children)) * school2 0 \n", + "((ptype == 6) * (num_young_children)) * work1 0 \n", + "((ptype == 6) * (num_young_children)) * work_and_school 0 \n", + "(~(school_taz > -1)) * school1 0 \n", + "(~(school_taz > -1)) * school2 0 \n", + "(~(school_taz > -1)) * work_and_school 0 \n", + "(~(workplace_taz > -1)) * work1 0 \n", + "(~(workplace_taz > -1)) * work2 0 \n", + "(~(workplace_taz > -1)) * work_and_school 0 \n", + "\n", + " max \n", + "((ptype == 1) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 1) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 2) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 2) & nonstudent_to_school) * school1 0 \n", + "((ptype == 2) & nonstudent_to_school) * work_and_school 0 \n", + "((ptype == 4) & nonstudent_to_school) * school1 0 \n", + "((ptype == 5) & (auto_ownership == 0)) * work2 0 \n", + "((ptype == 5) & nonstudent_to_school) * school1 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * school2 0 \n", + "((ptype == 6) & (auto_ownership == 0)) * work_and_school 0 \n", + "((ptype == 6) & (distance_to_school < 3)) * school2 0 \n", + "((ptype == 6) & (distance_to_work < 3 | distance_to_school < 3)) * work_and_school 0 \n", + "((ptype == 6) & non_family) * school1 0 \n", + "((ptype == 6) & non_family) * work1 0 \n", + "((ptype == 6) & non_family) * work_and_school 0 \n", + "((ptype == 6) * (num_young_children)) * school1 0 \n", + "((ptype == 6) * (num_young_children)) * school2 0 \n", + "((ptype == 6) * (num_young_children)) * work1 0 \n", + "((ptype == 6) * (num_young_children)) * work_and_school 0 \n", + "(~(school_taz > -1)) * school1 0 \n", + "(~(school_taz > -1)) * school2 0 \n", + "(~(school_taz > -1)) * work_and_school 0 \n", + "(~(workplace_taz > -1)) * work1 0 \n", + "(~(workplace_taz > -1)) * work2 0 \n", + "(~(workplace_taz > -1)) * work_and_school 0 \n", "Choices:\n", - "work_and_school 330\n", - "work2 262\n", - "work1 160\n", - "school2 56\n", - "school1 55\n", + "work_and_school 322\n", + "work2 221\n", + "work1 179\n", + "school1 67\n", + "school2 67\n", "dtype: int64\n", - "Time to execute model 'mandatory_tour_frequency': 3.11s\n", - "Total time to execute: 3.11s\n" + "Time to execute model 'mandatory_tour_frequency': 3.83s\n", + "Total time to execute: 3.83s\n" ] } ], @@ -236,7 +403,7 @@ "stream": "stdout", "text": [ "Running model 'non_mandatory_tour_frequency'\n", - "1709 persons run for non-mandatory tour model" + "1683 persons run for non-mandatory tour model" ] }, { @@ -244,7 +411,7 @@ "stream": "stdout", "text": [ "\n", - "Running segment 'driving' of size 40\n", + "Running segment 'driving' of size 45\n", "WARNING: Describe of columns with no variability:\n" ] }, @@ -253,30 +420,30 @@ "stream": "stdout", "text": [ " count mean std \\\n", - "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 3840 0 0 \n", - "escort * no_cars 3840 0 0 \n", - "max_window*(tot_tours == 0) 3840 0 0 \n", - "max_window*(tot_tours == 1) 3840 0 0 \n", - "max_window*(tot_tours == 2) 3840 0 0 \n", - "max_window*(tot_tours == 3) 3840 0 0 \n", - "max_window*(tot_tours == 4) 3840 0 0 \n", - "max_window*(tot_tours > 4) 3840 0 0 \n", - "no_cars & (tot_tours == 1) 3840 0 0 \n", - "no_cars & (tot_tours == 2) 3840 0 0 \n", - "no_cars & (tot_tours == 3) 3840 0 0 \n", - "no_cars & (tot_tours == 4) 3840 0 0 \n", - "no_cars & (tot_tours > 4) 3840 0 0 \n", - "num_disc_j 3840 0 0 \n", - "num_eat_j 3840 0 0 \n", - "num_joint_tours*(tot_tours == 0) 3840 0 0 \n", - "num_joint_tours*(tot_tours == 1) 3840 0 0 \n", - "num_joint_tours*(tot_tours == 2) 3840 0 0 \n", - "num_joint_tours*(tot_tours == 3) 3840 0 0 \n", - "num_joint_tours*(tot_tours == 4) 3840 0 0 \n", - "num_joint_tours*(tot_tours > 4) 3840 0 0 \n", - "num_main_j 3840 0 0 \n", - "num_shop_j 3840 0 0 \n", - "num_visi_j 3840 0 0 \n", + "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 4320 0 0 \n", + "escort * no_cars 4320 0 0 \n", + "max_window*(tot_tours == 0) 4320 0 0 \n", + "max_window*(tot_tours == 1) 4320 0 0 \n", + "max_window*(tot_tours == 2) 4320 0 0 \n", + "max_window*(tot_tours == 3) 4320 0 0 \n", + "max_window*(tot_tours == 4) 4320 0 0 \n", + "max_window*(tot_tours > 4) 4320 0 0 \n", + "no_cars & (tot_tours == 1) 4320 0 0 \n", + "no_cars & (tot_tours == 2) 4320 0 0 \n", + "no_cars & (tot_tours == 3) 4320 0 0 \n", + "no_cars & (tot_tours == 4) 4320 0 0 \n", + "no_cars & (tot_tours > 4) 4320 0 0 \n", + "num_disc_j 4320 0 0 \n", + "num_eat_j 4320 0 0 \n", + "num_joint_tours*(tot_tours == 0) 4320 0 0 \n", + "num_joint_tours*(tot_tours == 1) 4320 0 0 \n", + "num_joint_tours*(tot_tours == 2) 4320 0 0 \n", + "num_joint_tours*(tot_tours == 3) 4320 0 0 \n", + "num_joint_tours*(tot_tours == 4) 4320 0 0 \n", + "num_joint_tours*(tot_tours > 4) 4320 0 0 \n", + "num_main_j 4320 0 0 \n", + "num_shop_j 4320 0 0 \n", + "num_visi_j 4320 0 0 \n", "\n", " min 25% 50% \\\n", "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 0 0 0 \n", @@ -329,7 +496,7 @@ "num_main_j 0 0 \n", "num_shop_j 0 0 \n", "num_visi_j 0 0 \n", - "Running segment 'full' of size 645\n", + "Running segment 'full' of size 584\n", "WARNING: Describe of columns with no variability:\n" ] }, @@ -338,24 +505,24 @@ "stream": "stdout", "text": [ " count mean std \\\n", - "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 61920 0 0 \n", - "max_window*(tot_tours == 0) 61920 0 0 \n", - "max_window*(tot_tours == 1) 61920 0 0 \n", - "max_window*(tot_tours == 2) 61920 0 0 \n", - "max_window*(tot_tours == 3) 61920 0 0 \n", - "max_window*(tot_tours == 4) 61920 0 0 \n", - "max_window*(tot_tours > 4) 61920 0 0 \n", - "num_disc_j 61920 0 0 \n", - "num_eat_j 61920 0 0 \n", - "num_joint_tours*(tot_tours == 0) 61920 0 0 \n", - "num_joint_tours*(tot_tours == 1) 61920 0 0 \n", - "num_joint_tours*(tot_tours == 2) 61920 0 0 \n", - "num_joint_tours*(tot_tours == 3) 61920 0 0 \n", - "num_joint_tours*(tot_tours == 4) 61920 0 0 \n", - "num_joint_tours*(tot_tours > 4) 61920 0 0 \n", - "num_main_j 61920 0 0 \n", - "num_shop_j 61920 0 0 \n", - "num_visi_j 61920 0 0 \n", + "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 56064 0 0 \n", + "max_window*(tot_tours == 0) 56064 0 0 \n", + "max_window*(tot_tours == 1) 56064 0 0 \n", + "max_window*(tot_tours == 2) 56064 0 0 \n", + "max_window*(tot_tours == 3) 56064 0 0 \n", + "max_window*(tot_tours == 4) 56064 0 0 \n", + "max_window*(tot_tours > 4) 56064 0 0 \n", + "num_disc_j 56064 0 0 \n", + "num_eat_j 56064 0 0 \n", + "num_joint_tours*(tot_tours == 0) 56064 0 0 \n", + "num_joint_tours*(tot_tours == 1) 56064 0 0 \n", + "num_joint_tours*(tot_tours == 2) 56064 0 0 \n", + "num_joint_tours*(tot_tours == 3) 56064 0 0 \n", + "num_joint_tours*(tot_tours == 4) 56064 0 0 \n", + "num_joint_tours*(tot_tours > 4) 56064 0 0 \n", + "num_main_j 56064 0 0 \n", + "num_shop_j 56064 0 0 \n", + "num_visi_j 56064 0 0 \n", "\n", " min 25% 50% \\\n", "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 0 0 0 \n", @@ -396,7 +563,7 @@ "num_main_j 0 0 \n", "num_shop_j 0 0 \n", "num_visi_j 0 0 \n", - "Running segment 'nonwork' of size 267\n", + "Running segment 'nonwork' of size 289\n", "WARNING: Describe of columns with no variability:\n" ] }, @@ -405,24 +572,24 @@ "stream": "stdout", "text": [ " count mean std \\\n", - "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 25632 0 0 \n", - "max_window*(tot_tours == 0) 25632 0 0 \n", - "max_window*(tot_tours == 1) 25632 0 0 \n", - "max_window*(tot_tours == 2) 25632 0 0 \n", - "max_window*(tot_tours == 3) 25632 0 0 \n", - "max_window*(tot_tours == 4) 25632 0 0 \n", - "max_window*(tot_tours > 4) 25632 0 0 \n", - "num_disc_j 25632 0 0 \n", - "num_eat_j 25632 0 0 \n", - "num_joint_tours*(tot_tours == 0) 25632 0 0 \n", - "num_joint_tours*(tot_tours == 1) 25632 0 0 \n", - "num_joint_tours*(tot_tours == 2) 25632 0 0 \n", - "num_joint_tours*(tot_tours == 3) 25632 0 0 \n", - "num_joint_tours*(tot_tours == 4) 25632 0 0 \n", - "num_joint_tours*(tot_tours > 4) 25632 0 0 \n", - "num_main_j 25632 0 0 \n", - "num_shop_j 25632 0 0 \n", - "num_visi_j 25632 0 0 \n", + "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 27744 0 0 \n", + "max_window*(tot_tours == 0) 27744 0 0 \n", + "max_window*(tot_tours == 1) 27744 0 0 \n", + "max_window*(tot_tours == 2) 27744 0 0 \n", + "max_window*(tot_tours == 3) 27744 0 0 \n", + "max_window*(tot_tours == 4) 27744 0 0 \n", + "max_window*(tot_tours > 4) 27744 0 0 \n", + "num_disc_j 27744 0 0 \n", + "num_eat_j 27744 0 0 \n", + "num_joint_tours*(tot_tours == 0) 27744 0 0 \n", + "num_joint_tours*(tot_tours == 1) 27744 0 0 \n", + "num_joint_tours*(tot_tours == 2) 27744 0 0 \n", + "num_joint_tours*(tot_tours == 3) 27744 0 0 \n", + "num_joint_tours*(tot_tours == 4) 27744 0 0 \n", + "num_joint_tours*(tot_tours > 4) 27744 0 0 \n", + "num_main_j 27744 0 0 \n", + "num_shop_j 27744 0 0 \n", + "num_visi_j 27744 0 0 \n", "\n", " min 25% 50% \\\n", "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 0 0 0 \n", @@ -463,7 +630,7 @@ "num_main_j 0 0 \n", "num_shop_j 0 0 \n", "num_visi_j 0 0 \n", - "Running segment 'part' of size 153\n", + "Running segment 'part' of size 135\n", "WARNING: Describe of columns with no variability:\n" ] }, @@ -472,24 +639,24 @@ "stream": "stdout", "text": [ " count mean std \\\n", - "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 14688 0 0 \n", - "max_window*(tot_tours == 0) 14688 0 0 \n", - "max_window*(tot_tours == 1) 14688 0 0 \n", - "max_window*(tot_tours == 2) 14688 0 0 \n", - "max_window*(tot_tours == 3) 14688 0 0 \n", - "max_window*(tot_tours == 4) 14688 0 0 \n", - "max_window*(tot_tours > 4) 14688 0 0 \n", - "num_disc_j 14688 0 0 \n", - "num_eat_j 14688 0 0 \n", - "num_joint_tours*(tot_tours == 0) 14688 0 0 \n", - "num_joint_tours*(tot_tours == 1) 14688 0 0 \n", - "num_joint_tours*(tot_tours == 2) 14688 0 0 \n", - "num_joint_tours*(tot_tours == 3) 14688 0 0 \n", - "num_joint_tours*(tot_tours == 4) 14688 0 0 \n", - "num_joint_tours*(tot_tours > 4) 14688 0 0 \n", - "num_main_j 14688 0 0 \n", - "num_shop_j 14688 0 0 \n", - "num_visi_j 14688 0 0 \n", + "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 12960 0 0 \n", + "max_window*(tot_tours == 0) 12960 0 0 \n", + "max_window*(tot_tours == 1) 12960 0 0 \n", + "max_window*(tot_tours == 2) 12960 0 0 \n", + "max_window*(tot_tours == 3) 12960 0 0 \n", + "max_window*(tot_tours == 4) 12960 0 0 \n", + "max_window*(tot_tours > 4) 12960 0 0 \n", + "num_disc_j 12960 0 0 \n", + "num_eat_j 12960 0 0 \n", + "num_joint_tours*(tot_tours == 0) 12960 0 0 \n", + "num_joint_tours*(tot_tours == 1) 12960 0 0 \n", + "num_joint_tours*(tot_tours == 2) 12960 0 0 \n", + "num_joint_tours*(tot_tours == 3) 12960 0 0 \n", + "num_joint_tours*(tot_tours == 4) 12960 0 0 \n", + "num_joint_tours*(tot_tours > 4) 12960 0 0 \n", + "num_main_j 12960 0 0 \n", + "num_shop_j 12960 0 0 \n", + "num_visi_j 12960 0 0 \n", "\n", " min 25% 50% \\\n", "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 0 0 0 \n", @@ -530,7 +697,7 @@ "num_main_j 0 0 \n", "num_shop_j 0 0 \n", "num_visi_j 0 0 \n", - "Running segment 'preschool' of size 112\n", + "Running segment 'preschool' of size 127\n", "WARNING: Describe of columns with no variability:\n" ] }, @@ -539,24 +706,24 @@ "stream": "stdout", "text": [ " count mean std \\\n", - "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 10752 0 0 \n", - "max_window*(tot_tours == 0) 10752 0 0 \n", - "max_window*(tot_tours == 1) 10752 0 0 \n", - "max_window*(tot_tours == 2) 10752 0 0 \n", - "max_window*(tot_tours == 3) 10752 0 0 \n", - "max_window*(tot_tours == 4) 10752 0 0 \n", - "max_window*(tot_tours > 4) 10752 0 0 \n", - "num_disc_j 10752 0 0 \n", - "num_eat_j 10752 0 0 \n", - "num_joint_tours*(tot_tours == 0) 10752 0 0 \n", - "num_joint_tours*(tot_tours == 1) 10752 0 0 \n", - "num_joint_tours*(tot_tours == 2) 10752 0 0 \n", - "num_joint_tours*(tot_tours == 3) 10752 0 0 \n", - "num_joint_tours*(tot_tours == 4) 10752 0 0 \n", - "num_joint_tours*(tot_tours > 4) 10752 0 0 \n", - "num_main_j 10752 0 0 \n", - "num_shop_j 10752 0 0 \n", - "num_visi_j 10752 0 0 \n", + "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 12192 0 0 \n", + "max_window*(tot_tours == 0) 12192 0 0 \n", + "max_window*(tot_tours == 1) 12192 0 0 \n", + "max_window*(tot_tours == 2) 12192 0 0 \n", + "max_window*(tot_tours == 3) 12192 0 0 \n", + "max_window*(tot_tours == 4) 12192 0 0 \n", + "max_window*(tot_tours > 4) 12192 0 0 \n", + "num_disc_j 12192 0 0 \n", + "num_eat_j 12192 0 0 \n", + "num_joint_tours*(tot_tours == 0) 12192 0 0 \n", + "num_joint_tours*(tot_tours == 1) 12192 0 0 \n", + "num_joint_tours*(tot_tours == 2) 12192 0 0 \n", + "num_joint_tours*(tot_tours == 3) 12192 0 0 \n", + "num_joint_tours*(tot_tours == 4) 12192 0 0 \n", + "num_joint_tours*(tot_tours > 4) 12192 0 0 \n", + "num_main_j 12192 0 0 \n", + "num_shop_j 12192 0 0 \n", + "num_visi_j 12192 0 0 \n", "\n", " min 25% 50% \\\n", "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 0 0 0 \n", @@ -597,7 +764,7 @@ "num_main_j 0 0 \n", "num_shop_j 0 0 \n", "num_visi_j 0 0 \n", - "Running segment 'retired' of size 200\n", + "Running segment 'retired' of size 196\n", "WARNING: Describe of columns with no variability:\n" ] }, @@ -606,33 +773,55 @@ "stream": "stdout", "text": [ " count mean std \\\n", - "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 19200 0 0 \n", - "max_window*(tot_tours == 0) 19200 0 0 \n", - "max_window*(tot_tours == 1) 19200 0 0 \n", - "max_window*(tot_tours == 2) 19200 0 0 \n", - "max_window*(tot_tours == 3) 19200 0 0 \n", - "max_window*(tot_tours == 4) 19200 0 0 \n", - "max_window*(tot_tours > 4) 19200 0 0 \n", - "num_disc_j 19200 0 0 \n", - "num_eat_j 19200 0 0 \n", - "num_joint_tours*(tot_tours == 0) 19200 0 0 \n", - "num_joint_tours*(tot_tours == 1) 19200 0 0 \n", - "num_joint_tours*(tot_tours == 2) 19200 0 0 \n", - "num_joint_tours*(tot_tours == 3) 19200 0 0 \n", - "num_joint_tours*(tot_tours == 4) 19200 0 0 \n", - "num_joint_tours*(tot_tours > 4) 19200 0 0 \n", - "num_main_j 19200 0 0 \n", - "num_shop_j 19200 0 0 \n", - "num_visi_j 19200 0 0 \n", + "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 18816 0 0 \n", + "escort * no_cars 18816 0 0 \n", + "has_preschool_kid_at_home * eatout 18816 0 0 \n", + "has_preschool_kid_at_home * escort 18816 0 0 \n", + "has_preschool_kid_at_home * othdiscr 18816 0 0 \n", + "has_preschool_kid_at_home * othmaint 18816 0 0 \n", + "has_preschool_kid_at_home * shopping 18816 0 0 \n", + "max_window*(tot_tours == 0) 18816 0 0 \n", + "max_window*(tot_tours == 1) 18816 0 0 \n", + "max_window*(tot_tours == 2) 18816 0 0 \n", + "max_window*(tot_tours == 3) 18816 0 0 \n", + "max_window*(tot_tours == 4) 18816 0 0 \n", + "max_window*(tot_tours > 4) 18816 0 0 \n", + "no_cars & (tot_tours == 1) 18816 0 0 \n", + "no_cars & (tot_tours == 2) 18816 0 0 \n", + "no_cars & (tot_tours == 3) 18816 0 0 \n", + "no_cars & (tot_tours == 4) 18816 0 0 \n", + "no_cars & (tot_tours > 4) 18816 0 0 \n", + "num_disc_j 18816 0 0 \n", + "num_eat_j 18816 0 0 \n", + "num_joint_tours*(tot_tours == 0) 18816 0 0 \n", + "num_joint_tours*(tot_tours == 1) 18816 0 0 \n", + "num_joint_tours*(tot_tours == 2) 18816 0 0 \n", + "num_joint_tours*(tot_tours == 3) 18816 0 0 \n", + "num_joint_tours*(tot_tours == 4) 18816 0 0 \n", + "num_joint_tours*(tot_tours > 4) 18816 0 0 \n", + "num_main_j 18816 0 0 \n", + "num_shop_j 18816 0 0 \n", + "num_visi_j 18816 0 0 \n", "\n", " min 25% 50% \\\n", "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 0 0 0 \n", + "escort * no_cars 0 0 0 \n", + "has_preschool_kid_at_home * eatout 0 0 0 \n", + "has_preschool_kid_at_home * escort 0 0 0 \n", + "has_preschool_kid_at_home * othdiscr 0 0 0 \n", + "has_preschool_kid_at_home * othmaint 0 0 0 \n", + "has_preschool_kid_at_home * shopping 0 0 0 \n", "max_window*(tot_tours == 0) 0 0 0 \n", "max_window*(tot_tours == 1) 0 0 0 \n", "max_window*(tot_tours == 2) 0 0 0 \n", "max_window*(tot_tours == 3) 0 0 0 \n", "max_window*(tot_tours == 4) 0 0 0 \n", "max_window*(tot_tours > 4) 0 0 0 \n", + "no_cars & (tot_tours == 1) 0 0 0 \n", + "no_cars & (tot_tours == 2) 0 0 0 \n", + "no_cars & (tot_tours == 3) 0 0 0 \n", + "no_cars & (tot_tours == 4) 0 0 0 \n", + "no_cars & (tot_tours > 4) 0 0 0 \n", "num_disc_j 0 0 0 \n", "num_eat_j 0 0 0 \n", "num_joint_tours*(tot_tours == 0) 0 0 0 \n", @@ -647,12 +836,23 @@ "\n", " 75% max \n", "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 0 0 \n", + "escort * no_cars 0 0 \n", + "has_preschool_kid_at_home * eatout 0 0 \n", + "has_preschool_kid_at_home * escort 0 0 \n", + "has_preschool_kid_at_home * othdiscr 0 0 \n", + "has_preschool_kid_at_home * othmaint 0 0 \n", + "has_preschool_kid_at_home * shopping 0 0 \n", "max_window*(tot_tours == 0) 0 0 \n", "max_window*(tot_tours == 1) 0 0 \n", "max_window*(tot_tours == 2) 0 0 \n", "max_window*(tot_tours == 3) 0 0 \n", "max_window*(tot_tours == 4) 0 0 \n", "max_window*(tot_tours > 4) 0 0 \n", + "no_cars & (tot_tours == 1) 0 0 \n", + "no_cars & (tot_tours == 2) 0 0 \n", + "no_cars & (tot_tours == 3) 0 0 \n", + "no_cars & (tot_tours == 4) 0 0 \n", + "no_cars & (tot_tours > 4) 0 0 \n", "num_disc_j 0 0 \n", "num_eat_j 0 0 \n", "num_joint_tours*(tot_tours == 0) 0 0 \n", @@ -664,7 +864,7 @@ "num_main_j 0 0 \n", "num_shop_j 0 0 \n", "num_visi_j 0 0 \n", - "Running segment 'school' of size 211\n", + "Running segment 'school' of size 209\n", "WARNING: Describe of columns with no variability:\n" ] }, @@ -673,24 +873,24 @@ "stream": "stdout", "text": [ " count mean std \\\n", - "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 20256 0 0 \n", - "max_window*(tot_tours == 0) 20256 0 0 \n", - "max_window*(tot_tours == 1) 20256 0 0 \n", - "max_window*(tot_tours == 2) 20256 0 0 \n", - "max_window*(tot_tours == 3) 20256 0 0 \n", - "max_window*(tot_tours == 4) 20256 0 0 \n", - "max_window*(tot_tours > 4) 20256 0 0 \n", - "num_disc_j 20256 0 0 \n", - "num_eat_j 20256 0 0 \n", - "num_joint_tours*(tot_tours == 0) 20256 0 0 \n", - "num_joint_tours*(tot_tours == 1) 20256 0 0 \n", - "num_joint_tours*(tot_tours == 2) 20256 0 0 \n", - "num_joint_tours*(tot_tours == 3) 20256 0 0 \n", - "num_joint_tours*(tot_tours == 4) 20256 0 0 \n", - "num_joint_tours*(tot_tours > 4) 20256 0 0 \n", - "num_main_j 20256 0 0 \n", - "num_shop_j 20256 0 0 \n", - "num_visi_j 20256 0 0 \n", + "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 20064 0 0 \n", + "max_window*(tot_tours == 0) 20064 0 0 \n", + "max_window*(tot_tours == 1) 20064 0 0 \n", + "max_window*(tot_tours == 2) 20064 0 0 \n", + "max_window*(tot_tours == 3) 20064 0 0 \n", + "max_window*(tot_tours == 4) 20064 0 0 \n", + "max_window*(tot_tours > 4) 20064 0 0 \n", + "num_disc_j 20064 0 0 \n", + "num_eat_j 20064 0 0 \n", + "num_joint_tours*(tot_tours == 0) 20064 0 0 \n", + "num_joint_tours*(tot_tours == 1) 20064 0 0 \n", + "num_joint_tours*(tot_tours == 2) 20064 0 0 \n", + "num_joint_tours*(tot_tours == 3) 20064 0 0 \n", + "num_joint_tours*(tot_tours == 4) 20064 0 0 \n", + "num_joint_tours*(tot_tours > 4) 20064 0 0 \n", + "num_main_j 20064 0 0 \n", + "num_shop_j 20064 0 0 \n", + "num_visi_j 20064 0 0 \n", "\n", " min 25% 50% \\\n", "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 0 0 0 \n", @@ -731,7 +931,7 @@ "num_main_j 0 0 \n", "num_shop_j 0 0 \n", "num_visi_j 0 0 \n", - "Running segment 'university' of size 81\n", + "Running segment 'university' of size 98\n", "WARNING: Describe of columns with no variability:\n" ] }, @@ -740,24 +940,24 @@ "stream": "stdout", "text": [ " count mean std \\\n", - "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 7776 0 0 \n", - "max_window*(tot_tours == 0) 7776 0 0 \n", - "max_window*(tot_tours == 1) 7776 0 0 \n", - "max_window*(tot_tours == 2) 7776 0 0 \n", - "max_window*(tot_tours == 3) 7776 0 0 \n", - "max_window*(tot_tours == 4) 7776 0 0 \n", - "max_window*(tot_tours > 4) 7776 0 0 \n", - "num_disc_j 7776 0 0 \n", - "num_eat_j 7776 0 0 \n", - "num_joint_tours*(tot_tours == 0) 7776 0 0 \n", - "num_joint_tours*(tot_tours == 1) 7776 0 0 \n", - "num_joint_tours*(tot_tours == 2) 7776 0 0 \n", - "num_joint_tours*(tot_tours == 3) 7776 0 0 \n", - "num_joint_tours*(tot_tours == 4) 7776 0 0 \n", - "num_joint_tours*(tot_tours > 4) 7776 0 0 \n", - "num_main_j 7776 0 0 \n", - "num_shop_j 7776 0 0 \n", - "num_visi_j 7776 0 0 \n", + "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 9408 0 0 \n", + "max_window*(tot_tours == 0) 9408 0 0 \n", + "max_window*(tot_tours == 1) 9408 0 0 \n", + "max_window*(tot_tours == 2) 9408 0 0 \n", + "max_window*(tot_tours == 3) 9408 0 0 \n", + "max_window*(tot_tours == 4) 9408 0 0 \n", + "max_window*(tot_tours > 4) 9408 0 0 \n", + "num_disc_j 9408 0 0 \n", + "num_eat_j 9408 0 0 \n", + "num_joint_tours*(tot_tours == 0) 9408 0 0 \n", + "num_joint_tours*(tot_tours == 1) 9408 0 0 \n", + "num_joint_tours*(tot_tours == 2) 9408 0 0 \n", + "num_joint_tours*(tot_tours == 3) 9408 0 0 \n", + "num_joint_tours*(tot_tours == 4) 9408 0 0 \n", + "num_joint_tours*(tot_tours > 4) 9408 0 0 \n", + "num_main_j 9408 0 0 \n", + "num_shop_j 9408 0 0 \n", + "num_visi_j 9408 0 0 \n", "\n", " min 25% 50% \\\n", "(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0) 0 0 0 \n", @@ -799,40 +999,40 @@ "num_shop_j 0 0 \n", "num_visi_j 0 0 \n", "Choices:\n", - "0 1115\n", - "18 55\n", - "64 51\n", - "77 42\n", - "34 40\n", + "0 1117\n", + "18 62\n", + "64 55\n", + "34 47\n", + "77 39\n", "95 36\n", - "84 28\n", - "36 27\n", - "48 26\n", - "6 25\n", - "68 21\n", + "68 26\n", "70 20\n", - "31 18\n", - "86 10\n", - "22 8\n", + "6 19\n", + "48 18\n", + "36 17\n", + "86 15\n", + "31 15\n", + "80 11\n", + "14 11\n", "...\n", - "15 1\n", - "5 1\n", - "46 1\n", + "58 2\n", "32 1\n", - "92 1\n", - "85 1\n", - "47 1\n", - "52 1\n", - "55 1\n", - "58 1\n", - "61 1\n", - "89 1\n", - "72 1\n", - "78 1\n", + "59 1\n", + "2 1\n", + "79 1\n", + "88 1\n", + "73 1\n", + "56 1\n", + "33 1\n", "50 1\n", - "Length: 74, dtype: int64\n", - "Time to execute model 'non_mandatory_tour_frequency': 12.86s\n", - "Total time to execute: 12.86s\n" + "94 1\n", + "20 1\n", + "44 1\n", + "92 1\n", + "49 1\n", + "Length: 71, dtype: int64\n", + "Time to execute model 'non_mandatory_tour_frequency': 12.80s\n", + "Total time to execute: 12.80s\n" ] } ], @@ -842,7 +1042,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "sim.get_table(\"non_mandatory_tours\").trip_type.value_counts()" + "sim.get_table(\"non_mandatory_tours\").tour_type.value_counts()" ], "language": "python", "metadata": {}, @@ -852,12 +1052,12 @@ "output_type": "pyout", "prompt_number": 7, "text": [ - "escort 693\n", - "eatout 337\n", - "social 326\n", - "shopping 276\n", - "othdiscr 199\n", - "othmaint 183\n", + "escort 662\n", + "social 332\n", + "eatout 295\n", + "shopping 258\n", + "othdiscr 188\n", + "othmaint 182\n", "dtype: int64" ] } @@ -878,15 +1078,7 @@ "stream": "stdout", "text": [ "Running model 'destination_choice'\n", - "Running segment 'eatout' of size 337" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Running segment 'othdiscr' of size 199" + "1917" ] }, { @@ -894,7 +1086,8 @@ "stream": "stdout", "text": [ "\n", - "Running segment 'othmaint' of size 183" + "Running segment 'eatout' of size 295\n", + "Running segment 'othdiscr' of size 188" ] }, { @@ -902,7 +1095,7 @@ "stream": "stdout", "text": [ "\n", - "Running segment 'shopping' of size 276" + "Running segment 'othmaint' of size 182" ] }, { @@ -910,7 +1103,8 @@ "stream": "stdout", "text": [ "\n", - "Running segment 'social' of size 326" + "Running segment 'shopping' of size 258\n", + "Running segment 'social' of size 332" ] }, { @@ -925,17 +1119,17 @@ "output_type": "stream", "stream": "stdout", "text": [ - "count 10070.000000\n", - "mean 731.969513\n", - "std 412.938868\n", - "min 1.000000\n", - "25% 418.000000\n", - "50% 748.000000\n", - "75% 1099.000000\n", - "max 1453.000000\n", + "count 1255.000000\n", + "mean 733.726693\n", + "std 426.865923\n", + "min 2.000000\n", + "25% 377.000000\n", + "50% 722.000000\n", + "75% 1131.000000\n", + "max 1451.000000\n", "Name: TAZ, dtype: float64\n", - "Time to execute model 'destination_choice': 3.36s\n", - "Total time to execute: 3.36s\n" + "Time to execute model 'destination_choice': 2.65s\n", + "Total time to execute: 2.65s\n" ] } ], @@ -945,7 +1139,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "sim.run([\"mandatory_tour_departure_and_duration\"])" + "sim.run([\"tour_departure_and_duration_mandatory\"])" ], "language": "python", "metadata": {}, @@ -954,8 +1148,8 @@ "output_type": "stream", "stream": "stdout", "text": [ - "Running model 'mandatory_tour_departure_and_duration'\n", - "Running 1511 mandatory tour scheduling choices" + "Running model 'tour_departure_and_duration_mandatory'\n", + "Running 1466 mandatory tour scheduling choices" ] }, { @@ -963,42 +1157,20 @@ "stream": "stdout", "text": [ "\n", - "work_and_school 660\n", - "work2 524\n", - "work1 160\n", - "school2 112\n", - "school1 55\n", + "work_and_school 644\n", + "work2 442\n", + "work1 179\n", + "school2 134\n", + "school1 67\n", "dtype: int64\n", - "Expression\n", - "roundtrip_auto_time_to_work * start 0.00114\n", - "roundtrip_auto_time_to_work * duration 0.00221\n", - "(ptype == 2) * start 0.06736\n", - "(ptype == 4) * duration 0.12070\n", - "(ptype == 3) * start 0.05747\n", - "income_in_thousands * start 0.00021\n", - "workplace_in_cbd * start 0.04717\n", - "workplace_in_cbd * duration 0.08679\n", - "(start < end_of_previous_tour) & (tour_num == 2) -999.00000\n", - "(tour_num == 1) * start 0.30330\n", - "(tour_num == 1) * duration 0.18610\n", - "(tour_num == 2) * start 0.53810\n", - "(tour_num == 2) * duration 0.31740\n", - "(income_in_thousands > 100) & (start < 6) 0.48540\n", - "(income_in_thousands > 100) & (end > 22) 0.38390\n", - "workplace_in_cbd & (start < 6) 0.45660\n", - "workplace_in_cbd & (end > 22) 0.23340\n", - "home_is_rural & (start < 6) 0.40390\n", - "home_is_rural & (end > 22) 0.34510\n", - "(ptype == 1) & (duration < 9) 1.25700\n", - "(ptype == 1) & (start > 9) & (start < 13) 0.51820\n", - "(ptype == 2) & (end > 12) & (end < 16) 0.54330\n", - "(tour_num == 1) & (duration < 8) 1.98000\n", - "(tour_num == 2) & (duration < 8) 2.58200\n", - "(mandatory_tour_frequency == 'work_and_school') & is_worker & (duration < 8) 0.91260\n", - "(mandatory_tour_frequency == 'work_and_school') & is_student & (duration < 8) 2.58200\n", - "mode_choice_logsum 1.02700\n", - "Name: work, dtype: float64\n", - "Running 863 mandatory first tour choices\n", + " Coefficient\n", + "Expression \n", + "(tour_num == 1) & (duration < 8) 1.9800\n", + "(tour_num == 2) & (duration < 8) 2.5820\n", + "(mandatory_tour_frequency == 'work_and_school') & is_worker & (duration < 8) 0.9126\n", + "(mandatory_tour_frequency == 'work_and_school') & is_student & (duration < 8) 2.5820\n", + "mode_choice_logsum 1.0270\n", + "Running 856 mandatory first tour choices\n", "WARNING: Describe of columns with no variability:\n" ] }, @@ -1023,7 +1195,7 @@ "home_is_rural & (end > 22) 0 0 0 \n", "home_is_rural & (start < 6) 0 0 0 \n", "mode_choice_logsum 0 0 0 \n", - "Running 648 mandatory second tour choices" + "Running 610 mandatory second tour choices" ] }, { @@ -1058,15 +1230,37 @@ "home_is_rural & (start < 6) 0 0 0 \n", "mode_choice_logsum 0 0 0 \n", "Choices:\n", - "count 1511.000000\n", - "mean 85.776969\n", - "std 59.065077\n", + "count 1466.000000\n", + "mean 88.510232\n", + "std 57.398650\n", "min 0.000000\n", - "25% 29.000000\n", - "50% 83.000000\n", - "75% 136.000000\n", + "25% 38.000000\n", + "50% 85.000000\n", + "75% 139.000000\n", "max 189.000000\n", - "dtype: float64" + "dtype: float64\n", + "Time to execute model 'tour_departure_and_duration_mandatory': 3.47s\n", + "Total time to execute: 3.47s\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "sim.run([\"tour_departure_and_duration_non_mandatory\"])" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Running model 'tour_departure_and_duration_non_mandatory'\n", + "Running 1917 non-mandatory tour scheduling choices" ] }, { @@ -1074,12 +1268,126 @@ "stream": "stdout", "text": [ "\n", - "Time to execute model 'mandatory_tour_departure_and_duration': 3.43s\n", - "Total time to execute: 3.43s\n" + "Expression\n", + "start < end_of_previous_tour 999.00000\n", + "roundtrip_auto_time_to_work * duration 0.00474\n", + "(tour_type == \"shopping\") * start 0.06015\n", + "(tour_type == \"shopping\") * duration 0.12080\n", + "Name: Coefficient, dtype: float64\n", + "Running 566 non-mandatory #1 tour choices\n", + "WARNING: Describe of columns with no variability:\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " count mean std min 25% 50% 75% max\n", + "start < end_of_previous_tour 100000 0 0 0 0 0 0 0\n", + "Running 561 non-mandatory #2 tour choices\n", + "WARNING: Describe of columns with no variability:\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " count mean std min 25% 50% 75% max\n", + "start < end_of_previous_tour 100000 0 0 0 0 0 0 0\n", + "Running 327 non-mandatory #3 tour choices\n", + "WARNING: Describe of columns with no variability:\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " count mean std min 25% 50% 75% max\n", + "start < end_of_previous_tour 62130 0 0 0 0 0 0 0\n", + "Running 230 non-mandatory #4 tour choices\n", + "WARNING: Describe of columns with no variability:\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " count mean std min 25% 50% 75% \\\n", + "(tour_type == \"shopping\") * duration 43700 0 0 0 0 0 0 \n", + "(tour_type == \"shopping\") * start 43700 0 0 0 0 0 0 \n", + "start < end_of_previous_tour 43700 0 0 0 0 0 0 \n", + "\n", + " max \n", + "(tour_type == \"shopping\") * duration 0 \n", + "(tour_type == \"shopping\") * start 0 \n", + "start < end_of_previous_tour 0 \n", + "Running 146 non-mandatory #5 tour choices\n", + "WARNING: Describe of columns with no variability:\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " count mean std min 25% 50% 75% \\\n", + "(tour_type == \"shopping\") * duration 27740 0 0 0 0 0 0 \n", + "(tour_type == \"shopping\") * start 27740 0 0 0 0 0 0 \n", + "start < end_of_previous_tour 27740 0 0 0 0 0 0 \n", + "\n", + " max \n", + "(tour_type == \"shopping\") * duration 0 \n", + "(tour_type == \"shopping\") * start 0 \n", + "start < end_of_previous_tour 0 \n", + "Running 51 non-mandatory #6 tour choices\n", + "WARNING: Describe of columns with no variability:\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " count mean std min 25% 50% 75% \\\n", + "(tour_type == \"shopping\") * duration 9690 0 0 0 0 0 0 \n", + "(tour_type == \"shopping\") * start 9690 0 0 0 0 0 0 \n", + "start < end_of_previous_tour 9690 0 0 0 0 0 0 \n", + "\n", + " max \n", + "(tour_type == \"shopping\") * duration 0 \n", + "(tour_type == \"shopping\") * start 0 \n", + "start < end_of_previous_tour 0 \n", + "Running 36 non-mandatory #7 tour choices\n", + "WARNING: Describe of columns with no variability:\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " count mean std min 25% 50% 75% \\\n", + "(tour_type == \"shopping\") * duration 6840 0 0 0 0 0 0 \n", + "(tour_type == \"shopping\") * start 6840 0 0 0 0 0 0 \n", + "start < end_of_previous_tour 6840 0 0 0 0 0 0 \n", + "\n", + " max \n", + "(tour_type == \"shopping\") * duration 0 \n", + "(tour_type == \"shopping\") * start 0 \n", + "start < end_of_previous_tour 0 \n", + "Choices:\n", + "count 1917.000000\n", + "mean 31.080334\n", + "std 33.082042\n", + "min 1.000000\n", + "25% 18.000000\n", + "50% 18.000000\n", + "75% 18.000000\n", + "max 188.000000\n", + "dtype: float64\n", + "Time to execute model 'tour_departure_and_duration_non_mandatory': 3.31s\n", + "Total time to execute: 3.31s\n" ] } ], - "prompt_number": 42 + "prompt_number": 22 }, { "cell_type": "code",