Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Billy Charlton committed Feb 19, 2015
2 parents 364348c + 79d11c9 commit fc1a737
Show file tree
Hide file tree
Showing 88 changed files with 27,014 additions and 19,250 deletions.
55 changes: 54 additions & 1 deletion EmmeProject.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
#Copyright [2014] [Puget Sound Regional Council]

#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.

import inro.emme.desktop.app as app
import inro.modeller as _m
import inro.emme.matrix as ematrix
Expand All @@ -12,6 +26,7 @@
from multiprocessing import Pool, pool
sys.path.append(os.path.join(os.getcwd(),"inputs"))
from input_configuration import *
from EmmeProject import *


class EmmeProject:
Expand Down Expand Up @@ -101,20 +116,32 @@ def process_shape(self, linkshape_file):
scenario = self.current_scenario)
def change_scenario(self):
self.current_scenario = list(self.bank.scenarios())[0]

def delete_matrix(self, matrix):
NAMESPACE = "inro.emme.data.matrix.delete_matrix"
process = self.m.tool(NAMESPACE)
process(matrix, self.bank)

def delete_matrices(self, matrix_type):
NAMESPACE = "inro.emme.data.matrix.delete_matrix"
process = self.m.tool(NAMESPACE)
for matrix in self.bank.matrices():
if matrix_type == "ALL":
process(matrix, self.bank)
elif matrix.type == matrix_type:
process(matrix, self.bank)

def create_matrix (self, matrix_name, matrix_description, matrix_type):
NAMESPACE = "inro.emme.data.matrix.create_matrix"
process = self.m.tool(NAMESPACE)
print self.current_scenario
process (matrix_id= self.bank.available_matrix_identifier(matrix_type),
matrix_name= matrix_name,
matrix_description= matrix_description,
default_value=0,
overwrite=True,
scenario=self.current_scenario)

def matrix_calculator(self, **kwargs):
spec = json_to_dictionary('matrix_calc_spec')
for name, value in kwargs.items():
Expand Down Expand Up @@ -179,7 +206,7 @@ def network_calculator(self, type, **kwargs):
spec[name] = value
NAMESPACE = "inro.emme.network_calculation.network_calculator"
network_calc = self.m.tool(NAMESPACE)
self.link_calc_result = network_calc(spec)
self.network_calc_result = network_calc(spec)

def process_function_file(self, file_name):
NAMESPACE=("inro.emme.data.function.function_transaction" )
Expand All @@ -203,6 +230,32 @@ def matrix_balancing(self, **kwargs):
compute_matrix = self.m.tool(NAMESPACE)
report = compute_matrix(spec)

def import_matrices(self, matrix_name):
NAMESPACE = "inro.emme.data.matrix.matrix_transaction"
process = self.m.tool(NAMESPACE)
process(transaction_file = matrix_name,
throw_on_error = False,
scenario = self.current_scenario)

def transit_line_calculator(self, **kwargs):
spec = json_to_dictionary("transit_line_calculation")
for name, value in kwargs.items():
spec[name] = value

NAMESPACE = "inro.emme.network_calculation.network_calculator"
network_calc = self.m.tool(NAMESPACE)
self.transit_line_calc_result = network_calc(spec)

def transit_segment_calculator(self, **kwargs):
spec = json_to_dictionary("transit_segment_calculation")
for name, value in kwargs.items():
spec[name] = value

NAMESPACE = "inro.emme.network_calculation.network_calculator"
network_calc = self.m.tool(NAMESPACE)
self.transit_segment_calc_result = network_calc(spec)


def json_to_dictionary(dict_name):

#Determine the Path to the input files and load them
Expand Down
231 changes: 226 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,229 @@
soundcat
========
#SoundCast: PSRC's Travel Skims to Activity Based Model#

It's like soundcast, but less ess
##Background##
This code is intended to control the exchange of data between the PSRC's network model in Inro's Emme 4.0 software to our new Activity Based Model (ABM) system that is being developed in the DaySim software. DaySim requires several measures of accessibility from our network model in the form of matrices of travel times, costs, and distances. This Python code is intended to:

soundcat is the repository for the code before it has been fully vetted by the team into an official version.
+ Import estimates of personal travel by vehicle class and time of day from DaySim
+ Estimate Truck Trips by time of day for:
- Light Trucks
- Medium Trucks
- Heavy Trucks
+ Estimate any special generators of travel not captured in DaySim for items like
- External Stations
- Sport's Stadiums
- Airports
- Convention Centers
+ Run Highway, Transit and Non-Motorized Assignments for various vehicle classes and times of day
+ Generate matrices of travel information related to Time, Cost and Distance for all od-pairs in our 4000 zone travel model system.

