diff --git a/activitysim/activitysim.py b/activitysim/activitysim.py index 6148e20ab..846508dc1 100644 --- a/activitysim/activitysim.py +++ b/activitysim/activitysim.py @@ -14,13 +14,16 @@ def random_rows(df, n): def read_model_spec(fname, description_name="Description", - expression_name="Expression"): + expression_name="Expression", + stack=True): """ Read in the excel file and reformat for machines """ cfg = pd.read_csv(fname) # don't need description and set the expression to the index - cfg = cfg.drop(description_name, axis=1).set_index(expression_name).stack() + cfg = cfg.drop(description_name, axis=1).set_index(expression_name) + if stack: + cfg = cfg.stack() return cfg @@ -93,7 +96,11 @@ def simple_simulate(choosers, alternatives, spec, if mult_by_alt_col: expr = "({}) * df.{}".format(expr[0][1:], expr[1]) else: - expr = expr[0][1:] + if isinstance(expr, tuple): + expr = expr[0][1:] + else: + # it's already a string, but need to remove the "@" + expr = expr[1:] try: s = eval(expr) except Exception as e: @@ -103,7 +110,11 @@ def simple_simulate(choosers, alternatives, spec, if mult_by_alt_col: expr = "({}) * {}".format(*expr) else: - expr = expr[0] + if isinstance(expr, tuple): + expr = expr[0] + else: + # it's already a string, which is fine + pass try: s = df.eval(expr) except Exception as e: diff --git a/activitysim/defaults/datasources.py b/activitysim/defaults/datasources.py index 50f0bd245..5d4d80067 100644 --- a/activitysim/defaults/datasources.py +++ b/activitysim/defaults/datasources.py @@ -17,7 +17,7 @@ pd.options.mode.chained_assignment = None -@sim.injectable('settings', cache=True) +@sim.injectable(cache=True) def settings(): with open(os.path.join(misc.configs_dir(), "settings.yaml")) as f: settings = yaml.load(f) @@ -27,24 +27,24 @@ def settings(): return settings -@sim.injectable('run_number') +@sim.injectable() def run_number(): return misc.get_run_number() -@sim.injectable('uuid', cache=True) -def uuid_hex(): +@sim.injectable(cache=True) +def uuid(): return uuid.uuid4().hex -@sim.injectable('store', cache=True) -def hdfstore(settings): +@sim.injectable(cache=True) +def store(settings): return pd.HDFStore( os.path.join(misc.data_dir(), settings["store"]), mode='r') -@sim.injectable("scenario") +@sim.injectable() def scenario(settings): return settings["scenario"] diff --git a/activitysim/defaults/variables.py b/activitysim/defaults/variables.py index c50a58bba..03b8af8b2 100644 --- a/activitysim/defaults/variables.py +++ b/activitysim/defaults/variables.py @@ -20,6 +20,11 @@ def income_segment(households): labels=[1, 2, 3, 4]) +@sim.column("households") +def non_workers(households, persons): + return persons.household_id.value_counts() - households.workers + + @sim.column("households") def drivers(households, persons): # we assume that everyone 16 and older is a potential driver diff --git a/example/README.md b/example/README.md new file mode 100644 index 000000000..e6d289871 --- /dev/null +++ b/example/README.md @@ -0,0 +1,77 @@ +This is a list of items to double check before using in practice: + +* Make sure the units in things like distance_to_work match the walk thresholds + in the mandatory tour frequency spec. The original divided by 100. This is + true also of round trip auto to work and round trip auto to school. + +* There might be a few variables left off of some of the models. Look for +`head` in reading of the spec files as this is meant to eliminate some of the + rows. Also can look for `#` to comment out variables in the spec. + +* Go back to the 3 school location choices, and run the models for the +appropriate persons. + +* Probably needs code review of the variable definitions. How much of the +variable definitions are shared between regions and how much unique? Age +categories are shared? Income categories are unique? + +* This will be pretty easy to catch, but need to make sure the +non_mandatory_tour model runs with Matt's changes to simple simulate that are + coming. + + + +A few overarching principles + +* A little discussion of "NOT so object oriented" - this is more like a +database - data is in standard tables, NOT in objects... although the +simulation framework is sort of like adding methods to objects + +* The implications of this are that most of the core code is pandas and thus +the quality is controlled by the larger community. We are thankful that its +quality is very high. Specifically, there's not so much code in activitysim +"proper" + +* What it takes to add a new model + * define a new model + * define any new data sources necessary + * add any new assumptions in settings.yaml + * co-create the spec and any variables that are too complicated (or + reusable) for the spec + * run in notebook + +* Literally everything is really Python functions that compute something. +Case study of `num_under16_not_at_school` to show the inter-dependencies. + + + + +A few questions about "best practices" + +* What to put into the default data sources and variable specs and what to +put in the example / client-specific stuff? + +* Want to split up injectables from variables from tables or all one big file + so it's easier to search? + +* How much variable computation to put in excel versus Python + +* There were some hard coded limits in the original csv - (area_type < 4 and +distance_to_work < 3) - these are now just left in the csv spec. Why would +this be different than (income_in_thousands > 50)? I've made an effort to +not have such "magic numbers" in Python code. EDIT: I've now added an +`isurban` variable which reads the area_type from the settings.yaml. So my +convention so far is to leave hard-coded numbers out of the Python, +but putting them in the CSV is ok. (Elizabeth: MAX_NUM_AUTOS exists now) + +* Want to name or number the person types in the spec files? + +* We're verging on the need to use YAML to configure the model runs - give +the non_mandatory_tour model as an example. Is this too much code for a +modeler to manage or is this just right as it makes the model execution +transparent to the modeler? + +* Big issue: testing for client-specific code? It's harder because outputs are "data +dependent." It's easier to take a small dataset and make sure it always runs. + +* Should I go back and put the Q&A I've had with Dave as issues on github to save for posterity? diff --git a/example/configs/auto_ownership.csv b/example/configs/auto_ownership.csv new file mode 100644 index 000000000..cc1dae874 --- /dev/null +++ b/example/configs/auto_ownership.csv @@ -0,0 +1,30 @@ +Description,Expression,cars0,cars1,cars2,cars3,cars4 +2 Adults (age 16+),drivers==2,,0,3.0773,3.1962,2.6616 +3 Adults (age 16+),drivers==3,,0,3.5401,5.5131,5.208 +4+ Adults (age 16+),drivers>3,,2.0107,6.3662,8.5148,9.5807 +Persons age 16-17,num_adolescents,,0,-0.881,-1.7313,-1.7313 +Persons age 18-24,num_college_age,,-0.4087,-1.0095,-1.0107,-1.0107 +Persons age 35-34,num_young_adults,,0,-0.4849,-0.8596,-0.8596 +Presence of children age 0-4,num_young_children>0,,0.3669,0.7627,0.7627,0.7627 +Presence of children age 5-17,(num_children+num_adolescents)>0,,0.0158,0.2936,0.4769,0.4769 +"Number of workers, capped at 3",@df.workers.clip(upper=3),,0,0.2936,0.6389,0.8797 +"Piecewise Linear household income, $0-30k","@df.income_in_thousands.clip(0, 30)",,0.0383,0.054,0.0559,0.0619 +"Piecewise Linear household income, $30-75k","@(df.income_in_thousands-30).clip(0, 45)",,0,0.0083,0.011,0.0147 +"Piecewise Linear household income, $75k+, capped at $125k","@(df.income_in_thousands-75).clip(0, 50)",,0,0.0083,0.011,0.0147 +"Density index up to 10, if 0 workers","@(df.workers==0)*df.density_index.clip(0, 10)",,0,-0.2028,-0.3654,-0.3654 +"Density index in excess of 10, if 0 workers",@(df.workers==0)*(df.density_index-10).clip(0),,-0.0152,-0.1106,-0.1766,-0.1766 +"Density index up to 10, if 1+ workers","@(df.workers>0)*df.density_index.clip(0, 10)",,0,-0.2028,-0.3654,-0.3654 +"Density index in excess of 10, if 1+ workers",@(df.workers>0)*(df.density_index-10).clip(0),,-0.0152,-0.1106,-0.1766,-0.1766 +Constants,@1,,1.1865,-1.0846,-3.2502,-5.313 +San Francisco county,county_name == 'San Francisco',,0.4259,0.4683,0.1458,0.1458 +Solano county,county_name == 'Solano',,-0.566,-0.4429,-0.2372,-0.2372 +Napa county,county_name == 'Napa',,-0.566,-0.4429,-0.2372,-0.2372 +Sonoma county,county_name == 'Sonoma',,-0.566,-0.4429,-0.2372,-0.2372 +Marin county,county_name == 'Marin',,-0.2434,0,0,0 +"Retail accessibility (0.66*PK + 0.34*OP) by auto, if 0 workers",(workers==0)*(0.66*AUTOPEAKRETAIL+0.34*AUTOOFFPEAKRETAIL),,0.0626,0.0626,0.0626,0.0626 +"Retail accessibility (0.66*PK + 0.34*OP) by auto, if 1+ workers",(workers>0)*(0.66*AUTOPEAKRETAIL+0.34*AUTOOFFPEAKRETAIL),,0.1646,0.1646,0.1646,0.1646 +"Retail accessibility (0.66*PK + 0.34*OP) by transit, if 0 workers",(workers==0)*(0.66*TRANSITPEAKRETAIL+0.34*TRANSITOFFPEAKRETAIL),,-0.3053,-0.3053,-0.3053,-0.3053 +"Retail accessibility (0.66*PK + 0.34*OP) by transit, if 1+ workers",(workers>0)*(0.66*TRANSITPEAKRETAIL+0.34*TRANSITOFFPEAKRETAIL),,-0.5117,-0.5117,-0.5117,-0.5117 +"Retail accessibility by non-motorized, if 0 workers",(workers==0)*NONMOTORIZEDRETAIL,,-0.03,-0.03,-0.03,-0.03 +"Retail accessibility by non-motorized, if 1+ workers",(workers>0)*NONMOTORIZEDRETAIL,,-0.03,-0.03,-0.03,-0.03 +"Auto time savings per worker (over walk or transit, max 120) to work",workTourAutoTimeSavings/workers,,0.4707,0.6142,0.5705,0.7693 diff --git a/example/configs/auto_ownership_coeffs.csv b/example/configs/auto_ownership_coeffs.csv deleted file mode 100644 index 0fe176c11..000000000 --- a/example/configs/auto_ownership_coeffs.csv +++ /dev/null @@ -1 +0,0 @@ -Description,Expression,cars0,cars1,cars2,cars3,cars4 2 Adults (age 16+),drivers==2,,0,3.0773,3.1962,2.6616 3 Adults (age 16+),drivers==3,,0,3.5401,5.5131,5.208 4+ Adults (age 16+),drivers>3,,2.0107,6.3662,8.5148,9.5807 Persons age 16-17,num_adolescents,,0,-0.881,-1.7313,-1.7313 Persons age 18-24,num_college_age,,-0.4087,-1.0095,-1.0107,-1.0107 Persons age 35-34,num_young_adults,,0,-0.4849,-0.8596,-0.8596 Presence of children age 0-4,num_young_children>0,,0.3669,0.7627,0.7627,0.7627 Presence of children age 5-17,(num_children+num_adolescents)>0,,0.0158,0.2936,0.4769,0.4769 "Number of workers, capped at 3",@df.workers.clip(upper=3),,0,0.2936,0.6389,0.8797 "Piecewise Linear household income, $0-30k","@df.income_in_thousands.clip(0, 30)",,0.0383,0.054,0.0559,0.0619 "Piecewise Linear household income, $30-75k","@(df.income_in_thousands-30).clip(0, 45)",,0,0.0083,0.011,0.0147 "Piecewise Linear household income, $75k+, capped at $125k","@(df.income_in_thousands-75).clip(0, 50)",,0,0.0083,0.011,0.0147 "Density index up to 10, if 0 workers","@(df.workers==0)*df.density_index.clip(0, 10)",,0,-0.2028,-0.3654,-0.3654 "Density index in excess of 10, if 0 workers",@(df.workers==0)*(df.density_index-10).clip(0),,-0.0152,-0.1106,-0.1766,-0.1766 "Density index up to 10, if 1+ workers","@(df.workers>0)*df.density_index.clip(0, 10)",,0,-0.2028,-0.3654,-0.3654 "Density index in excess of 10, if 1+ workers",@(df.workers>0)*(df.density_index-10).clip(0),,-0.0152,-0.1106,-0.1766,-0.1766 Constants,@1,,1.1865,-1.0846,-3.2502,-5.313 San Francisco county,county_name == 'San Francisco',,0.4259,0.4683,0.1458,0.1458 Solano county,county_name == 'Solano',,-0.566,-0.4429,-0.2372,-0.2372 Napa county,county_name == 'Napa',,-0.566,-0.4429,-0.2372,-0.2372 Sonoma county,county_name == 'Sonoma',,-0.566,-0.4429,-0.2372,-0.2372 Marin county,county_name == 'Marin',,-0.2434,0,0,0 "Retail accessibility (0.66*PK + 0.34*OP) by auto, if 0 workers",(workers==0)*(0.66*AUTOPEAKRETAIL+0.34*AUTOOFFPEAKRETAIL),,0.0626,0.0626,0.0626,0.0626 "Retail accessibility (0.66*PK + 0.34*OP) by auto, if 1+ workers",(workers>0)*(0.66*AUTOPEAKRETAIL+0.34*AUTOOFFPEAKRETAIL),,0.1646,0.1646,0.1646,0.1646 "Retail accessibility (0.66*PK + 0.34*OP) by transit, if 0 workers",(workers==0)*(0.66*TRANSITPEAKRETAIL+0.34*TRANSITOFFPEAKRETAIL),,-0.3053,-0.3053,-0.3053,-0.3053 "Retail accessibility (0.66*PK + 0.34*OP) by transit, if 1+ workers",(workers>0)*(0.66*TRANSITPEAKRETAIL+0.34*TRANSITOFFPEAKRETAIL),,-0.5117,-0.5117,-0.5117,-0.5117 "Retail accessibility by non-motorized, if 0 workers",(workers==0)*NONMOTORIZEDRETAIL,,-0.03,-0.03,-0.03,-0.03 "Retail accessibility by non-motorized, if 1+ workers",(workers>0)*NONMOTORIZEDRETAIL,,-0.03,-0.03,-0.03,-0.03 "Auto time savings per worker (over walk or transit, max 120) to work",workTourAutoTimeSavings/workers,,0.4707,0.6142,0.5705,0.7693 \ No newline at end of file diff --git a/example/configs/destination_choice.csv b/example/configs/destination_choice.csv new file mode 100644 index 000000000..9f239eafd --- /dev/null +++ b/example/configs/destination_choice.csv @@ -0,0 +1,10 @@ +Description,Expression,university,highschool,gradeschool,escortkids,escortnokids,shopping,eatout,othmaint,social,othdiscr,workbased +Sample of alternatives correction factor,"min(dcSoaCorrections,60)",1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000 +"Distance, piecewise linear from 0 to 1 miles","if(distance<1.0,distance,1.0)",-3.2451,-0.9523,-1.6419,-0.1499,-0.1499,0.0000,-0.5609,0.0000,-0.7841,-0.1677,-0.7926 +"Distance, piecewise linear from 1 to 2 miles","if(distance<2.0,distance-1.0,1.0)",-2.7011,-0.5700,-0.5700,-0.1499,-0.1499,0.0000,-0.5609,0.0000,-0.7841,-0.1677,-0.7926 +"Distance, piecewise linear from 2 to 5 miles","if(distance<5.0,distance-2.0,3.0)",-0.5707,-0.5700,-0.5700,-0.8671,-0.8671,-0.5655,-0.3192,-0.6055,-0.3485,-0.4955,-0.5197 +"Distance, piecewise linear from 5 to 15 miles","if(distance<15.0,distance-5.0,10.0)",-0.5002,-0.1930,-0.2031,-0.2137,-0.2137,-0.1832,-0.1238,-0.1093,-0.1306,-0.1193,-0.2045 +"Distance, piecewise linear for 15+ miles",distance-15.0,-0.0730,-0.1882,-0.0460,-0.2137,-0.2137,-0.1832,-0.1238,-0.1093,-0.1306,-0.1193,-0.2045 +Mode choice logsum,mcLogsum,0.5358,0.5358,0.5358,0.6755,0.6755,0.6755,0.6755,0.6755,0.6755,0.6755,0.5136 +Size variable,sizeTerm,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000 +No attractions,"if(sizeTerm==0,1,0)",-999.0000,-999.0000,-999.0000,-999.0000,-999.0000,-999.0000,-999.0000,-999.0000,-999.0000,-999.0000,-999.0000 \ No newline at end of file diff --git a/example/configs/destination_choice_alternatives_sample.csv b/example/configs/destination_choice_alternatives_sample.csv new file mode 100644 index 000000000..2a33dac44 --- /dev/null +++ b/example/configs/destination_choice_alternatives_sample.csv @@ -0,0 +1,9 @@ +Description,Expression,worklow,workmed,workhigh,workveryhigh,university,highschool,gradeschool,escortkids,escortnokids,shopping,eatout,othmaint,social,othdiscr,workbased +"Distance, piecewise linear from 0 to 1 miles",@df.distance.clip(1),-0.8428,-0.8428,-0.8428,-0.8428,-3.2451,-0.9523,-1.6419,-0.1499,-0.1499,0,-0.5609,0,-0.7841,-0.1677,-0.7926 +"Distance, piecewise linear from 1 to 2 miles","@(df.distance-1).clip(0,1)",-0.3104,-0.3104,-0.3104,-0.3104,-2.7011,-0.57,-0.57,-0.1499,-0.1499,0,-0.5609,0,-0.7841,-0.1677,-0.7926 +"Distance, piecewise linear from 2 to 5 miles","@(df.distance-2).clip(0,3)",-0.3783,-0.3783,-0.3783,-0.3783,-0.5707,-0.57,-0.57,-0.8671,-0.8671,-0.5655,-0.3192,-0.6055,-0.3485,-0.4955,-0.5197 +"Distance, piecewise linear from 5 to 15 miles","@(df.distance-5).clip(0,10)",-0.1285,-0.1285,-0.1285,-0.1285,-0.5002,-0.193,-0.2031,-0.2137,-0.2137,-0.1832,-0.1238,-0.1093,-0.1306,-0.1193,-0.2045 +"Distance, piecewise linear for 15+ miles",@(df.distance-15.0).clip(0),-0.0917,-0.0917,-0.0917,-0.0917,-0.073,-0.1882,-0.046,-0.2137,-0.2137,-0.1832,-0.1238,-0.1093,-0.1306,-0.1193,-0.2045 +Size variable,@(df.income_segment==1)*df.size_low,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 +No attractions,@(df.income_segment==1)*df.size_low == 0,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999,-999 +Destination taz is home taz,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 \ No newline at end of file diff --git a/example/configs/destination_choice_size_terms.csv b/example/configs/destination_choice_size_terms.csv new file mode 100644 index 000000000..6ef694785 --- /dev/null +++ b/example/configs/destination_choice_size_terms.csv @@ -0,0 +1,16 @@ +purpose,segment,TOTHH,RETEMPN,FPSEMPN,HEREMPN,OTHEMPN,AGREMPN,MWTEMPN,AGE0519,HSENROLL,COLLFTE,COLLPTE +work,low,0,0.129,0.193,0.383,0.12,0.01,0.164,0,0,0,0 +work,med,0,0.12,0.197,0.325,0.139,0.008,0.21,0,0,0,0 +work,high,0,0.11,0.207,0.284,0.154,0.006,0.239,0,0,0,0 +work,veryhigh,0,0.093,0.27,0.241,0.146,0.004,0.246,0,0,0,0 +university,university,0,0,0,0,0,0,0,0,0,0.592,0.408 +school,grade,0,0,0,0,0,0,0,1,0,0,0 +school,high,0,0,0,0,0,0,0,0,1,0,0 +escort,kids,0,0.225,0,0.144,0,0,0,0.465,0.166,0,0 +escort,no kids,0,0.225,0,0.144,0,0,0,0.465,0.166,0,0 +shopping,shopping,0,1,0,0,0,0,0,0,0,0,0 +eatOut,eatOut,0,0.742,0,0.258,0,0,0,0,0,0,0 +othMaint,othMaint,0,0.482,0,0.518,0,0,0,0,0,0,0 +social,social,0,0.522,0,0.478,0,0,0,0,0,0,0 +othDiscr,othDiscr,0.252,0.212,0,0.272,0.165,0,0,0,0.098,0,0 +atwork,atwork,0,0.742,0,0.258,0,0,0,0,0,0,0 diff --git a/example/configs/mandatory_tour_frequency.csv b/example/configs/mandatory_tour_frequency.csv new file mode 100644 index 000000000..854505462 --- /dev/null +++ b/example/configs/mandatory_tour_frequency.csv @@ -0,0 +1,100 @@ +Description,Expression,work1,work2,school1,school2,work_and_school +Full-time worker alternative-specific constants,ptype == 1,0,-3.3781,,, +Part-time worker alternative-specific constants,ptype == 2,0,-3.0476,,, +University student alternative-specific constants,ptype == 3,2.166,-1.3965,0,-3.7429,0.1073 +Non-working adult alternative-specific constants,ptype == 4,,,,, +Retired alternative-specific constants,ptype == 5,,,,, +Driving-age child alternative-specific constants,ptype == 6,,,0,-3.136,-4.4362 +Pre-driving age child who is in school alternative-specific constants,ptype == 7,,,0,-3.9703, +Female - Full-time worker interaction,(ptype == 1) & female,0,-0.2255,0.1592,,-0.3442 +Female - Part-time worker interaction,(ptype == 2) & female,0,-0.2255,0.1592,,-0.3442 +Female - University student interaction,(ptype == 3) & female,0.1737,-0.2255,0.1592,0.114,-0.3442 +Female - Non-working adult interaction,(ptype == 4) & female,0,-0.2255,0.1592,, +Female - Retired interaction,(ptype == 5) & female,0,-0.2255,0.1592,, +Female - Driving-age child interaction,(ptype == 6) & female,0.1737,,0,0.114,-0.3442 +Female - Pre-driving age child who is in school interaction,(ptype == 7) & female,0.1737,,0,0.114, +Under 35 - Full-time worker interaction,(ptype == 1) & (age <= 35),0,-0.1375,0.7218,,0.9761 +Under 35 - Part-time worker interaction,(ptype == 2) & (age <= 35),0,-0.1375,0.7218,,0.9761 +Under 35 - University student interaction,(ptype == 3) & (age <= 35),-0.4629,-0.1375,0,1.275,0.9761 +Under 35 - Non-working adult interaction,(ptype == 4) & (age <= 35),0,-0.1375,0.7218,, +Can walk to work - Full-time worker interaction,(ptype == 1) & (distance_to_work < 3),,0.5268,,, +Can walk to work - Part-time worker interaction,(ptype == 2) & (distance_to_work < 3),,0.5268,,, +Can walk to work - University student interaction,(ptype == 3) & (distance_to_work < 3),,0.5268,,, +Can walk to work - Non-working adult interaction,(ptype == 4) & (distance_to_work < 3),,0.5268,,, +Can walk to work - Retired interaction,(ptype == 5) & (distance_to_work < 3),,0.5268,,, +Can walk to school - University student interaction,(ptype == 3) & (distance_to_school < 3),,,,0.7114, +Can walk to school - Driving-age child interaction,(ptype == 6) & (distance_to_school < 3),,,,0.7114, +Can walk to school - Pre-driving age child who is in school interaction,(ptype == 7) & (distance_to_school < 3),,,,0.7114, +Can walk to work or school - Full-time worker interaction,(ptype == 1) & (distance_to_work < 3 | distance_to_school < 3),,,,,0.1391 +Can walk to work or school - Part-time worker interaction,(ptype == 2) & (distance_to_work < 3 | distance_to_school < 3),,,,,0.1391 +Can walk to work or school - University student interaction,(ptype == 3) & (distance_to_work < 3 | distance_to_school < 3),,,,,0.1391 +Can walk to work or school - Driving-age child interaction,(ptype == 6) & (distance_to_work < 3 | distance_to_school < 3),,,,,0.1391 +Round trip auto time to work - Full-time worker interaction,(ptype == 1) * roundtrip_auto_time_to_work,,-0.0035,,,-0.0031 +Round trip auto time to work - Part-time worker interaction,(ptype == 2) * roundtrip_auto_time_to_work,,-0.0035,,,-0.0031 +Round trip auto time to work - University student interaction,(ptype == 3) * roundtrip_auto_time_to_work,,-0.0035,,,-0.0031 +Round trip auto time to work - Non-working adult interaction,(ptype == 4) * roundtrip_auto_time_to_work,,-0.0035,,, +Round trip auto time to work - Retired,(ptype == 5) * roundtrip_auto_time_to_work,,-0.0035,,, +Round trip auto time to school - University student interaction,(ptype == 3) * roundtrip_auto_time_to_school,,,,-0.0034,-0.0031 +Round trip auto time to school - Driving-age child interaction,(ptype == 6) * roundtrip_auto_time_to_school,,,,-0.0034,-0.0031 +Round trip auto time to school - Pre-driving age child who is in school interaction,(ptype == 7) * roundtrip_auto_time_to_school,,,,-0.0034, +Student is employed - University student interaction,(ptype == 3) & student_is_employed,3.014,3.014,,,3.014 +Student is employed - Driving-age child interaction,(ptype == 6) & student_is_employed,3.014,3.014,,,3.014 +Non-student goes to school - Full-time worker interaction,(ptype == 1) & nonstudent_to_school,,,3.883,,3.883 +Non-student goes to school - Part-time worker interaction,(ptype == 2) & nonstudent_to_school,,,3.883,,3.883 +Non-student goes to school - Non-working adult interaction,(ptype == 4) & nonstudent_to_school,,,3.883,, +Non-student goes to school - Retired interaction,(ptype == 5) & nonstudent_to_school,,,3.883,, +No cars in household - Full-time worker interaction,(ptype == 1) & (auto_ownership == 0),,-1.306,,,-1.302 +No cars in household - Part-time worker interaction,(ptype == 2) & (auto_ownership == 0),,-1.306,,,-1.302 +No cars in household - University student interaction,(ptype == 3) & (auto_ownership == 0),,-1.306,,-1.413,-1.302 +No cars in household - Non-working adult interaction,(ptype == 4) & (auto_ownership == 0),,-1.306,,, +No cars in household - Retired interaction,(ptype == 5) & (auto_ownership == 0),,-1.306,,, +No cars in household - Driving-age student interaction,(ptype == 6) & (auto_ownership == 0),,,,-1.413,-1.302 +No cars in household - Pre-driving age child who is in school interaction,(ptype == 7) & (auto_ownership == 0),,,,-1.413, +Fewer cars than drivers in household - University student interaction,(ptype == 3) & (auto_ownership < drivers),,,,-0.5759, +Fewer cars than drivers in household - Driving-age student interaction,(ptype == 6) & (auto_ownership < drivers),,,,-0.5759, +Fewer cars than drivers in household - Pre-driving age child who is in school interaction,(ptype == 7) & (auto_ownership < drivers),,,,-0.5759, +Number of preschool children in household - Full-time worker interaction,(ptype == 1) * (num_young_children),0,-0.1478,-0.1335,,-0.1251 +Number of preschool children in household - Part-time worker interaction,(ptype == 2) * (num_young_children),0,-0.1478,-0.1335,,-0.1251 +Number of preschool children in household - University student interaction,(ptype == 3) * (num_young_children),0.2191,-0.1478,0,-0.5577,-0.1251 +Number of preschool children in household - Non-working adult interaction,(ptype == 4) * (num_young_children),0,-0.1478,-0.1335,, +Number of preschool children in household - Retired interaction,(ptype == 5) * (num_young_children),0,-0.1478,-0.1335,, +Number of preschool children in household - Driving-age student interaction,(ptype == 6) * (num_young_children),0.2191,,0,-0.5577,-0.1251 +Number of preschool children in household - Pre-driving age child who is in school interaction,(ptype == 7) * (num_young_children),0.2191,,0,-0.5577, +Number of non-workers in the household - Full-time worker interaction,(ptype == 1) * non_workers,,,0.2574,, +Number of non-workers in the household - Part-time worker interaction,(ptype == 2) * non_workers,,,0.2574,, +Household income higher than $50k - Full-time worker interaction,(ptype == 1) & (income_in_thousands > 50),0,,0.0347,,0.0347 +Household income higher than $50k - Part-time worker interaction,(ptype == 2) & (income_in_thousands > 50),0,,0.0347,,0.0347 +Household income higher than $50k - University student interaction,(ptype == 3) & (income_in_thousands > 50),-0.0528,-0.0528,0,,-0.0528 +Household income higher than $50k - Non-working adult interaction,(ptype == 4) & (income_in_thousands > 50),0,,0.0347,, +Household income higher than $50k - Retired interaction,(ptype == 5) & (income_in_thousands > 50),0,,0.0347,, +Household income higher than $50k - Driving-age student interaction,(ptype == 6) & (income_in_thousands > 50),-0.0528,,0,,-0.0528 +Household income higher than $50k - Pre-driving age child who is in school interaction,(ptype == 7) & (income_in_thousands > 50),-0.0528,,0,, +Non-family household - Full-time worker interaction,(ptype == 1) & non_family,0,,-0.25,,-0.25 +Non-family household - Part-time worker interaction,(ptype == 2) & non_family,0,,-0.25,,-0.25 +Non-family household - University student interaction,(ptype == 3) & non_family,-0.1792,-0.1792,0,,-0.1792 +Non-family household - Non-working adult interaction,(ptype == 4) & non_family,0,,-0.25,, +Non-family household - Retired interaction,(ptype == 5) & non_family,0,,-0.25,, +Non-family household - Driving-age student interaction,(ptype == 6) & non_family,-0.1792,,0,,-0.1792 +Non-family household - Pre-driving age child who is in school interaction,(ptype == 7) & non_family,-0.1792,,0,, +Number of children under 16 not at school - Full-time worker interaction,(ptype == 1) * num_under16_not_at_school,,0.1804,,,-0.1955 +Number of children under 16 not at school - Part-time worker interaction,(ptype == 2) * num_under16_not_at_school,,0.1804,,,-0.1955 +Number of children under 16 not at school - University student interaction,(ptype == 3) * num_under16_not_at_school,,0.1804,,0.0866,-0.1955 +Number of children under 16 not at school - Non-working adult interaction,(ptype == 4) * num_under16_not_at_school,,0.1804,,, +Number of children under 16 not at school - Retired,(ptype == 5) * num_under16_not_at_school,,0.1804,,, +Number of children under 16 not at school - Driving-age student interaction,(ptype == 6) * num_under16_not_at_school,,,,0.0866,-0.1955 +Number of children under 16 not at school - Pre-driving age child who is in school interaction,(ptype == 7) * num_under16_not_at_school,,,,0.0866, +Home is in urban area - Full-time worker interaction,(ptype == 1) & home_is_urban,0,0.2308,-0.1361,,-0.3509 +Home is in urban area - Part-time worker interaction,(ptype == 2) & home_is_urban,0,0.2308,-0.1361,,-0.3509 +Home is in urban area - University student interaction,(ptype == 3) & home_is_urban,-0.2831,0.2308,0,0.317,-0.3509 +Home is in urban area - Non-working adult interaction,(ptype == 4) & home_is_urban,0,0.238,-0.1361,, +Home is in urban area - Retired interaction,(ptype == 5) & home_is_urban,0,0.2308,-0.1361,, +Home is in urban area - Driving-age student interaction,(ptype == 6) & home_is_urban,-0.2831,,0,0.317,-0.3509 +Home is in urban area - Pre-driving age child who is in school interaction,(ptype == 7) & home_is_urban,-0.2831,,0,0.317, +Unavailable: Full-time worker,ptype == 1,,,,-999, +Unavailable: Part-time worker,ptype == 2,,,,-999, +Unavailable: Non-working adult,ptype == 4,,,,-999,-999 +Unavailable: Retired,ptype == 5,,,,-999,-999 +Unavailable: Driving-age child,ptype == 6,-999,-999,,, +Unavailable: Pre-driving age child who is in school,ptype == 7,,-999,,,-999 +Unavailable: Work tours for those with no usual work location,~(workplace_taz > -1),-999,-999,,,-999 +Unavailalbe: School tours for those with no usual school location,~(school_taz > -1),,,-999,-999,-999 diff --git a/example/configs/non_mandatory_tour_frequency.csv b/example/configs/non_mandatory_tour_frequency.csv new file mode 100644 index 000000000..49499f514 --- /dev/null +++ b/example/configs/non_mandatory_tour_frequency.csv @@ -0,0 +1,205 @@ +Description,Expression,full,part,university,nonwork,retired,driving,school,preschool +Total Number of Tours = 0 (No Prior Tours),(tot_tours == 0) & (num_mand == 0) & (num_joint_tours == 0),-999,-999,-999,-999,-999,-999,-999,-999 +Total Number of Tours = 0 (1 or more Prior Tours),(tot_tours == 0) & ((num_mand > 0) | (num_joint_tours > 0)),0,0,0,0,0,0,0,0 +Total Number of Tours = 1,tot_tours == 1,-7.3572,-7.6391,-6.2138,-8.9791,-8.5684,-7.1506,-7.1506,-5.759 +Total Number of Tours = 2,tot_tours == 2,-10.647,-10.4557,-8.908,-12.0248,-12.7416,-11.1214,-11.1214,-11.517 +Total Number of Tours = 3,tot_tours == 3,-13.5005,-14.0176,-12.3261,-14.8516,-15.0978,-13.175,-13.175,-17.276 +Total Number of Tours = 4,tot_tours == 4,-16.3965,-16.9717,-15.8114,-17.7037,-19.5439,-999,-999,-23.035 +Total Number of Tours = 5,tot_tours == 5,-19.6843,-999,-999,-999,-20.7897,-999,-999,-999 +Total Number of Tours = 6+,tot_tours > 5,-999,-999,-999,-999,-999,-999,-999,-999 +Number of Mandatory tours & tour frequency =0,num_mand*(tot_tours == 0),0,0,0,0,0,0,0,2.491 +Number of Mandatory tours & tour frequency =1,num_mand*(tot_tours == 1),0,-0.239,-0.1852,-0.6766,0,-0.234,-0.234,0.903 +Number of Mandatory tours & tour frequency =2,num_mand*(tot_tours == 2),-0.8887,-1.8208,-0.8753,-1.0518,-5.0196,-0.9231,-0.9231,0 +Number of Mandatory tours & tour frequency =3,num_mand*(tot_tours == 3),-2.3343,-2.5923,-1.6158,-1.0518,-5.0196,-6.5835,-6.5835,1.022 +Number of Mandatory tours & tour frequency =4,num_mand*(tot_tours == 4),-2.3343,-2.5923,-999,-999,-999,-999,-999,0.769 +Number of Mandatory tours & tour frequency = 5+,num_mand*(tot_tours > 4),-2.3343,-2.5923,-999,-999,-999,-999,-999,0 +Number of Joint tours & tour frequency =0,num_joint_tours*(tot_tours == 0),0,0,0,0,0,0,0,0 +Number of Joint tours & tour frequency =1,num_joint_tours*(tot_tours == 1),0,0,0,-0.1699,0,-0.2162,-0.2162,0 +Number of Joint tours & tour frequency =2,num_joint_tours*(tot_tours == 2),0,-1.1986,-0.3153,-0.4285,-0.95,-0.3587,-0.3587,0 +Number of Joint tours & tour frequency =3,num_joint_tours*(tot_tours == 3),0,-1.1986,-0.7351,-0.6551,-7.143,-4.2701,-4.2701,0 +Number of Joint tours & tour frequency =4,num_joint_tours*(tot_tours == 4),0,-1.1986,-999,-1.0411,-999,-999,-999,0 +Number of Joint tours & tour frequency = 5+,num_joint_tours*(tot_tours > 4),0,-999,-999,-1.0411,-999,-999,-999,0 +Number of Joint Shopping tours,num_shop_j,0,0,-0.713,-0.2391,-0.8072,0,0,0 +Number of Joint Maintenance tours,num_main_j,0,0,0,0,0,0,0,0 +Number of Joint Eating Out tours,num_eat_j,-0.5866,0,0,-0.7727,0,0,0,0 +Number of Joint Visit tours,num_visi_j,0,0,0,0,0,0,0,0 +Number of Joint Discretionary tours,num_disc_j,0,0,0.6713,0,0,0,0,0 +"Logged Maximum Residual Window, tour frequency =0",max_window*(tot_tours == 0),0,0,1.1858,0,0,0,0,0 +"Logged Maximum Residual Window, tour frequency =1",max_window*(tot_tours == 1),1.2562,1.5748,1.4842,1.7637,1.8357,1.3298,1.3298,0 +"Logged Maximum Residual Window, tour frequency =2",max_window*(tot_tours == 2),1.2868,2.0026,1.4842,1.7928,2.2707,1.3759,1.3759,0 +"Logged Maximum Residual Window, tour frequency =3",max_window*(tot_tours == 3),1.3993,2.0026,1.4842,1.7928,4.4023,3.2808,3.2808,0 +"Logged Maximum Residual Window, tour frequency =4",max_window*(tot_tours == 4),1.3993,2.0026,1.4842,1.7928,4.4023,3.2808,3.2808,0 +"Logged Maximum Residual Window, tour frequency =5+",max_window*(tot_tours > 4),1.3993,2.0026,1.4842,1.7928,4.4023,3.2808,3.2808,0 +Dummy for Mediumlow Income group (20K-50K) & tour frequency=1,(20 < income_in_thousands <= 50) & (tot_tours == 1),0.4981,0.5981,0,0.5709,0,0,0,0 +Dummy for Mediumlow Income group (20K-50K) & tour frequency=2,(20 < income_in_thousands <= 50) & (tot_tours == 2),0.8345,0.9178,0,0.8315,0,0,0,0 +Dummy for Mediumlow Income group (20K-50K) & tour frequency=3,(20 < income_in_thousands <= 50) & (tot_tours == 3),1.0213,1.7539,0,0.8315,0,0,0,0 +Dummy for Mediumlow Income group (20K-50K) & tour frequency=4,(20 < income_in_thousands <= 50) & (tot_tours == 4),1.0213,1.7539,0,0.8315,0,0,0,0 +Dummy for Mediumlow Income group (20K-50K) & tour frequency=5+,(20 < income_in_thousands <= 50) & (tot_tours > 4),1.0213,1.7539,0,0.8315,0,0,0,0 +Dummy for MediumHigh Income group (50K-100K) & tour frequency=1,(50 < income_in_thousands <= 100) & (tot_tours == 1),0.4981,0.8682,0.1109,0.7426,0,0,0,0 +Dummy for MediumHigh Income group (50K-100K) & tour frequency=2,(50 < income_in_thousands <= 100) & (tot_tours == 2),0.8345,1.5362,0.3914,0.8546,0,0,0,0 +Dummy for MediumHigh Income group (50K-100K) & tour frequency=3,(50 < income_in_thousands <= 100) & (tot_tours == 3),1.0213,1.9331,0.6137,1.0792,0,0,0,0 +Dummy for MediumHigh Income group (50K-100K) & tour frequency=4,(50 < income_in_thousands <= 100) & (tot_tours == 4),1.0213,1.9331,0.6137,1.0792,0,0,0,0 +Dummy for MediumHigh Income group (50K-100K) & tour frequency=5+,(50 < income_in_thousands <= 100) & (tot_tours > 4),1.0213,1.9331,0.6137,1.0792,0,0,0,0 +Dummy for High Income group (>100K) & tour frequency=1,(100 < income_in_thousands) & (tot_tours == 1),0.5189,0.8682,0.3986,1.0633,0,0,0,0 +Dummy for High Income group (>100K) & tour frequency=2,(100 < income_in_thousands) & (tot_tours == 2),1.1336,1.5362,0.8009,1.0633,0,0,0,0 +Dummy for High Income group (>100K) & tour frequency=3,(100 < income_in_thousands) & (tot_tours == 3),1.3899,1.9331,0.8254,1.7742,0,0,0,0 +Dummy for High Income group (>100K) & tour frequency=4,(100 < income_in_thousands) & (tot_tours == 4),1.3899,1.9331,0.8254,2.3941,0,0,0,0 +Dummy for High Income group (>100K) & tour frequency=5+,(100 < income_in_thousands) & (tot_tours > 4),1.3899,1.9331,0.8254,2.3941,0,0,0,0 +Dummy for Mediumlow Income group (20K-50K) & shopping tour,(20 < income_in_thousands <= 50) * shopping,0,0.4421,0.5693,0.7734,1.0949,0,0,0 +Dummy for Mediumhigh Income group (50K-100K) & shopping tour,(50 < income_in_thousands <= 100) * shopping,0,0.4421,0.5693,0.8906,1.0949,0.2443,0.2443,0 +Dummy for High Income group (>100K) & shopping tour,(100 < income_in_thousands) * shopping,0,0.7066,0.5693,0.9776,1.0949,0.2443,0.2443,0 +Dummy for Mediumlow Income group (20K-50K) & maintenance tour,(20 < income_in_thousands <= 50) * othmaint,0,0.6763,0,0,0.7648,0,0,0 +Dummy for Mediumhigh Income group (50K-100K) & maintenance tour,(50 < income_in_thousands <= 100) * othmaint,0,0.6763,0,0,0.7648,0.3982,0.3982,0 +Dummy for High Income group (>100K) & maintenance tour,(100 < income_in_thousands) * othmaint,0,0.6763,0,0,1.3795,0.3982,0.3982,0 +Dummy for Mediumlow Income group (20K-50K) & Eating out tour,(20 < income_in_thousands <= 50) * eatout,0,0,0,0.2766,0.9769,0,0,0 +Dummy for Mediumhigh Income group (50K-100K) & Eating out tour,(50 < income_in_thousands <= 100) * eatout,0.5581,0,-0.7207,0.4631,1.181,0.4916,0.4916,0 +Dummy for High Income group (>100K) & Eating out tour,(100 < income_in_thousands) * eatout,0.5581,0,-0.7207,0.7086,1.4842,0.4916,0.4916,0 +Dummy for Mediumlow Income group (20K-50K) & Discretionary tour,(20 < income_in_thousands <= 50) * othdiscr,0,0.296,0,0.1707,1.0095,0.9169,0.9169,0 +Dummy for Mediumhigh Income group (50K-100K) & Discretionary tour,(50 < income_in_thousands <= 100) * othdiscr,0.2565,0.296,0,0.5009,1.0095,1.405,1.405,0 +Dummy for High Income group (>100K) & Discretionary tour,(100 < income_in_thousands) * othdiscr,0.2565,0.296,0,0.8846,1.0095,2.327,2.327,0 +Dummy for Mediumlow Income group (20K-50K) & Visiting tour,(20 < income_in_thousands <= 50) * social,0,-0.6868,0,-0.267,0,0,0,0 +Dummy for Mediumhigh Income group (50K-100K) & Visiting tour,(50 < income_in_thousands <= 100) * social,-0.2423,-0.6868,-0.3694,-0.267,-0.4368,0.2858,0.2858,0 +Dummy for High Income group (>100K) & Visiting tour,(100 < income_in_thousands) * social,-0.2423,-0.6868,-0.3694,-0.9449,-0.5137,0.2858,0.2858,0 +Dummy for Female & tour frequency =1,female & (tot_tours == 1),-0.0766,0,0.0973,0.3902,-0.9348,0,0,0 +Dummy for Female & tour frequency =2,female & (tot_tours == 2),-0.1062,0,0.2361,0.5323,-1.3028,0,0,0 +Dummy for Female & tour frequency =3,female & (tot_tours == 3),-0.3274,0,1.9002,0.7452,-2.266,0,0,0 +Dummy for Female & tour frequency =4,female & (tot_tours == 4),-0.3274,0,1.9002,1.1294,-2.266,0,0,0 +Dummy for Female & tour frequency =5,female & (tot_tours == 5),-0.3274,0,1.9002,1.1294,-2.266,0,0,0 +Dummy for Female & Escorting Tour,female * escort,0.1824,0,0,0,0,0,0,0 +Dummy for Female & Shopping Tour,female * shopping,0,0.4524,0,0,0.9688,0,0,0 +Dummy for Female & Maintenance Tour,female * othmaint,0,0,0,-0.2464,0.7424,0,0,0 +Dummy for Female & EatingOut Tour,female * eatout,0,0,-0.6568,0,0,0,0,0 +Dummy for Female & Discretionary Tour,female * othdiscr,0,0.3072,-0.3266,0,0.4954,0,0,0 +Dummy for zero car ownership & tour frequency =1,no_cars & (tot_tours == 1),-0.3486,-0.5498,-0.581,-0.3623,0,-0.6369,-0.6369,0 +Dummy for zero car ownership & tour frequency =2,no_cars & (tot_tours == 2),-0.3486,-0.5498,-0.581,-1.272,0,-0.6369,-0.6369,0 +Dummy for zero car ownership & tour frequency =3,no_cars & (tot_tours == 3),-0.3486,-0.5498,-0.581,-1.9307,0,-0.6369,-0.6369,0 +Dummy for zero car ownership & tour frequency =4,no_cars & (tot_tours == 4),-0.3486,-0.5498,-0.581,-1.9307,0,-0.6369,-0.6369,0 +Dummy for zero car ownership & tour frequency =5+,no_cars & (tot_tours > 4),-0.3486,-0.5498,-0.581,-1.9307,0,-0.6369,-0.6369,0 +Dummy for Car Shortage vs Workers & tour frequency =1,(car_sufficiency < 0) & (tot_tours == 1),0,-0.5498,-0.581,-0.3623,0,-0.6369,-0.6369,0 +Dummy for Car Shortage vs Workers & tour frequency =2,(car_sufficiency < 0) & (tot_tours == 2),0,-0.5498,-0.581,-1.272,0,-0.6369,-0.6369,0 +Dummy for Car Shortage vs Workers & tour frequency =3,(car_sufficiency < 0) & (tot_tours == 3),0,-0.5498,-0.581,-1.9307,0,-0.6369,-0.6369,0 +Dummy for Car Shortage vs Workers & tour frequency =4,(car_sufficiency < 0) & (tot_tours == 4),0,-0.5498,-0.581,-1.9307,0,-0.6369,-0.6369,0 +Dummy for Car Shortage vs Workers & tour frequency =5+,(car_sufficiency < 0) & (tot_tours > 4),0,-0.5498,-0.581,-1.9307,0,-0.6369,-0.6369,0 +Dummy for Car Surplus vs Workers & tour frequency =1,(car_sufficiency > 0) & (tot_tours == 1),0.1304,0,0,0.7738,0.7965,0.2902,0.2902,0 +Dummy for Car Surplus vs Workers & tour frequency =2,(car_sufficiency > 0) & (tot_tours == 2),0.1304,0,0,0.7738,2.1302,2.0352,2.0352,0 +Dummy for Car Surplus vs Workers & tour frequency =3,(car_sufficiency > 0) & (tot_tours == 3),0.1304,0,0,0.7738,2.1302,2.0352,2.0352,0 +Dummy for Car Surplus vs Workers & tour frequency =4,(car_sufficiency > 0) & (tot_tours == 4),0.1304,0,0,0.7738,2.1302,2.0352,2.0352,0 +Dummy for Car Surplus vs Workers & tour frequency =5+,(car_sufficiency > 0) & (tot_tours > 4),0.1304,0,0,0.7738,2.1302,2.0352,2.0352,0 +Dummy for Presence of Non-Worker(other than modeled person) & tour frequency =1,has_non_worker & (tot_tours == 1),0,0,-0.8506,-0.3763,0.224,0,0,0 +Dummy for Presence of Non-Worker(other than modeled person) & tour frequency =2,has_non_worker & (tot_tours == 2),0,0,-1.1804,-0.719,0.2436,-0.6571,-0.6571,0 +Dummy for Presence of Non-Worker(other than modeled person) & tour frequency =3,has_non_worker & (tot_tours == 3),0,0,-1.1804,-1.0229,0.62,-1.4044,-1.4044,0 +Dummy for Presence of Non-Worker(other than modeled person) & tour frequency =4,has_non_worker & (tot_tours == 4),0,0,-1.1804,-1.0229,3.3742,-1.4044,-1.4044,0 +Dummy for Presence of Non-Worker(other than modeled person) & tour frequency =5,has_non_worker & (tot_tours == 5),0,0,-1.1804,-1.0229,3.3742,-1.4044,-1.4044,0 +Dummy for Presence of Retiree(other than modeled person) & tour frequency =1,has_retiree & (tot_tours == 1),0,0,0,-0.464,-0.4458,0,0,0 +Dummy for Presence of Retiree(other than modeled person) & tour frequency =2,has_retiree & (tot_tours == 2),0,0,0,-0.4795,-0.5315,0,0,0 +Dummy for Presence of Retiree(other than modeled person) & tour frequency =3,has_retiree & (tot_tours == 3),0,0,0,-0.4795,-0.5315,0,0,0 +Dummy for Presence of Retiree(other than modeled person) & tour frequency =4,has_retiree & (tot_tours == 4),0,0,0,-0.4795,-0.5315,0,0,0 +Dummy for Presence of Retiree(other than modeled person) & tour frequency =5,has_retiree & (tot_tours == 5),0,0,0,-0.4795,-0.5315,0,0,0 +Dummy for Presence of PreSchool Kid (other than modeled person) in Household & tour frequency =1,has_preschool_kid & (tot_tours == 1),0,-0.1559,-0.9961,-0.7161,0,0,0,0 +Dummy for Presence of PreSchool Kid (other than modeled person) in Household & tour frequency =2,has_preschool_kid & (tot_tours == 2),0,-0.5681,-1.9096,-0.7161,0,0,0,0 +Dummy for Presence of PreSchool Kid (other than modeled person) in Household & tour frequency =3,has_preschool_kid & (tot_tours == 3),0,-0.5681,-2.8469,-0.7161,0,0,0,0 +Dummy for Presence of PreSchool Kid (other than modeled person) in Household & tour frequency =4,has_preschool_kid & (tot_tours == 4),0,-0.5681,-2.8469,-0.7161,0,0,0,0 +Dummy for Presence of PreSchool Kid (other than modeled person) in Household & tour frequency =5,has_preschool_kid & (tot_tours == 5),0,-0.5681,-2.8469,-0.7161,0,0,0,0 +Dummy for Presence of Predriving School Kid (other than modeled person) in Household & tour frequency =1,has_school_kid & (tot_tours == 1),0,0,0,0.1486,0,-0.3219,-0.3219,0 +Dummy for Presence of Predriving School Kid (other than modeled person) in Household & tour frequency =2,has_school_kid & (tot_tours == 2),0,0,0,0.484,0,-1.0874,-1.0874,0 +Dummy for Presence of Predriving School Kid (other than modeled person) in Household & tour frequency =3,has_school_kid & (tot_tours == 3),0,0,0,0.484,0,-1.0874,-1.0874,0 +Dummy for Presence of Predriving School Kid (other than modeled person) in Household & tour frequency =4,has_school_kid & (tot_tours == 4),0,0,0,0.484,0,-1.0874,-1.0874,0 +Dummy for Presence of Predriving School Kid (other than modeled person) in Household & tour frequency =5,has_school_kid & (tot_tours == 5),0,0,0,0.484,0,-1.0874,-1.0874,0 +Dummy for Presence of Full time Worker (other than modeled person) & Escorting tour ,has_full_time * escort,0,0,0,0.3947,0,0,0,-0.893 +Dummy for Presence of Part time Worker (other than modeled person) & Escorting tour ,has_part_time * escort,0,0,-1.8213,-0.5861,0,0,0,0 +Dummy for Presence of Non-Worker (other than modeled person) & Escorting tour ,has_non_worker * escort,-0.4815,-0.5263,0,0,0,0,0,0.89 +Dummy for Presence of Retiree (other than modeled person) & Escorting tour ,has_retiree * escort,-0.808,-0.7516,0,0,0,0,0,0 +Dummy for Presence of University Student (other than modeled person) & Escorting tour ,has_university * escort,0,0,0,0,0,0,0,0 +Dummy for Presence of Driving School Kid (other than modeled person) & Escorting tour ,has_driving_kid * escort,0.3601,0.4164,0,0,0,0,0,0 +Dummy for Presence of Pre-Driving School Kid (other than modeled person) & Escorting tour ,has_school_kid * escort,1.3974,1.5795,0.9489,1.3773,1.4903,0,0,0 +Dummy for Presence of Pre-School Kid (other than modeled person) & Escorting tour ,has_preschool_kid * escort,0.6842,0.5414,2.1465,0.7194,0.5027,0,0,0 +Dummy for At home Pre-Driving School Kid & Escorting tour ,has_school_kid_at_home * escort,-0.2746,0,0,-1.148,0,0,0,0 +Dummy for At homef Pre-School Kid & Escorting tour ,has_preschool_kid_at_home * escort,-1.5675,0,0,-0.1373,0,0,0,0 +Dummy for Presence of Full time Worker (other than modeled person) & Shopping tour ,has_full_time * shopping,-0.3059,0,-0.7728,0,-0.3609,0,0,0 +Dummy for Presence of Part time Worker (other than modeled person) & Shopping tour ,has_part_time * shopping,-0.1541,0,-0.5199,0,0,0,0,1.155 +Dummy for Presence of Non-Worker (other than modeled person) & Shopping tour ,has_non_worker * shopping,-0.416,0,0,0,0,0,0,0.808 +Dummy for Presence of Retiree (other than modeled person) & Shopping tour ,has_retiree * shopping,0,0,0,0,0,0,0,0 +Dummy for Presence of University Student (other than modeled person) & Shopping tour ,has_university * shopping,0,0,0,0,0,0,0,0 +Dummy for Presence of Driving School Kid (other than modeled person) & Shopping tour ,has_driving_kid * shopping,0,0,0,0,0,0,0,0 +Dummy for Presence of Pre-Driving School Kid (other than modeled person) & Shopping tour ,has_school_kid * shopping,0,0,0,0,0,0,0,0 +Dummy for Presence of Pre-School Kid (other than modeled person) & Shopping tour ,has_preschool_kid * shopping,-0.208,0,1.3135,0,0,0,0,0 +Dummy for At home Pre-Driving School Kid & Shopping tour ,has_school_kid_at_home * shopping,0,0,0,0,0,0,0,0 +Dummy for At homef Pre-School Kid & Shopping tour ,has_preschool_kid_at_home * shopping,0,0,0,0,0,0,0,0 +Dummy for Presence of Full time Worker (other than modeled person) & Maintenance tour ,has_full_time * othmaint,-0.1685,-0.3131,0,0,0,0,0,0 +Dummy for Presence of Part time Worker (other than modeled person) & Maintenance tour ,has_part_time * othmaint,-0.1584,-0.5621,0,0,0,0,0,0 +Dummy for Presence of Non-Worker(other than modeled person) & Maintenance tour ,has_non_worker * othmaint,-0.3237,0,0,0,0,0,0,0 +Dummy for Presence of Retiree (other than modeled person) & Maintenance tour ,has_retiree * othmaint,0,0,0,0,0,0,0,0 +Dummy for Presence of University Student (other than modeled person) & Maintenance tour ,has_university * othmaint,0,0,0,0,0,0,0,0 +Dummy for Presence of Driving School Kid (other than modeled person) & Maintenance tour ,has_driving_kid * othmaint,0,0,0,0,0,0,0,0 +Dummy for Presence of Pre-Driving School Kid (other than modeled person) & Maintenance tour ,has_school_kid * othmaint,0,0,0.3863,0,0,0,0,0 +Dummy for Presence of Pre-School Kid (other than modeled person) & Maintenance tour ,has_preschool_kid * othmaint,0,0,0.9694,0,0,0,0,0 +Dummy for At home Pre-Driving School Kid & Maintenance tour ,has_school_kid_at_home * othmaint,0,0,0,0,0,0,0,0 +Dummy for At homef Pre-School Kid & Maintenance tour ,has_preschool_kid_at_home * othmaint,0,0,0,0,0,0,0,0 +Dummy for Presence of Full time Worker (other than modeled person) & Eating Out tour ,has_full_time * eatout,-0.3571,0,-0.5251,-0.4667,-0.788,0,0,0 +Dummy for Presence of Part time Worker (other than modeled person) & Eating Out tour ,has_part_time * eatout,0,0,-1.9795,0,-0.788,0,0,1.037 +Dummy for Presence of Non-Worker (other than modeled person) & Eating Out tour ,has_non_worker * eatout,-0.2014,-0.6545,0,-0.4976,-0.788,0,0,1.157 +Dummy for Presence of Retiree (other than modeled person) & Eating Out tour ,has_retiree * eatout,-0.5708,-1.389,0,-0.6911,-0.9282,0,0,0 +Dummy for Presence of University Student (other than modeled person) & Eating Out tour ,has_university * eatout,0,-1.4318,-0.6529,0,0,0,0,0 +Dummy for Presence of Driving School Kid (other than modeled person) & Eating Out tour ,has_driving_kid * eatout,0,0,0,0,0,-0.6377,-0.6377,0 +Dummy for Presence of Pre-Driving School Kid (other than modeled person) & Eating Out tour ,has_school_kid * eatout,0,0,0,0,0,-1.5698,-1.5698,0 +Dummy for Presence of Pre-School Kid (other than modeled person) & Eating Out tour ,has_preschool_kid * eatout,-0.4225,0,0,0,0,-0.2987,-0.2987,0 +Dummy for At home Pre-Driving School Kid & Eating Out tour ,has_school_kid_at_home * eatout,0,0,0,-0.3926,0,0,0,0 +Dummy for At homef Pre-School Kid & Eating Out tour ,has_preschool_kid_at_home * eatout,0,0,0,-0.3926,0,0,0,0 +Dummy for Presence of Full time Worker (other than modeled person) & Discretionary tour ,has_full_time * othdiscr,-0.667,0,-0.4833,-0.3545,-0.4835,0,0,0 +Dummy for Presence of Part time Worker (other than modeled person) & Discretionary tour ,has_part_time * othdiscr,-0.2102,0,0,-0.3545,0,0,0,0 +Dummy for Presence of Non-Worker (other than modeled person) & Discretionary tour ,has_non_worker * othdiscr,-0.4281,-1.0371,0.9781,0,-0.5603,0,0,0.791 +Dummy for Presence of Retiree (other than modeled person) & Discretionary tour ,has_retiree * othdiscr,-0.9104,0,0,0,0,0,0,0 +Dummy for Presence of University Student (other than modeled person) & Discretionary tour ,has_university * othdiscr,-0.8551,0,-0.6542,0,0,-1.2834,-1.2834,0 +Dummy for Presence of Driving School Kid (other than modeled person) & Discretionary tour ,has_driving_kid * othdiscr,-0.3963,0,0,0,0,-0.9202,-0.9202,0 +Dummy for Presence of Pre-Driving School Kid (other than modeled person) & Discretionary tour ,has_school_kid * othdiscr,-0.3959,0,0,0,0,0,0,0 +Dummy for Presence of Pre-School Kid (other than modeled person) & Discretionary tour ,has_preschool_kid * othdiscr,-0.5081,0,0,0,0,0,0,0 +Dummy for At home Pre-Driving School Kid & Discretionary tour ,has_school_kid_at_home * othdiscr,-0.4703,0,0,0,0,0,0,0 +Dummy for At homef Pre-School Kid & Discretionary tour ,has_preschool_kid_at_home * othdiscr,-0.4703,0,0,0,0,0,0,0 +Walk Access to Retail & Tour Frequency =1,NONMOTORIZEDRETAIL * (tot_tours == 1),0,0.0899,0,0.0713,0.0616,0,0,0 +Walk Access to Retail & Tour Frequency =2,NONMOTORIZEDRETAIL * (tot_tours == 2),0,0.1447,0,0.1256,0.0616,0,0,0 +Walk Access to Retail & Tour Frequency =3,NONMOTORIZEDRETAIL * (tot_tours == 3),0,0.3479,0,0.1508,0.0616,0,0,0 +Walk Access to Retail & Tour Frequency =4,NONMOTORIZEDRETAIL * (tot_tours == 4),0,0.3479,0,0.1508,0.0616,0,0,0 +Walk Access to Retail & Tour Frequency =5+,NONMOTORIZEDRETAIL * (tot_tours > 4),0,0.3479,0,0.1508,0.0616,0,0,0 +Transit Access to Retail & Tour Frequency =1,TRANSITOFFPEAKRETAIL * (tot_tours == 1),0.0226,0,0.0664,0,0,0,0,0 +Transit Access to Retail & Tour Frequency =2,TRANSITOFFPEAKRETAIL * (tot_tours == 2),0.0226,0,0.0664,0,0,0,0,0 +Transit Access to Retail & Tour Frequency =3,TRANSITOFFPEAKRETAIL * (tot_tours == 3),0.0226,0,0.0664,0,0,0,0,0 +Transit Access to Retail & Tour Frequency =4,TRANSITOFFPEAKRETAIL * (tot_tours == 4),0.0226,0,0.0664,0,0,0,0,0 +Transit Access to Retail & Tour Frequency =5+,TRANSITOFFPEAKRETAIL * (tot_tours > 4),0.0226,0,0.0664,0,0,0,0,0 +Auto Access to Retail & Tour Frequency =1,AUTOOFFPEAKRETAIL * (tot_tours == 1),0,0,0,0,0,0.1004,0.1004,0 +Auto Access to Retail & Tour Frequency =2,AUTOOFFPEAKRETAIL * (tot_tours == 2),0,0,0,0,0,0.1004,0.1004,0 +Auto Access to Retail & Tour Frequency =3,AUTOOFFPEAKRETAIL * (tot_tours == 3),0,0,0,0,0,0.1004,0.1004,0 +Auto Access to Retail & Tour Frequency =4,AUTOOFFPEAKRETAIL * (tot_tours == 4),0,0,0,0,0,0.1004,0.1004,0 +Auto Access to Retail & Tour Frequency =5+,AUTOOFFPEAKRETAIL * (tot_tours > 4),0,0,0,0,0,0.1004,0.1004,0 +Walk Access to Retail & Escorting ,NONMOTORIZEDRETAIL * escort,0.0451,0,0,0,0,0,0,0 +Transit Access to Retail & Escorting ,TRANSITOFFPEAKRETAIL * escort,0,0,0,0,0,0,0,0 +Auto Access to Retail & Escorting ,AUTOOFFPEAKRETAIL * escort,0,0,0,0,0,0,0,0 +Walk Access to Retail & Shopping ,NONMOTORIZEDRETAIL * shopping,0.033,0,0.0972,0.0598,0,0,0,0 +Transit Access to Retail & Shopping ,TRANSITOFFPEAKRETAIL * shopping,0,0,0,0,0,0,0,0 +Auto Access to Retail & Shopping ,AUTOOFFPEAKRETAIL * shopping,0.1067,0,0,0,0,0,0,0 +Walk Access to Retail & Maintenance ,NONMOTORIZEDRETAIL * othmaint,0,0,0,0,0,0,0,0 +Transit Access to Retail & Maintenance ,TRANSITOFFPEAKRETAIL * othmaint,0,0,0.0314,0,0,0,0,0 +Auto Access to Retail & Maintenance ,AUTOOFFPEAKRETAIL * othmaint,0.0749,0,0,0.0956,0,0,0,0 +Walk Access to Retail & Eating Out ,NONMOTORIZEDRETAIL * eatout,0.145,0,0,0,0,0,0,0 +Transit Access to Retail & Eating Out ,TRANSITOFFPEAKRETAIL * eatout,0,0,0,0,0,0,0,0 +Auto Access to Retail & Eating Out ,AUTOOFFPEAKRETAIL * eatout,0,0,0.1018,0,0,0,0,0 +Walk Access to Retail & Discretionary ,NONMOTORIZEDRETAIL * othdiscr,0.0567,0,0,0.0772,0,0,0,0 +Transit Access to Retail & Discretionary ,TRANSITOFFPEAKRETAIL * othdiscr,0,0,0,0,0,0,0,0 +Auto Access to Retail & Discretionary ,AUTOOFFPEAKRETAIL * othdiscr,0.0844,0,0.094,0,0,0,0,0 +Urban Areatype & Tour Frequency =1,home_is_urban & (tot_tours == 1),0,0,-1.1648,0,0,0,0,0 +Urban Areatype & Tour Frequency =2,home_is_urban & (tot_tours == 2),0,0,-2.3177,0,0,0,0,0 +Urban Areatype & Tour Frequency =3,home_is_urban & (tot_tours == 3),0,0,-2.5027,0,0,0,0,0 +Urban Areatype & Tour Frequency =4,home_is_urban & (tot_tours == 4),0,0,-2.5027,0,0,0,0,0 +Urban Areatype & Tour Frequency =5+,home_is_urban & (tot_tours > 4),0,0,-2.5027,0,0,0,0,0 +Urban Areatype & Escorting tour,home_is_urban * escort,-0.4316,-0.3929,0.8516,0,0,0,0,0 +Urban Areatype &Shopping tour,home_is_urban * shopping,0,0,0.533,0,0,0,0,0 +Urban Areatype & Maintenance tour,home_is_urban * othmaint,0,0,1.0316,0,0,1.0394,1.0394,0 +Urban Areatype & EatingOut tour,home_is_urban * eatout,0,0,0.68,0,0,0,0,0 +Urban Areatype & Discretionary tour,home_is_urban * othdiscr,0,0,0.9563,0,0,0,0,0 +1 Escort Tour Constant,escort == 1,0.0298,0.5272,1.7028,-0.0629,-0.3992,-0.4934,-0.4934,0.3622 +2+ Escort Tours Constant,escort >= 2,0.7402,1.5987,2.8379,0.9273,0.5175,1.4155,1.4155,2.2219 +1+ Shopping Tours Constant,shopping >= 1,0.4774,0.7569,1.8403,0.4683,0.5947,0.532,0.532,1.6919 +1+ Maintenance Tours Constant,othmaint >= 1,0.1202,0.5533,0.3348,-0.0653,0.1046,-0.4344,-0.4344,0.6788 +1+ Eating Out Tours Constant,eatout >= 1,0.0097,0.6914,2.0723,-0.1429,0.0245,-0.0242,-0.0242,0.9612 +1+ Visting Tours Constant,social >= 1,0.0522,0.1405,1.2172,-0.1272,0.2789,0.2367,0.2367,0.4424 +1+ Other Discretionary Tours Constant,othdiscr >= 1,0.7412,0.7989,1.3389,0.3334,0.4282,-0.2602,-0.2602,1.4935 +Dummy for 0-auto household & Escorting Tour,escort * no_cars,-2,-2,-2,-2,-2,-2,-2,-2 \ No newline at end of file diff --git a/example/configs/non_mandatory_tour_frequency_alternatives.csv b/example/configs/non_mandatory_tour_frequency_alternatives.csv new file mode 100644 index 000000000..1c0052f96 --- /dev/null +++ b/example/configs/non_mandatory_tour_frequency_alternatives.csv @@ -0,0 +1,97 @@ +escort,shopping,othmaint,othdiscr,eatout,social +0,0,0,0,0,0 +0,0,0,1,0,0 +0,0,0,0,0,1 +0,0,0,1,0,1 +0,0,0,0,1,0 +0,0,0,1,1,0 +0,0,0,0,1,1 +0,0,0,1,1,1 +0,0,1,0,0,0 +0,0,1,1,0,0 +0,0,1,0,0,1 +0,0,1,1,0,1 +0,0,1,0,1,0 +0,0,1,1,1,0 +0,0,1,0,1,1 +0,0,1,1,1,1 +0,1,0,0,0,0 +0,1,0,1,0,0 +0,1,0,0,0,1 +0,1,0,1,0,1 +0,1,0,0,1,0 +0,1,0,1,1,0 +0,1,0,0,1,1 +0,1,0,1,1,1 +0,1,1,0,0,0 +0,1,1,1,0,0 +0,1,1,0,0,1 +0,1,1,1,0,1 +0,1,1,0,1,0 +0,1,1,1,1,0 +0,1,1,0,1,1 +0,1,1,1,1,1 +1,0,0,0,0,0 +1,0,0,1,0,0 +1,0,0,0,0,1 +1,0,0,1,0,1 +1,0,0,0,1,0 +1,0,0,1,1,0 +1,0,0,0,1,1 +1,0,0,1,1,1 +1,0,1,0,0,0 +1,0,1,1,0,0 +1,0,1,0,0,1 +1,0,1,1,0,1 +1,0,1,0,1,0 +1,0,1,1,1,0 +1,0,1,0,1,1 +1,0,1,1,1,1 +1,1,0,0,0,0 +1,1,0,1,0,0 +1,1,0,0,0,1 +1,1,0,1,0,1 +1,1,0,0,1,0 +1,1,0,1,1,0 +1,1,0,0,1,1 +1,1,0,1,1,1 +1,1,1,0,0,0 +1,1,1,1,0,0 +1,1,1,0,0,1 +1,1,1,1,0,1 +1,1,1,0,1,0 +1,1,1,1,1,0 +1,1,1,0,1,1 +1,1,1,1,1,1 +2,0,0,0,0,0 +2,0,0,1,0,0 +2,0,0,0,0,1 +2,0,0,1,0,1 +2,0,0,0,1,0 +2,0,0,1,1,0 +2,0,0,0,1,1 +2,0,0,1,1,1 +2,0,1,0,0,0 +2,0,1,1,0,0 +2,0,1,0,0,1 +2,0,1,1,0,1 +2,0,1,0,1,0 +2,0,1,1,1,0 +2,0,1,0,1,1 +2,0,1,1,1,1 +2,1,0,0,0,0 +2,1,0,1,0,0 +2,1,0,0,0,1 +2,1,0,1,0,1 +2,1,0,0,1,0 +2,1,0,1,1,0 +2,1,0,0,1,1 +2,1,0,1,1,1 +2,1,1,0,0,0 +2,1,1,1,0,0 +2,1,1,0,0,1 +2,1,1,1,0,1 +2,1,1,0,1,0 +2,1,1,1,1,0 +2,1,1,0,1,1 +2,1,1,1,1,1 diff --git a/example/configs/settings.yaml b/example/configs/settings.yaml index 05cf2cdb0..c80b37fa8 100644 --- a/example/configs/settings.yaml +++ b/example/configs/settings.yaml @@ -1,6 +1,11 @@ store: mtc_asim.h5 -households_sample_size: 100000 +# area_types less than this are considered urban +urban_threshold: 4 +cbd_threshold: 2 +rural_threshold: 6 + +households_sample_size: 1000 county_map: San Francisco: 1 @@ -12,3 +17,34 @@ county_map: Napa: 7 Sonoma: 8 Marin: 9 + +employment_map: + 1: "full" + 2: "part" + 3: "not" + 4: "child" + +student_map: + 1: "high" + 2: "college" + 3: "not" + +person_type_map: + 1: "full" + 2: "part" + 3: "university" + 4: "nonwork" + 5: "retired" + 6: "driving" + 7: "school" + 8: "preschool" + +household_type_map: + 0: "null" + 1: "family_married" + 2: "family_male" + 3: "family_female" + 4: "nonfamily_male_alone" + 5: "nonfamily_male_notalone" + 6: "nonfamily_female_alone" + 7: "nonfamily_female_notalone" diff --git a/example/configs/tour_departure_and_duration.csv b/example/configs/tour_departure_and_duration.csv new file mode 100644 index 000000000..e501d097b --- /dev/null +++ b/example/configs/tour_departure_and_duration.csv @@ -0,0 +1 @@ +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_alternatives.csv b/example/configs/tour_departure_and_duration_alternatives.csv new file mode 100644 index 000000000..05f02b796 --- /dev/null +++ b/example/configs/tour_departure_and_duration_alternatives.csv @@ -0,0 +1,191 @@ +start,end +5,5 +5,6 +5,7 +5,8 +5,9 +5,10 +5,11 +5,12 +5,13 +5,14 +5,15 +5,16 +5,17 +5,18 +5,19 +5,20 +5,21 +5,22 +5,23 +6,6 +6,7 +6,8 +6,9 +6,10 +6,11 +6,12 +6,13 +6,14 +6,15 +6,16 +6,17 +6,18 +6,19 +6,20 +6,21 +6,22 +6,23 +7,7 +7,8 +7,9 +7,10 +7,11 +7,12 +7,13 +7,14 +7,15 +7,16 +7,17 +7,18 +7,19 +7,20 +7,21 +7,22 +7,23 +8,8 +8,9 +8,10 +8,11 +8,12 +8,13 +8,14 +8,15 +8,16 +8,17 +8,18 +8,19 +8,20 +8,21 +8,22 +8,23 +9,9 +9,10 +9,11 +9,12 +9,13 +9,14 +9,15 +9,16 +9,17 +9,18 +9,19 +9,20 +9,21 +9,22 +9,23 +10,10 +10,11 +10,12 +10,13 +10,14 +10,15 +10,16 +10,17 +10,18 +10,19 +10,20 +10,21 +10,22 +10,23 +11,11 +11,12 +11,13 +11,14 +11,15 +11,16 +11,17 +11,18 +11,19 +11,20 +11,21 +11,22 +11,23 +12,12 +12,13 +12,14 +12,15 +12,16 +12,17 +12,18 +12,19 +12,20 +12,21 +12,22 +12,23 +13,13 +13,14 +13,15 +13,16 +13,17 +13,18 +13,19 +13,20 +13,21 +13,22 +13,23 +14,14 +14,15 +14,16 +14,17 +14,18 +14,19 +14,20 +14,21 +14,22 +14,23 +15,15 +15,16 +15,17 +15,18 +15,19 +15,20 +15,21 +15,22 +15,23 +16,16 +16,17 +16,18 +16,19 +16,20 +16,21 +16,22 +16,23 +17,17 +17,18 +17,19 +17,20 +17,21 +17,22 +17,23 +18,18 +18,19 +18,20 +18,21 +18,22 +18,23 +19,19 +19,20 +19,21 +19,22 +19,23 +20,20 +20,21 +20,22 +20,23 +21,21 +21,22 +21,23 +22,22 +22,23 +23,23 \ No newline at end of file diff --git a/example/configs/workplace_location.csv b/example/configs/workplace_location.csv index af7b3ce91..0adf1b611 100644 --- a/example/configs/workplace_location.csv +++ b/example/configs/workplace_location.csv @@ -1 +1,17 @@ -Description,Expression,Alt "Distance, piecewise linear from 0 to 1 miles",@df.distance.clip(1),-0.8428 "Distance, piecewise linear from 1 to 2 miles","@(df.distance-1).clip(0,1)",-0.3104 "Distance, piecewise linear from 2 to 5 miles","@(df.distance-2).clip(0,3)",-0.3783 "Distance, piecewise linear from 5 to 15 miles","@(df.distance-5).clip(0,10)",-0.1285 "Distance, piecewise linear for 15+ miles",@(df.distance-15.0).clip(0),-0.0917 "Distance 0 to 5 mi, high and very high income",@(df.income_segment>=3)*df.distance.clip(upper=5),0.15 "Distance 5+ mi, high and very high income",@(df.income_segment>=3)*(df.distance-5).clip(0),0.02 "Size variable full-time worker, low income",@(df.income_segment==1)*df.size_low,1 "Size variable full-time worker, medium income",@(df.income_segment==2)*df.size_med,1 "Size variable full-time worker, high income",@(df.income_segment==3)*df.size_high,1 "Size variable full-time worker, very high income",@(df.income_segment==4)*df.size_veryhigh,1 "No attractions full-time worker, low income",@(df.income_segment==1)&(df.size_low==0),-999 "No attractions full-time worker, medium income",@(df.income_segment==2)&(df.size_med==0),-999 "No attractions full-time worker, high income",@(df.income_segment==3)&(df.size_high==0),-999 "No attractions full-time worker, very high income",@(df.income_segment==4)&(df.size_veryhigh==0),-999 Mode choice logsum,mcLogsum,0.3 \ No newline at end of file +Description,Expression,Alt +"Distance, piecewise linear from 0 to 1 miles",@df.distance.clip(1),-0.8428 +"Distance, piecewise linear from 1 to 2 miles","@(df.distance-1).clip(0,1)",-0.3104 +"Distance, piecewise linear from 2 to 5 miles","@(df.distance-2).clip(0,3)",-0.3783 +"Distance, piecewise linear from 5 to 15 miles","@(df.distance-5).clip(0,10)",-0.1285 +"Distance, piecewise linear for 15+ miles",@(df.distance-15.0).clip(0),-0.0917 +"Distance 0 to 5 mi, high and very high income",@(df.income_segment>=3)*df.distance.clip(upper=5),0.15 +"Distance 5+ mi, high and very high income",@(df.income_segment>=3)*(df.distance-5).clip(0),0.02 +"Size variable full-time worker, low income",@(df.income_segment==1)*df.size_low,1 +"Size variable full-time worker, medium income",@(df.income_segment==2)*df.size_med,1 +"Size variable full-time worker, high income",@(df.income_segment==3)*df.size_high,1 +"Size variable full-time worker, very high income",@(df.income_segment==4)*df.size_veryhigh,1 +"No attractions full-time worker, low income",@(df.income_segment==1)&(df.size_low==0),-999 +"No attractions full-time worker, medium income",@(df.income_segment==2)&(df.size_med==0),-999 +"No attractions full-time worker, high income",@(df.income_segment==3)&(df.size_high==0),-999 +"No attractions full-time worker, very high income",@(df.income_segment==4)&(df.size_veryhigh==0),-999 +Mode choice logsum,#mcLogsum,0.3 diff --git a/example/configs/workplace_location_size_terms.csv b/example/configs/workplace_location_size_terms.csv deleted file mode 100644 index f9b7da433..000000000 --- a/example/configs/workplace_location_size_terms.csv +++ /dev/null @@ -1 +0,0 @@ -purpose,segment,TOTHH,RETEMPN,FPSEMPN,HEREMPN,OTHEMPN,AGREMPN,MWTEMPN,AGE0519,HSENROLL,COLLFTE,COLLPTE work,low,0,0.129,0.193,0.383,0.12,0.01,0.164,0,0,0,0 work,med,0,0.12,0.197,0.325,0.139,0.008,0.21,0,0,0,0 work,high,0,0.11,0.207,0.284,0.154,0.006,0.239,0,0,0,0 work,veryhigh,0,0.093,0.27,0.241,0.146,0.004,0.246,0,0,0,0 university,university,0,0,0,0,0,0,0,0,0,0.592,0.408 school,grade,0,0,0,0,0,0,0,1,0,0,0 school,high,0,0,0,0,0,0,0,0,1,0,0 escort,kids,0,0.225,0,0.144,0,0,0,0.465,0.166,0,0 escort,no kids,0,0.225,0,0.144,0,0,0,0.465,0.166,0,0 shopping,shopping,0,1,0,0,0,0,0,0,0,0,0 eatOut,eatOut,0,0.742,0,0.258,0,0,0,0,0,0,0 othMaint,othMaint,0,0.482,0,0.518,0,0,0,0,0,0,0 social,social,0,0.522,0,0.478,0,0,0,0,0,0,0 othDiscr,othDiscr,0.252,0.212,0,0.272,0.165,0,0,0,0.098,0,0 atwork,atwork,0,0.742,0,0.258,0,0,0,0,0,0,0 \ No newline at end of file diff --git a/example/models.py b/example/models.py index 941d9973c..840212d2b 100644 --- a/example/models.py +++ b/example/models.py @@ -1,4 +1,5 @@ import urbansim.sim.simulation as sim +import urbansim.utils.misc as usim_misc import os from activitysim import activitysim as asim import openmatrix as omx @@ -7,47 +8,154 @@ import pandas as pd +# this is the max number of cars allowable in the auto ownership model +MAX_NUM_CARS = 5 + + +""" +This part of this file is currently creating small tables to serve as +alternatives in the various models +""" + + @sim.table() def auto_alts(): - return asim.identity_matrix(["cars%d" % i for i in range(5)]) + return asim.identity_matrix(["cars%d" % i for i in range(MAX_NUM_CARS)]) +@sim.table() +def mandatory_tour_frequency_alts(): + return asim.identity_matrix(["work1", "work2", "school1", "school2", + "work_and_school"]) + + +# these are the alternatives for the workplace choice @sim.table() def zones(): # I grant this is a weird idiom but it helps to name the index return pd.DataFrame({"TAZ": np.arange(1454)+1}).set_index("TAZ") +@sim.table() +def non_mandatory_tour_frequency_alts(): + f = os.path.join("configs", + "non_mandatory_tour_frequency_alternatives.csv") + return pd.read_csv(f) + + +@sim.column("non_mandatory_tour_frequency_alts") +def tot_tours(non_mandatory_tour_frequency_alts): + # this assumes that the alt dataframe is only counts of trip types + return non_mandatory_tour_frequency_alts.local.sum(axis=1) + + +@sim.table() +def tour_departure_and_duration_alts(): + # right now this file just contains the start and end hour + f = os.path.join("configs", + "tour_departure_and_duration_alternatives.csv") + return pd.read_csv(f) + + +# 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 + + +""" +Read in the omx files and create the skim objects +""" + + @sim.injectable() def nonmotskm_omx(): - return omx.openFile('data/nonmotskm.omx') + return omx.openFile(os.path.join('data', "nonmotskm.omx")) + + +@sim.injectable() +def distance_skim(nonmotskm_omx): + return skim.Skim(nonmotskm_omx['DIST'], offset=-1) + + +@sim.injectable() +def sovam_skim(nonmotskm_omx): + # FIXME use the right omx file + return skim.Skim(nonmotskm_omx['DIST'], offset=-1) + + +@sim.injectable() +def sovmd_skim(nonmotskm_omx): + # FIXME use the right omx file + return skim.Skim(nonmotskm_omx['DIST'], offset=-1) @sim.injectable() -def distance_matrix(nonmotskm_omx): +def sovpm_skim(nonmotskm_omx): + # FIXME use the right omx file return skim.Skim(nonmotskm_omx['DIST'], offset=-1) +""" +Read in the spec files and reformat as necessary +""" + + @sim.injectable() def auto_ownership_spec(): - f = os.path.join('configs', "auto_ownership_coeffs.csv") + f = os.path.join('configs', "auto_ownership.csv") + # FIXME should read in all variables and comment out ones not used return asim.read_model_spec(f).head(4*26) @sim.injectable() def workplace_location_spec(): f = os.path.join('configs', "workplace_location.csv") + # FIXME should read in all variables and comment out ones not used return asim.read_model_spec(f).head(15) +@sim.injectable() +def mandatory_tour_frequency_spec(): + f = os.path.join('configs', "mandatory_tour_frequency.csv") + return asim.read_model_spec(f) + + +@sim.injectable() +def non_mandatory_tour_frequency_spec(): + f = os.path.join('configs', "non_mandatory_tour_frequency.csv") + # this is a spec in already stacked format + # it also has multiple segments in different columns in the spec + return asim.read_model_spec(f, stack=False) + + @sim.table() -def workplace_size_spec(): - f = os.path.join('configs', 'workplace_location_size_terms.csv') +def destination_choice_size_terms(): + f = os.path.join('configs', 'destination_choice_size_terms.csv') return pd.read_csv(f) @sim.table() -def workplace_size_terms(land_use, workplace_size_spec): +def destination_choice_spec(): + f = os.path.join('configs', 'destination_choice_alternatives_sample.csv') + return asim.read_model_spec(f, stack=False).head(5) + + +@sim.table() +def tour_departure_and_duration_spec(): + f = os.path.join('configs', 'tour_departure_and_duration.csv') + return asim.read_model_spec(f, stack=False) + + +""" +This is a special submodel for the workplace location choice +""" + + +@sim.table() +def workplace_size_terms(land_use, destination_choice_size_terms): """ This method takes the land use data and multiplies various columns of the land use data by coefficients from the workplace_size_spec table in order @@ -56,7 +164,7 @@ def workplace_size_terms(land_use, workplace_size_spec): income) """ land_use = land_use.to_frame() - df = workplace_size_spec.to_frame().query("purpose == 'work'") + df = destination_choice_size_terms.to_frame().query("purpose == 'work'") df = df.drop("purpose", axis=1).set_index("segment") new_df = {} for index, row in df.iterrows(): @@ -70,6 +178,12 @@ def workplace_size_terms(land_use, workplace_size_spec): return new_df +""" +Auto ownership is a standard model which predicts how many cars a household +with given characteristics owns +""" + + @sim.model() def auto_ownership_simulate(households, auto_alts, @@ -86,25 +200,38 @@ def auto_ownership_simulate(households, asim.simple_simulate(choosers, alternatives, auto_ownership_spec, mult_by_alt_col=True) + # map these back to integers + choices = choices.map(dict([("cars%d" % i, i) + for i in range(MAX_NUM_CARS)])) + print "Choices:\n", choices.value_counts() sim.add_column("households", "auto_ownership", choices) return model_design +""" +The workplace location model predicts the zones in which various people will +work. Interestingly there's not really any supply side to this model - we +assume there are workplaces for the people to work. +""" + + +# FIXME there are three school models that go along with this one which have +# FIXME not been implemented yet @sim.model() def workplace_location_simulate(persons, households, zones, workplace_location_spec, - distance_matrix, + distance_skim, workplace_size_terms): choosers = sim.merge_tables(persons.name, tables=[persons, households]) alternatives = zones.to_frame().join(workplace_size_terms.to_frame()) skims = { - "distance": distance_matrix + "distance": distance_skim } choices, model_design = \ @@ -116,12 +243,329 @@ def workplace_location_simulate(persons, mult_by_alt_col=False, sample_size=50) - print "Describe of hoices:\n", choices.describe() + print "Describe of choices:\n", choices.describe() sim.add_column("persons", "workplace_taz", choices) return model_design +""" +This model predicts the frequency of making mandatory trips (see the +alternatives above) - these trips include work and school in some combination. +""" + + +@sim.model() +def mandatory_tour_frequency(persons, + households, + land_use, + mandatory_tour_frequency_alts, + mandatory_tour_frequency_spec): + + choosers = sim.merge_tables(persons.name, tables=[persons, + households, + land_use]) + + # filter based on results of CDAP + choosers = choosers[choosers.cdap_activity == 'M'] + print "%d persons run for mandatory tour model" % len(choosers) + + choices, model_design = \ + asim.simple_simulate(choosers, + mandatory_tour_frequency_alts.to_frame(), + mandatory_tour_frequency_spec, + mult_by_alt_col=True) + + print "Choices:\n", choices.value_counts() + sim.add_column("persons", "mandatory_tour_frequency", choices) + + return model_design + + +""" +This model predicts the frequency of making non-mandatory trips ( +alternatives for this model come from a seaparate csv file which is +configured by the user) - these trips include escort, shopping, othmaint, +othdiscr, eatout, and social trips in various combination. +""" + + +@sim.model() +def non_mandatory_tour_frequency(persons, + households, + land_use, + accessibility, + non_mandatory_tour_frequency_alts, + non_mandatory_tour_frequency_spec): + + choosers = sim.merge_tables(persons.name, tables=[persons, + households, + land_use, + accessibility]) + + # filter based on results of CDAP + choosers = choosers[choosers.cdap_activity.isin(['M', 'N'])] + print "%d persons run for non-mandatory tour model" % len(choosers) + + choices_list = [] + # segment by person type and pick the right spec for each person type + for name, segment in choosers.groupby('ptype_cat'): + + print "Running segment '%s' of size %d" % (name, len(segment)) + + choices, _ = \ + asim.simple_simulate(segment, + non_mandatory_tour_frequency_alts.to_frame(), + # notice that we pick the column for the + # segment for each segment we run + non_mandatory_tour_frequency_spec[name], + mult_by_alt_col=False) + choices_list.append(choices) + + choices = pd.concat(choices_list) + + print "Choices:\n", choices.value_counts() + # this is adding the INDEX of the alternative that is chosen - when + # we use the results of this choice we will need both these indexes AND + # the alternatives themselves + sim.add_column("persons", "non_mandatory_tour_frequency", choices) + + +""" +We have now generated mandatory and non-mandatory tours, but they are +attributes of the person table - this function creates a "tours" table which +has one row per tour that has been generated (and the person id it is +associated with) +""" + + +@sim.table() +def non_mandatory_tours(persons, + non_mandatory_tour_frequency_alts): + + # get the actual alternatives for each person - have to go back to the + # non_mandatory_tour_frequency_alts dataframe to get this - the choice + # above just stored the index values for the chosen alts + tours = non_mandatory_tour_frequency_alts.local.\ + loc[persons.non_mandatory_tour_frequency] + + # assign person ids to the index + tours.index = persons.index[~persons.non_mandatory_tour_frequency.isnull()] + + # reformat with the columns given below + tours = tours.stack().reset_index() + tours.columns = ["person_id", "trip_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 + tours = tours.take(np.repeat(tours.index.values, tours.num_tours.values)) + + # make index unique and drop num_tours since we don't need it anymore + tours = tours.reset_index(drop=True).drop("num_tours", axis=1) + + """ + Pretty basic at this point - trip table looks like this so far + person_id trip_type + 0 4419 escort + 1 4419 escort + 2 4419 othmaint + 3 4419 eatout + 4 4419 social + 5 10001 escort + 6 10001 escort + """ + return tours + + +sim.broadcast('persons', 'non_mandatory_tours', + cast_index=True, onto_on='person_id') + + +""" +This does the same as the above but for mandatory tours. Ending format is +the same as in the comment above except trip types are "work" and "school" +""" + +@sim.table() +def mandatory_tours(persons): + + persons = persons.to_frame(columns=["mandatory_tour_frequency", + "is_worker"]) + persons = persons[~persons.mandatory_tour_frequency.isnull()] + + tours = [] + # this is probably easier to do in non-vectorized fashion (at least for now) + for key, row in persons.iterrows(): + + mtour = row.mandatory_tour_frequency + is_worker = row.is_worker + + # 1 work trip + if mtour == "work1": + tours += [(key, "work", 1)] + # 2 work trips + elif mtour == "work2": + tours += [(key, "work", 1), (key, "work", 2)] + # 1 school trip + elif mtour == "school1": + tours += [(key, "school", 1)] + # 2 school trips + elif mtour == "school2": + tours += [(key, "school", 1), (key, "school", 2)] + # 1 work and 1 school trip + elif mtour == "work_and_school": + if is_worker: + # is worker, work trip goes first + tours += [(key, "work", 1), (key, "school", 2)] + else: + # is student, work trip goes second + tours += [(key, "school", 1), (key, "work", 2)] + else: + assert 0 + + return pd.DataFrame(tours, columns=["person_id", "trip_type", "tour_num"]) + + +sim.broadcast('persons', 'mandatory_tours', + cast_index=True, onto_on='person_id') + + +""" +Given the tour generation from the above, each tour needs to have a +destination, so in this case tours are the choosers (with the associated +person that's making the tour) +""" + + +@sim.model() +def destination_choice(non_mandatory_tours, + persons, + households, + land_use, + zones, + distance_skim, + destination_choice_spec): + + tours = non_mandatory_tours + + # FIXME these models don't have size terms at the moment + + # FIXME these models don't use stratified sampling + + # FIXME is the distance to the second trip based on the choice of the + # FIXME first trip - ouch! + + # choosers are tours - in a sense tours are choosing their destination + choosers = sim.merge_tables(tours.name, tables=[tours, + persons, + households]) + + skims = { + "distance": distance_skim + } + + choices_list = [] + # segment by trip type and pick the right spec for each person type + for name, segment in choosers.groupby('trip_type'): + + # FIXME - there are two options here escort with kids and without + if name == "escort": + continue + + print "Running segment '%s' of size %d" % (name, len(segment)) + + choices, _ = \ + asim.simple_simulate(choosers, + zones.to_frame(), + destination_choice_spec[name], + skims, + skim_join_name="TAZ", + mult_by_alt_col=False, + sample_size=50) + + choices_list.append(choices) + + choices = pd.concat(choices_list) + + print "Choices:\n", choices.describe() + # every trip now has a destination which is the index from the + # alternatives table - in this case it's the destination taz + sim.add_column("non_mandatory_tours", "destination", choices) + + +""" +This model predicts the departure time and duration of each activity +""" + + +@sim.model() +def mandatory_tour_departure_and_duration(mandatory_tours, + persons, + households, + land_use, + tour_departure_and_duration_alts, + tour_departure_and_duration_spec): + + choosers = sim.merge_tables(mandatory_tours.name, tables=[mandatory_tours, + persons, + households, + land_use]) + + print "Running %d mandatory tour scheduling choices" % len(choosers) + + # assert there's only a first or second mandatory tour - that's a basic + # assumption of this model formulation right now + assert choosers.tour_num.isin([1, 2]).value_counts()[True] == len(choosers) + + 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() + + print choosers.mandatory_tour_frequency.value_counts() + print spec + + # 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 + # then for the second tours - this is mainly because the second tours are + # dependent on the first tours' scheduling + + print "Running %d mandatory first tour choices" % len(first_tours) + + alts["end_of_previous_tour"] = -1 + + # FIXME - a note to remember that this also needs the mode choice logsum + alts["mode_choice_logsum"] = 0 + + first_choices, _ = \ + asim.simple_simulate(first_tours, alts, spec, mult_by_alt_col=False) + + print "Running %d mandatory second tour choices" % len(second_tours) + + # FIXME need to set end_of_previous_tour to the ends computed above + second_choices, _ = \ + asim.simple_simulate(second_tours, alts, spec, mult_by_alt_col=False) + + choices = pd.concat([first_choices, second_choices]) + + # as with non-mandatory tour generation, this stores the INDEX of + # the alternative in the tour_departure and_duration_alts dataframe - + # 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) + + +""" +This section contains computed columns on each table. +""" + +""" +for the land use table +""" + + @sim.column("land_use") def total_households(land_use): return land_use.local.TOTHH @@ -139,4 +583,357 @@ def total_acres(land_use): @sim.column("land_use") def county_id(land_use): - return land_use.local.COUNTY \ No newline at end of file + return land_use.local.COUNTY + + +""" +for households +""" + + +# just a rename / alias +@sim.column("households") +def home_taz(households): + return households.TAZ + + +# map household type ids to strings +@sim.column("households") +def household_type(households, settings): + return households.HHT.map(settings["household_type_map"]) + + +@sim.column("households") +def non_family(households): + return households.household_type.isin(["nonfamily_male_alone", + "nonfamily_male_notalone", + "nonfamily_female_alone", + "nonfamily_female_notalone"]) + + +# can't just invert these unfortunately because there's a null household type +@sim.column("households") +def family(households): + return households.household_type.isin(["family_married", + "family_male", + "family_female"]) + + +@sim.column("households") +def num_under16_not_at_school(persons, households): + return persons.under16_not_at_school.groupby(persons.household_id).size().\ + reindex(households.index).fillna(0) + + +@sim.column("households") +def auto_ownership(households): + # FIXME this is really because we ask for ALL columns in the persons data + # FIXME frame - urbansim actually only asks for the columns that are used by + # FIXME the model specs in play at that time + return pd.Series(0, households.index) + + +@sim.column('households') +def no_cars(households): + return (households.auto_ownership == 0) + + +@sim.column('households') +def home_is_urban(households, land_use, settings): + s = usim_misc.reindex(land_use.area_type, households.home_taz) + return s < settings['urban_threshold'] + + +@sim.column('households') +def home_is_rural(households, land_use, settings): + s = usim_misc.reindex(land_use.area_type, households.home_taz) + return s > settings['rural_threshold'] + + +@sim.column('households') +def car_sufficiency(households, persons): + return households.auto_ownership - persons.household_id.value_counts() + + +# this is an idiom to grab the person of the specified type and check to see if +# there is 1 or more of that kind of person in each household +def presence_of(ptype, persons, households, at_home=False): + if at_home: + # if at_home, they need to be of given type AND at home + s = persons.household_id[(persons.ptype_cat == ptype) & + (persons.cdap_activity == "H")] + else: + s = persons.household_id[persons.ptype_cat == ptype] + + return (s.value_counts() > 0).reindex(households.index).fillna(False) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_non_worker(persons, households): + return presence_of("nonwork", persons, households) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_retiree(persons, households): + return presence_of("retired", persons, households) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_preschool_kid(persons, households): + return presence_of("preschool", persons, households) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_preschool_kid_at_home(persons, households): + return presence_of("preschool", persons, households, at_home=True) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_driving_kid(persons, households): + return presence_of("driving", persons, households) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_school_kid(persons, households): + return presence_of("school", persons, households) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_school_kid_at_home(persons, households): + return presence_of("school", persons, households, at_home=True) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_full_time(persons, households): + return presence_of("full", persons, households) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_part_time(persons, households): + return presence_of("part", persons, households) + + +# FIXME this is in non-mandatory tour generation - and should really be from +# FIXME the perspective of the current chooser - which it's not right now +@sim.column('households') +def has_university(persons, households): + return presence_of("university", persons, households) + + +""" +for the persons table +""" + + +# FIXME - this is my "placeholder" for the CDAP model ;) +@sim.column("persons") +def cdap_activity(persons): + return pd.Series(np.random.randint(3, size=len(persons)), + index=persons.index).map({0: 'M', 1: 'N', 2: 'H'}) + + +# FIXME - these are my "placeholder" for joint trip generation +# number of joint shopping tours +@sim.column("persons") +def num_shop_j(persons): + return pd.Series(0, persons.index) + + +# FIXME - these are my "placeholder" for joint trip generation +# number of joint shopping tours +@sim.column("persons") +def num_main_j(persons): + return pd.Series(0, persons.index) + + +# FIXME - these are my "placeholder" for joint trip generation +# number of joint shopping tours +@sim.column("persons") +def num_eat_j(persons): + return pd.Series(0, persons.index) + + +# FIXME - these are my "placeholder" for joint trip generation +# number of joint shopping tours +@sim.column("persons") +def num_visi_j(persons): + return pd.Series(0, persons.index) + + +# FIXME - these are my "placeholder" for joint trip generation +# number of joint shopping tours +@sim.column("persons") +def num_disc_j(persons): + return pd.Series(0, persons.index) + + +@sim.column("persons") +def num_joint_tours(persons): + return persons.num_shop_j + persons.num_main_j + persons.num_eat_j +\ + persons.num_visi_j + persons.num_disc_j + + +@sim.column("persons") +def male(persons): + return persons.sex == 1 + + +@sim.column("persons") +def female(persons): + return persons.sex == 1 + + +# count the number of mandatory tours for each person +@sim.column("persons") +def num_mand(persons): + # FIXME this is really because we ask for ALL columns in the persons data + # FIXME frame - urbansim actually only asks for the columns that are used by + # FIXME the model specs in play at that time + if "mandatory_tour_frequency" not in persons.columns: + return pd.Series(0, index=persons.index) + + s = persons.mandatory_tour_frequency.map({ + "work1": 1, + "work2": 2, + "school1": 1, + "school2": 2, + "work_and_school": 2 + }) + return s + + +# FIXME now totally sure what this is but it's used in non mandatory tour +# FIXME generation and probably has to do with remaining unscheduled time +@sim.column('persons') +def max_window(persons): + return pd.Series(0, persons.index) + + +# convert employment categories to string descriptors +@sim.column("persons") +def employed_cat(persons, settings): + return persons.pemploy.map(settings["employment_map"]) + + +# convert student categories to string descriptors +@sim.column("persons") +def student_cat(persons, settings): + return persons.pstudent.map(settings["student_map"]) + + +# convert person type categories to string descriptors +@sim.column("persons") +def ptype_cat(persons, settings): + return persons.ptype.map(settings["person_type_map"]) + + +# borrowing these definitions from the original code +@sim.column("persons") +def student_is_employed(persons): + return (persons.ptype_cat.isin(['university', 'driving']) & + persons.employed_cat.isin(['full', 'part'])) + + +@sim.column("persons") +def nonstudent_to_school(persons): + return (persons.ptype_cat.isin(['full', 'part', 'nonwork', 'retired']) & + persons.student_cat.isin(['high', 'college'])) + + +@sim.column("persons") +def under16_not_at_school(persons): + return (persons.ptype_cat.isin(["school", "preschool"]) & + persons.cdap_activity.isin(["N", "H"])) + + +@sim.column("persons") +def is_worker(persons): + return persons.employed_cat.isin(['full', 'part']) + + +@sim.column("persons") +def is_student(persons): + return persons.student_cat.isin(['high', 'college']) + + +@sim.column("persons") +def workplace_taz(persons): + # FIXME this is really because we ask for ALL columns in the persons data + # FIXME frame - urbansim actually only asks for the columns that are used by + # FIXME the model specs in play at that time + return pd.Series(1, persons.index) + + +@sim.column("persons") +def home_taz(households, persons): + return usim_misc.reindex(households.home_taz, + persons.household_id) + + +@sim.column("persons") +def school_taz(persons): + # FIXME need to fix this after getting school lcm working + return persons.workplace_taz + + +# this use the distance skims to compute the raw distance to work from home +@sim.column("persons") +def distance_to_work(persons, distance_skim): + return pd.Series(distance_skim.get(persons.home_taz, + persons.workplace_taz), + index=persons.index) + + +# same deal but to school +@sim.column("persons") +def distance_to_school(persons, distance_skim): + return pd.Series(distance_skim.get(persons.home_taz, + persons.school_taz), + index=persons.index) + + +# similar but this adds the am peak travel time to the pm peak travel time in +# the opposite direction (by car) +@sim.column("persons") +def roundtrip_auto_time_to_work(persons, sovam_skim, sovpm_skim): + return pd.Series(sovam_skim.get(persons.home_taz, + persons.workplace_taz) + + sovpm_skim.get(persons.workplace_taz, + persons.home_taz), + index=persons.index) + + +# this adds the am peak travel time to the md peak travel time in +# the opposite direction (by car), assuming students leave school earlier +@sim.column("persons") +def roundtrip_auto_time_to_school(persons, sovam_skim, sovmd_skim): + return pd.Series(sovam_skim.get(persons.home_taz, + persons.school_taz) + + sovmd_skim.get(persons.school_taz, + persons.home_taz), + index=persons.index) + + +@sim.column('persons') +def workplace_in_cbd(persons, land_use, settings): + s = usim_misc.reindex(land_use.area_type, persons.workplace_taz) + return s < settings['cbd_threshold'] + diff --git a/notebooks/data_mover.ipynb b/notebooks/data_mover.ipynb index 1c065abf1..e6329cec6 100644 --- a/notebooks/data_mover.ipynb +++ b/notebooks/data_mover.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:afbc3e7040dd9e4a5b21433063f13a6a8abfcc04bcfc6574e7e43376c257cd33" + "signature": "sha256:07f23263339f1751ee4eb702d126692b9ed2785fe8640a8906eb0fb110d9e67a" }, "nbformat": 3, "nbformat_minor": 0, @@ -43,8 +43,10 @@ "col_map = {\n", " \"HHID\": \"household_id\",\n", " \"AGE\": \"age\",\n", + " \"SEX\": \"sex\",\n", " \"hworkers\": \"workers\",\n", - " \"HINC\": \"income\"\n", + " \"HINC\": \"income\",\n", + " \"AREATYPE\": \"area_type\"\n", "}" ], "language": "python", diff --git a/notebooks/simulation.ipynb b/notebooks/simulation.ipynb index 1643e621d..d81303ad9 100644 --- a/notebooks/simulation.ipynb +++ b/notebooks/simulation.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:68dd59fb87c331bcb79d97a97557ee2ee411309bd3a85e58d6bee4b169b221df" + "signature": "sha256:2ac723c10479d39a6126f1871723950f6eb803212ddda416f1652722e84434c1" }, "nbformat": 3, "nbformat_minor": 0, @@ -39,35 +39,55 @@ "stream": "stdout", "text": [ "Running model 'workplace_location_simulate'\n", - "Describe of hoices:\n" + "Describe of choices:\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ - "count 258078.000000\n", - "mean 718.510997\n", - "std 422.975764\n", - "min 1.000000\n", - "25% 352.000000\n", - "50% 719.000000\n", - "75% 1083.000000\n", - "max 1454.000000\n", + "count 2513.000000\n", + "mean 719.074413\n", + "std 426.054061\n", + "min 1.000000\n", + "25% 356.000000\n", + "50% 720.000000\n", + "75% 1090.000000\n", + "max 1454.000000\n", "Name: TAZ, dtype: float64\n", - "Time to execute model 'workplace_location_simulate': 35.33s" + "Time to execute model 'workplace_location_simulate': 7.61s\n", + "Total time to execute: 7.61s\n" ] - }, + } + ], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print sim.get_table(\"persons\").distance_to_work.describe()" + ], + "language": "python", + "metadata": {}, + "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ - "\n", - "Total time to execute: 35.34s\n" + "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", + "dtype: float64\n" ] } ], - "prompt_number": 2 + "prompt_number": 3 }, { "cell_type": "code", @@ -90,13 +110,34 @@ "output_type": "stream", "stream": "stdout", "text": [ - "cars2 47959\n", - "cars3 38186\n", - "cars1 7528\n", - "cars4 5123\n", - "cars0 1204\n", + "2 477\n", + "3 379\n", + "1 94\n", + "4 38\n", + "0 12\n", "dtype: int64\n", - "Time to execute model 'auto_ownership_simulate': 4.62s" + "Time to execute model 'auto_ownership_simulate': 0.55s\n", + "Total time to execute: 0.55s\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "sim.run(['mandatory_tour_frequency'])" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Running model 'mandatory_tour_frequency'\n", + "863 persons run for mandatory tour model" ] }, { @@ -104,615 +145,1154 @@ "stream": "stdout", "text": [ "\n", - "Total time to execute: 4.62s\n" + "WARNING: Describe of columns with no variability:\n" + ] + }, + { + "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", + "\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", + "\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", + "Choices:\n", + "work_and_school 330\n", + "work2 262\n", + "work1 160\n", + "school2 56\n", + "school1 55\n", + "dtype: int64\n", + "Time to execute model 'mandatory_tour_frequency': 3.11s\n", + "Total time to execute: 3.11s\n" ] } ], - "prompt_number": 3 + "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ - "sim.get_table(\"land_use\").to_frame().describe()" + "sim.run(['non_mandatory_tour_frequency'])" ], "language": "python", "metadata": {}, "outputs": [ { - "html": [ - "
\n", - " | DISTRICT | \n", - "SD | \n", - "COUNTY | \n", - "TOTHH | \n", - "HHPOP | \n", - "TOTPOP | \n", - "EMPRES | \n", - "SFDU | \n", - "MFDU | \n", - "HHINCQ1 | \n", - "... | \n", - "hhlds | \n", - "sftaz | \n", - "gqpop | \n", - "employment_density | \n", - "total_acres | \n", - "county_id | \n", - "density_index | \n", - "household_density | \n", - "total_households | \n", - "total_employment | \n", - "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "... | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1453.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "1454.000000 | \n", - "
mean | \n", - "14.908528 | \n", - "14.908528 | \n", - "3.835626 | \n", - "1793.688446 | \n", - "4816.408528 | \n", - "4917.978680 | \n", - "2168.684319 | \n", - "1122.798487 | \n", - "670.889959 | \n", - "508.134801 | \n", - "... | \n", - "1793.688446 | \n", - "727.500000 | \n", - "101.570151 | \n", - "9.596395 | \n", - "3146.071457 | \n", - "3.835626 | \n", - "2.279554 | \n", - "6.008186 | \n", - "1793.688446 | \n", - "2247.736589 | \n", - "
std | \n", - "8.701078 | \n", - "8.701078 | \n", - "2.040153 | \n", - "961.021405 | \n", - "2686.029808 | \n", - "2690.352928 | \n", - "1211.109335 | \n", - "854.895353 | \n", - "717.261660 | \n", - "378.753528 | \n", - "... | \n", - "961.021405 | \n", - "419.877958 | \n", - "393.886676 | \n", - "45.067313 | \n", - "16945.908840 | \n", - "2.040153 | \n", - "3.945717 | \n", - "8.565908 | \n", - "961.021405 | \n", - "3538.356220 | \n", - "
min | \n", - "1.000000 | \n", - "1.000000 | \n", - "1.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "... | \n", - "0.000000 | \n", - "1.000000 | \n", - "-1.000000 | \n", - "0.000000 | \n", - "13.000000 | \n", - "1.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "
25% | \n", - "8.000000 | \n", - "8.000000 | \n", - "3.000000 | \n", - "1200.250000 | \n", - "3288.250000 | \n", - "3384.500000 | \n", - "1460.500000 | \n", - "602.000000 | \n", - "144.500000 | \n", - "257.000000 | \n", - "... | \n", - "1200.250000 | \n", - "364.250000 | \n", - "5.000000 | \n", - "0.877829 | \n", - "230.000000 | \n", - "3.000000 | \n", - "0.550232 | \n", - "1.910701 | \n", - "1200.250000 | \n", - "482.000000 | \n", - "
50% | \n", - "15.000000 | \n", - "15.000000 | \n", - "4.000000 | \n", - "1681.500000 | \n", - "4504.500000 | \n", - "4577.000000 | \n", - "2016.000000 | \n", - "1034.000000 | \n", - "460.000000 | \n", - "434.000000 | \n", - "... | \n", - "1681.500000 | \n", - "727.500000 | \n", - "18.000000 | \n", - "2.158701 | \n", - "397.000000 | \n", - "4.000000 | \n", - "1.289224 | \n", - "3.939122 | \n", - "1681.500000 | \n", - "1005.500000 | \n", - "
75% | \n", - "20.750000 | \n", - "20.750000 | \n", - "5.000000 | \n", - "2259.750000 | \n", - "6033.750000 | \n", - "6098.500000 | \n", - "2735.500000 | \n", - "1496.000000 | \n", - "907.750000 | \n", - "674.750000 | \n", - "... | \n", - "2259.750000 | \n", - "1090.750000 | \n", - "71.000000 | \n", - "5.492696 | \n", - "883.500000 | \n", - "5.000000 | \n", - "2.337577 | \n", - "6.693238 | \n", - "2259.750000 | \n", - "2215.750000 | \n", - "
max | \n", - "34.000000 | \n", - "34.000000 | \n", - "9.000000 | \n", - "12542.000000 | \n", - "39671.000000 | \n", - "40020.000000 | \n", - "16799.000000 | \n", - "12413.000000 | \n", - "4920.000000 | \n", - "3754.000000 | \n", - "... | \n", - "12542.000000 | \n", - "1454.000000 | \n", - "7810.000000 | \n", - "877.564767 | \n", - "372520.000000 | \n", - "9.000000 | \n", - "46.360371 | \n", - "90.891304 | \n", - "12542.000000 | \n", - "37950.000000 | \n", - "
8 rows \u00d7 48 columns
\n", - "\n", - " | TAZ | \n", - "SERIALNO | \n", - "PUMA5 | \n", - "income | \n", - "PERSONS | \n", - "HHT | \n", - "UNITTYPE | \n", - "NOC | \n", - "BLDGSZ | \n", - "TENURE | \n", - "... | \n", - "bucketBin | \n", - "originalPUMA | \n", - "hmultiunit | \n", - "num_young_adults | \n", - "drivers | \n", - "num_children | \n", - "num_adolescents | \n", - "income_in_thousands | \n", - "num_young_children | \n", - "num_college_age | \n", - "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "... | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "100000.000000 | \n", - "
mean | \n", - "752.439040 | \n", - "4924260.422350 | \n", - "2168.287950 | \n", - "77684.096720 | \n", - "2.580780 | \n", - "2.642540 | \n", - "0.077640 | \n", - "0.468280 | \n", - "3.529460 | \n", - "1.892780 | \n", - "... | \n", - "4.484880 | \n", - "2168.287950 | \n", - "0.401800 | \n", - "0.394180 | \n", - "2.063810 | \n", - "0.357290 | \n", - "0.060680 | \n", - "77.684097 | \n", - "0.159680 | \n", - "0.226650 | \n", - "
std | \n", - "430.258155 | \n", - "2863687.886756 | \n", - "516.271349 | \n", - "81341.474187 | \n", - "1.606362 | \n", - "2.066835 | \n", - "0.367387 | \n", - "0.913982 | \n", - "2.517375 | \n", - "1.010353 | \n", - "... | \n", - "2.871932 | \n", - "516.271349 | \n", - "0.490264 | \n", - "0.728922 | \n", - "1.122662 | \n", - "0.760368 | \n", - "0.260074 | \n", - "81.341474 | \n", - "0.462498 | \n", - "0.589748 | \n", - "
min | \n", - "1.000000 | \n", - "496.000000 | \n", - "1000.000000 | \n", - "-20000.000000 | \n", - "1.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "... | \n", - "0.000000 | \n", - "1000.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "-20.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "
25% | \n", - "374.000000 | \n", - "2456274.500000 | \n", - "2104.000000 | \n", - "26500.000000 | \n", - "1.000000 | \n", - "1.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "2.000000 | \n", - "1.000000 | \n", - "... | \n", - "2.000000 | \n", - "2104.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "1.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "26.500000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "
50% | \n", - "764.000000 | \n", - "4895910.500000 | \n", - "2303.000000 | \n", - "58000.000000 | \n", - "2.000000 | \n", - "1.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "2.000000 | \n", - "2.000000 | \n", - "... | \n", - "4.000000 | \n", - "2303.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "2.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "58.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "
75% | \n", - "1144.000000 | \n", - "7357629.750000 | \n", - "2410.000000 | \n", - "100000.000000 | \n", - "4.000000 | \n", - "4.000000 | \n", - "0.000000 | \n", - "1.000000 | \n", - "5.000000 | \n", - "3.000000 | \n", - "... | \n", - "7.000000 | \n", - "2410.000000 | \n", - "1.000000 | \n", - "1.000000 | \n", - "2.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "100.000000 | \n", - "0.000000 | \n", - "0.000000 | \n", - "
max | \n", - "1454.000000 | \n", - "9999811.000000 | \n", - "2714.000000 | \n", - "1237000.000000 | \n", - "25.000000 | \n", - "7.000000 | \n", - "2.000000 | \n", - "10.000000 | \n", - "10.000000 | \n", - "4.000000 | \n", - "... | \n", - "9.000000 | \n", - "2714.000000 | \n", - "1.000000 | \n", - "9.000000 | \n", - "25.000000 | \n", - "8.000000 | \n", - "5.000000 | \n", - "1237.000000 | \n", - "8.000000 | \n", - "24.000000 | \n", - "
8 rows \u00d7 53 columns
\n", - "