The vehicle skims include 756 matrices (12 time periods x 63 skims). Previous data exchanges between our model systems relied upon transfer via comma-separated formats. We have implemented code that utilizes an HDF5 database as a storage container for all Emme model output. The intent is to use hdf5 during runtime for all model processes as there are a variety of api's in various languages to access the data. For now we are assuming an HDF5 database for each time period but this might change as we move forward with implementation.

##Emme Data Structure##
To effectively utilize multiple cores on a pc for model runs, we need to have a separate Emme databank and corresponding Emme project for every time period that we wish to run in parallel. So in order to run 12 highway assignments concurrently, we need to have 12 distinct project files with only one databank in each.

The current folder structure is:

Root Directory (for example, C:\ABM)
-> Banks
-> Bank1
-> Bank2
-> Bank3
-> Bank4
etc.
-> Projects
-> Project1
-> Project2
-> Project3
-> Project4
etc.

During code testing, we are relying on hardcoding all paths to the project files in the code. Once testing of the code is complete, we plan to implement a refined approach to selecting the projects either through the use of a control file or possibly a tkinter based dialog selection using tkFileDialog.

##Input Files##
As of now, there are a variety of input files that exist in various ascii formats. These files currently reside in the "Inputs" folder under each bank. The inputs inlcude:

1. user_classes.txt (dictionary)
This file contains relevant data about the vehicle classes used in the skimming process. It is used to create all relevant matrices, link attributes and assignment and skim parameters used in the course of the run.
2. vdfs.txt (input)
This file contains the specification of the volume delay functions need for assignments in Emme
3. tolls.txt (input)
This file contains the specification of the link level tolls for the network
4. link_calculation.txt (Emme Tool Specification)
This file contains the specification for the link calculator tool from Emme Modeller
5. node_calculation.txt (Emme Tool Specification)
This file contains the specification for the node calculator tool from Emme Modeller
6. general_attribute_based_skim.txt (Emme Tool Specification)
This file contains the specification for Path Based Skimming of a network attribute from Emme Modeller
7. general_generalized_cost_skim.txt (Emme Tool Specification)
This file contains the specification for Path Based Skimming of an od object from Emme Modeller
8. general_path_based_assignment.txt (Emme Tool Specification)
This file contains the specification for Path Based Assignments from Emme Modeller
9. general_path_based_volume.txt (Emme Tool Specification)
This file contains the specification for Path Based Class Specific volumes from Emme Modeller

We are working on a solution to generalize the creation of as many of these inputs as possible. The vdfs and tolls file could reside in our hdf5 datastore. The Emme specifications might be auto-generated based on the inputs in the user_class dictionary. For now, these specification files work for networks with 21 user classes.

##Time Periods##
DaySim calculates travel for all hours of the day. In order to provide meaningful accessibility data to DaySim and still maintain reasonable model run times, the PSRC network model will be various time periods per day for various modal purposes. The difference by mode reflects the availability of network related data b ymode and time of day.

###Time Periods for Highway Assignments###
The time periods for Highway Assignments are are defined as:

1. Early AM 5:00 am - 6:00 am
2. AM Peak Hour 1 6:00 am - 7:00 am
3. AM Peak Hour 2 7:00 am - 8:00 am
4. AM Peak Hour 3 8:00 am - 9:00 am
5. AM Peak Hour 4 9:00 am - 10:00 am
6. Midday 10:00 am - 2:00 pm
7. PM Peak Hour 1 2:00 pm - 3:00 pm
8. PM Peak Hour 2 3:00 pm - 4:00 pm
9. PM Peak Hour 3 4:00 pm - 5:00 pm
10. PM Peak Hour 4 5:00 pm - 6:00 pm
11. Evening 6:00 pm � 8:00 pm
12. Overnight 8:00 pm - 5:00 am

###Time Periods for Transit Assignments###
The time periods for Transit Assignments are are defined as:

1. AM 6:00 am - 9:00 am
2. Midday 9:00 am - 3:00 pm
3. PM 3:00 pm - 6:00 pm
4. Evening 6:00 pm - 8:00 pm
5. Night 8:00 pm - 6:00 am

###Vehicle Classification for Highway Assignments###
Assignment Specifications are currently set to work for a 21 class assignments as needed by DaySim. The 21 classes are:

1. SOV Toll Income Level 1
2. SOV Toll Income Level 2
3. SOV Toll Income Level 3
4. SOV No Toll Income Level 1
5. SOV No Toll Income Level 2
6. SOV No Toll Income Level 3
7. HOV 2 Toll Income Level 1
8. HOV 2 Toll Income Level 2
9. HOV 2 Toll Income Level 3
10. HOV 2 No Toll Income Level 1
11. HOV 2 No Toll Income Level 2
12. HOV 2 No Toll Income Level 3
13. HOV 3 Toll Income Level 1
14. HOV 3 Toll Income Level 2
15. HOV 3 Toll Income Level 3
16. HOV 3 No Toll Income Level 1
17. HOV 3 No Toll Income Level 2
18. HOV 3 No Toll Income Level 3
19. Light Trucks
20. Medium Trucks
21. Heavy Trucks

###Value of Time###
The values of time are currently being refined. Originally, the value of time categories used the assignment are coming from DaySim and are:

Class $ per Hour
Cat #1 Cat #2 Cat #3
SOV $2.00 $8.00 $20.00
HOV 2 $4.00 $16.00 $40.00
HOV 3+ $6.00 $24.00 $60.00
Trucks $40.00 $45.00 $50.00

Class minutes per cent
Cat #1 Cat #2 Cat #3
SOV 0.3000 0.0750 0.0300
HOV 2 0.1500 0.0375 0.0150
HOV 3+ 0.1000 0.0250 0.0100
Trucks 0.0150 0.0133 0.0120


###Matrix Definition###
The code uses the Emme Tool for creating matrices to create the 84 total demand and skim matrices needed for the model run. The code overwrites any existing matrices as DaySim will be feeding new demand each time it access Emme for skimming and the skims should change due to the new demand. There are 21 demand trip tables and 63 total skim tables being created for auto modes (time, cost and distance).

Naming convention is: class (2 characters), toll/notoll(2 characters), income (1 number), type (1 character)

1. svtl1v - SOV Toll Income Level 1 Demand
2. svtl2v - SOV Toll Income Level 1 Demand
3. svtl3v - SOV Toll Income Level 1 Demand
4. svnt1v - SOV No Toll Income Level 1 Demand
5. svnt2v - SOV No Toll Income Level 1 Demand
6. svnt3v - SOV No Toll Income Level 1 Demand
7. h2tl1v - HOV 2 Toll Income Level 1 Demand
8. h2tl2v - HOV 2 Toll Income Level 1 Demand
9. h2tl3v - HOV 2 Toll Income Level 1 Demand
10. h2nt1v - HOV 2 No Toll Income Level 1 Demand
11. h2nt2v - HOV 2 No Toll Income Level 1 Demand
12. h2nt3v - HOV 2 No Toll Income Level 1 Demand
13. h3tl1v - HOV 3+ Toll Income Level 1 Demand
14. h3tl2v - HOV 3+ Toll Income Level 1 Demand
15. h3tl3v - HOV 3+ Toll Income Level 1 Demand
16. h3nt1v - HOV 3+ No Toll Income Level 1 Demand
17. h3nt2v - HOV 3+ No Toll Income Level 1 Demand
18. h3nt3v - HOV 3+ No Toll Income
19. lttrkv - Light Truck Demand
20. mdtrkv - Medium Truck Demand
21. hvtrkv - Heavy Truck Demand
22. svtl1t - SOV Toll Income Level 1 Time
23. svtl2t - SOV Toll Income Level 1 Time
24. svtl3t - SOV Toll Income Level 1 Time
25. svnt1t - SOV No Toll Income Level 1 Time
26. svnt2t - SOV No Toll Income Level 1 Time
27. svnt3t - SOV No Toll Income Level 1 Time
28. h2tl1t - HOV 2 Toll Income Level 1 Time
29. h2tl2t - HOV 2 Toll Income Level 1 Time
30. h2tl3t - HOV 2 Toll Income Level 1 Time
31. h2nt1t - HOV 2 No Toll Income Level 1 Time
32. h2nt2t - HOV 2 No Toll Income Level 1 Time
33. h2nt3t - HOV 2 No Toll Income Level 1 Time
34. h3tl1t - HOV 3+ Toll Income Level 1 Time
35. h3tl2t - HOV 3+ Toll Income Level 1 Time
36. h3tl3t - HOV 3+ Toll Income Level 1 Time
37. h3nt1t - HOV 3+ No Toll Income Level 1 Time
38. h3nt2t - HOV 3+ No Toll Income Level 1 Time
39. h3nt3t - HOV 3+ No Toll Income
40. lttrkt - Light Truck Time
41. mdtrkt - Medium Truck Time
42. hvtrkt - Heavy Truck Time
43. svtl1c - SOV Toll Income Level 1 Cost
44. svtl2c - SOV Toll Income Level 1 Cost
45. svtl3c - SOV Toll Income Level 1 Cost
46. svnt1c - SOV No Toll Income Level 1 Cost
47. svnt2c - SOV No Toll Income Level 1 Cost
48. svnt3c - SOV No Toll Income Level 1 Cost
49. h2cl1c - HOV 2 Toll Income Level 1 Cost
50. h2cl2c - HOV 2 Toll Income Level 1 Cost
51. h2cl3c - HOV 2 Toll Income Level 1 Cost
52. h2nt1c - HOV 2 No Toll Income Level 1 Cost
53. h2nt2c - HOV 2 No Toll Income Level 1 Cost
54. h2nt3c - HOV 2 No Toll Income Level 1 Cost
55. h3cl1c - HOV 3+ Toll Income Level 1 Cost
56. h3cl2c - HOV 3+ Toll Income Level 1 Cost
57. h3cl3c - HOV 3+ Toll Income Level 1 Cost
58. h3nt1c - HOV 3+ No Toll Income Level 1 Cost
59. h3nt2c - HOV 3+ No Toll Income Level 1 Cost
60. h3nt3c - HOV 3+ No Toll Income
61. lttrkc - Light Truck Cost
62. mdtrkc - Medium Truck Cost
63. hvtrkc - Heavy Truck Cost
64. svtl1d - SOV Toll Income Level 1 Distance
65. svtl2d - SOV Toll Income Level 1 Distance
66. svtl3d - SOV Toll Income Level 1 Distance
67. svnt1d - SOV No Toll Income Level 1 Distance
68. svnt2d - SOV No Toll Income Level 1 Distance
69. svnt3d - SOV No Toll Income Level 1 Distance
70. h2dl1d - HOV 2 Toll Income Level 1 Distance
71. h2dl2d - HOV 2 Toll Income Level 1 Distance
72. h2dl3d - HOV 2 Toll Income Level 1 Distance
73. h2nt1d - HOV 2 No Toll Income Level 1 Distance
74. h2nt2d - HOV 2 No Toll Income Level 1 Distance
75. h2nt3d - HOV 2 No Toll Income Level 1 Distance
76. h3dl1d - HOV 3+ Toll Income Level 1 Distance
77. h3dl2d - HOV 3+ Toll Income Level 1 Distance
78. h3dl3d - HOV 3+ Toll Income Level 1 Distance
79. h3nt1d - HOV 3+ No Toll Income Level 1 Distance
80. h3nt2d - HOV 3+ No Toll Income Level 1 Distance
81. h3nt3d - HOV 3+ No Toll Income
82. lttrkd - Light Truck Distance
83. mdtrkd - Medium Truck Distance
84. hvtrkd - Heavy Truck Distance

###Vehicle Matrix Calculations###
The code creates three sets of skims for use by DaySim - travel time, generalized cost and distance. All three skim procedures utilize the standard path based assignment analysis toolkits from Emme Modeller. The travel time skims are created by skimming auto time (timau) across all paths, distance skims are based on link length and the generalized cost skims use the conversion of toll costs to time via values of time as noted above.

When it's done, we put it in SoundCast
10 changes: 5 additions & 5 deletions configuration_template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ IxxiFirstLineIsHeader = false

# zone list, district lookup
ImportZones = true
RawZonePath = TAZIndex_5_28_14.txt
RawZonePath = TAZIndex.txt
RawZoneDelimiter = 9

# park and ride nodes
ImportParkAndRideNodes = true
RawParkAndRideNodePath = p_rNodes_040814.csv
RawParkAndRideNodePath = p_r_nodes.csv
RawParkAndRideNodeDelimiter = 44

# daysim output text files
Expand Down Expand Up @@ -259,9 +259,9 @@ PathImpedance_TransitFerryPathConstant = 0.0
PathImpedance_TransitUsePathTypeSpecificTime = true

PathImpedance_TransitPremiumBusTimeAdditiveWeight = 0.00
PathImpedance_TransitLightRailTimeAdditiveWeight = -0.10
PathImpedance_TransitCommuterRailTimeAdditiveWeight = -0.35
PathImpedance_TransitFerryTimeAdditiveWeight = -0.60
PathImpedance_TransitLightRailTimeAdditiveWeight = -0.10
PathImpedance_TransitCommuterRailTimeAdditiveWeight = -0.50
PathImpedance_TransitFerryTimeAdditiveWeight = -0.50
PathImpedance_BikeUseTypeSpecificDistanceFractions = false
PathImpedance_BikeType1DistanceFractionAdditiveWeight = 0.0
PathImpedance_BikeType2DistanceFractionAdditiveWeight = 0.0
Expand Down
Loading

0 comments on commit fc1a737

Please sign in to comment.