API Documentation ¶
Controller ¶
RunController - model operation controller.
Main interface to start a TM2PY model run. Provide one or more configuration files in .toml format (by convention a scenario.toml and a model.toml)
Typical usage example: from tm2py.controller import RunController controller = RunController( [“scenario.toml”, “model.toml”]) controller.run()
Or from the command-line:
python <path>/tm2py/tm2py/controller.py –s scenario.toml –m model.toml
RunController
¶
Main operational interface for model runs.
Provide one or more config files in TOML (*.toml) format, and a run directory. If the run directory is not provided the root directory of the first config_file is used.
Properties
Internal properties
Source code in tm2py\controller.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
component_name
property
¶
Name of current component of model run.
congested_transit_assn_max_iteration
property
¶
Return mapping of time periods to max iteration in congested transit assignment.
emme_manager
property
¶
Cached Emme Manager object.
iter_component
property
¶
Tuple of the current iteration and component name.
iteration
property
¶
Current iteration of model run.
run_dir
property
¶
The root run directory of the model run.
run_iterations
property
¶
List of iterations for this model run.
time_period_durations
property
¶
Return mapping of time periods to durations in hours.
time_period_names
property
¶
Return input time_period name or names and return list of time_period names.
Implemented here for easy access for all components.
Returns: list of uppercased string names of time periods
__init__(config_file=None, run_dir=None, run_components=component_cls_map.keys())
¶
Constructor for RunController class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_file
|
Union[Collection[Union[str, Path]], str, Path]
|
Single or list of config file locations as strings or Path objects. Defaults to None. |
None
|
run_dir
|
Union[Path, str]
|
Model run directory as a Path object or string. If not provided, defaults to the directory of the first config_file. |
None
|
run_components
|
Collection[str]
|
List of component names to run. Defaults to all components. |
keys()
|
Source code in tm2py\controller.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
__repr__()
¶
Legible representation.
Source code in tm2py\controller.py
138 139 140 141 142 143 144 145 146 |
|
component()
¶
Current component of model.
Source code in tm2py\controller.py
202 203 204 |
|
get_abs_path(rel_path)
¶
Get the absolute path from the root run directory given a relative path.
Source code in tm2py\controller.py
221 222 223 224 225 |
|
run()
¶
Main interface to run model.
Iterates through the self._queued_components and runs them.
Source code in tm2py\controller.py
227 228 229 230 231 232 233 234 |
|
run_next()
¶
Run next component in the queue.
Source code in tm2py\controller.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
Configuration ¶
Config implementation and schema.
ActiveModeShortestPathSkimConfig
¶
Bases: ConfigItem
Active mode skim entry.
Source code in tm2py\config.py
658 659 660 661 662 663 664 665 666 |
|
ActiveModesConfig
¶
Bases: ConfigItem
Active Mode skim parameters.
Source code in tm2py\config.py
669 670 671 672 673 674 |
|
AirPassengerConfig
¶
Bases: ConfigItem
Air passenger model parameters.
Properties
highway_demand_file: output OMX file input_demand_folder: location to find the input demand csvs input_demand_filename_tmpl: filename template for input demand. Should have {year}, {direction} and {airport} variables and end in ‘.csv’ reference_start_year: base start year for input demand tables used to calculate the linear interpolation, as well as in the file name template {year}{direction}{airport}.csv reference_end_year: end year for input demand tables used to calculate the linear interpolation, as well as in the file name template {year}{direction}{airport}.csv airport_names: list of one or more airport names / codes as used in the input file names demand_aggregation: specification of aggregation of by-access mode demand to highway class demand
Source code in tm2py\config.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
|
valid_input_demand_filename_tmpl(value)
¶
Validate skim matrix template has correct {}.
Source code in tm2py\config.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
|
AirPassengerDemandAggregationConfig
¶
Bases: ConfigItem
Air passenger demand aggregation input parameters.
Properties
Source code in tm2py\config.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
AssignmentStoppingCriteriaConfig
¶
Bases: ConfigItem
Assignment stop configuration parameters.
Source code in tm2py\config.py
1254 1255 1256 1257 1258 1259 |
|
CcrWeightsConfig
¶
Bases: ConfigItem
Weights for CCR Configuration.
Source code in tm2py\config.py
1262 1263 1264 1265 1266 1267 1268 1269 1270 |
|
ChoiceClassConfig
¶
Bases: ConfigItem
Choice class parameters.
Properties
The end value in the utility equation for class c and property p is:
utility[p].coeff * classes[c].property_factor[p] * sum(skim(classes[c].skim_mode,skim_p) for skim_p in property_to_skim[p])
Source code in tm2py\config.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
|
ClassDemandConfig
¶
Bases: ConfigItem
Input source for demand for highway or transit assignment class.
Used to specify where to find related demand file for this highway or transit class.
Properties
Source code in tm2py\config.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
|
CoefficientConfig
¶
Bases: ConfigItem
Coefficient and properties to be used in utility or regression.
Source code in tm2py\config.py
441 442 443 444 445 446 |
|
ConfigItem
¶
Bases: ABC
Base class to add partial dict-like interface to tm2py model configuration.
Allow use of .items() [“X”] and .get(“X”) .to_dict() from configuration.
Not to be constructed directly. To be used a mixin for dataclasses representing config schema. Do not use “get” “to_dict”, or “items” for key names.
Source code in tm2py\config.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
__getitem__(key)
¶
Get item for config. D[key] -> D[key] if key in D, else raise KeyError.
Source code in tm2py\config.py
26 27 28 |
|
get(key, default=None)
¶
Return the value for key if key is in the dictionary, else default.
Source code in tm2py\config.py
34 35 36 |
|
items()
¶
The sub-config objects in config.
Source code in tm2py\config.py
30 31 32 |
|
Configuration
¶
Bases: ConfigItem
Source code in tm2py\config.py
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 |
|
load_toml(toml_path)
classmethod
¶
Load configuration from .toml files(s).
Normally the config is split into a scenario_config.toml file and a model_config.toml file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
toml_path
|
Union[List[Union[str, Path]], str, Path]
|
a valid system path string or Path object to a TOML format config file or list of paths of path objects to a set of TOML files. |
required |
Returns:
Type | Description |
---|---|
Configuration
|
A Configuration object |
Source code in tm2py\config.py
1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 |
|
maz_skim_period_exists(value, values)
¶
Validate highway.maz_to_maz.skim_period refers to a valid period.
Source code in tm2py\config.py
1469 1470 1471 1472 1473 1474 1475 1476 1477 |
|
relative_gap_length(value, values)
¶
Validate highway.relative_gaps is a list of length greater or equal to global iterations.
Source code in tm2py\config.py
1479 1480 1481 1482 1483 1484 1485 1486 1487 |
|
transit_stop_criteria_length(value, values)
¶
Validate transit.congested.stop_criteria is a list of length greater or equal to global iterations.
Source code in tm2py\config.py
1489 1490 1491 1492 1493 1494 1495 1496 1497 |
|
CongestedAssnConfig
¶
Bases: ConfigItem
Congested transit assignment Configuration.
Source code in tm2py\config.py
1328 1329 1330 1331 1332 1333 1334 1335 1336 |
|
CongestedTransitMaxIteration
¶
Bases: ConfigItem
Congested transit assignment time period specific max iteration parameters.
Properties
Source code in tm2py\config.py
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 |
|
CongestedTransitStopCriteria
¶
Bases: ConfigItem
Congested transit assignment stopping criteria parameters.
Properties
Source code in tm2py\config.py
1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 |
|
CongestedWeightsConfig
¶
Bases: ConfigItem
Weights for Congested Transit Assignment Configuration.
Source code in tm2py\config.py
1273 1274 1275 1276 1277 1278 1279 1280 1281 |
|
DemandCountyGroupConfig
¶
Bases: ConfigItem
Grouping of counties for assignment and demand files.
Properties
Source code in tm2py\config.py
867 868 869 870 871 872 873 874 875 876 877 |
|
EawtWeightsConfig
¶
Bases: ConfigItem
Weights for calculating extra added wait time Configuration.
Source code in tm2py\config.py
1284 1285 1286 1287 1288 1289 1290 1291 |
|
EmmeConfig
¶
Bases: ConfigItem
Emme-specific parameters.
Properties
Source code in tm2py\config.py
1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 |
|
HighwayCapClassConfig
¶
Bases: ConfigItem
Highway link capacity and speed (‘capclass’) index entry.
Properties
Source code in tm2py\config.py
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
|
HighwayClassConfig
¶
Bases: ConfigItem
Highway assignment class definition.
Note that excluded_links, skims and toll attribute names include vehicle groups (“{vehicle}”) which reference the list of highway.toll.dst_vehicle_group_names (see HighwayTollsConfig). The default example model config uses: “da”, “sr2”, “sr3”, “vsm”, sml”, “med”, “lrg”
Example single class config
name = “da” description= “drive alone” mode_code= “d” [[highway.classes.demand]] source = “household” name = “SOV_GP_{period}” [[highway.classes.demand]] source = “air_passenger” name = “da” [[highway.classes.demand]] source = “internal_external” name = “da” excluded_links = [“is_toll_da”, “is_sr2”], value_of_time = 18.93, # $ / hr operating_cost_per_mile = 17.23, # cents / mile toll = [“@bridgetoll_da”] skims = [“time”, “dist”, “freeflowtime”, “bridgetoll_da”],
Properties
Source code in tm2py\config.py
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 |
|
HighwayConfig
¶
Bases: ConfigItem
Highway assignment and skims parameters.
Properties
Source code in tm2py\config.py
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
|
unique_capclass_numbers(value)
¶
Validate list of capclass_lookup has unique .capclass values.
Source code in tm2py\config.py
1003 1004 1005 1006 1007 1008 1009 |
|
unique_class_names(value)
¶
Validate list of classes has unique .name values.
Source code in tm2py\config.py
1011 1012 1013 1014 1015 1016 1017 |
|
valid_skim_matrix_name_template(value)
¶
Validate skim matrix template has correct {}.
Source code in tm2py\config.py
989 990 991 992 993 994 995 996 997 998 999 1000 1001 |
|
valid_skim_template(value)
¶
Validate skim template has correct {} and extension.
Source code in tm2py\config.py
978 979 980 981 982 983 984 985 986 987 |
|
validate_class_keyword_lists(value, values)
¶
Validate classes .skims, .toll, and .excluded_links values.
Source code in tm2py\config.py
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
|
validate_class_mode_excluded_links(value, values)
¶
Validate list of classes has unique .mode_code or .excluded_links match.
Source code in tm2py\config.py
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 |
|
HighwayMazToMazConfig
¶
Bases: ConfigItem
Highway MAZ to MAZ shortest path assignment and skim parameters.
Properties
Source code in tm2py\config.py
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
|
unique_group_numbers(value)
¶
Validate list of demand_county_groups has unique .number values.
Source code in tm2py\config.py
918 919 920 921 922 923 |
|
HighwayRelativeGapConfig
¶
Bases: ConfigItem
Highway assignment relative gap parameters.
Properties
Source code in tm2py\config.py
718 719 720 721 722 723 724 725 726 727 728 |
|
HighwayTollsConfig
¶
Bases: ConfigItem
Highway assignment and skim input tolls and related parameters.
Properties
Source code in tm2py\config.py
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 |
|
dst_vehicle_group_names_length(value, values)
¶
Validate dst_vehicle_group_names has same length as src_vehicle_group_names.
Source code in tm2py\config.py
841 842 843 844 845 846 847 848 849 850 851 |
|
HouseholdConfig
¶
Bases: ConfigItem
Household (residents) model parameters.
Source code in tm2py\config.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
HouseholdModeAgg
¶
Bases: ConfigItem
household trip mode aggregation input parameters.
Properties
Source code in tm2py\config.py
304 305 306 307 308 309 310 311 312 313 314 315 |
|
ImpedanceConfig
¶
Bases: ConfigItem
Blended skims used for accessibility/friction calculations.
Properties:I name: name to store it as, referred to in TripDistribution config skim_mode: name of the mode to use for the blended skim time_blend: blend of time periods to use; mapped to the factors (which should sum to 1)
Source code in tm2py\config.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
|
sums_to_one(value)
¶
Validate highway.maz_to_maz.skim_period refers to a valid period.
Source code in tm2py\config.py
595 596 597 598 599 |
|
InternalExternalConfig
¶
Bases: ConfigItem
Internal <-> External model parameters.
Source code in tm2py\config.py
514 515 516 517 518 519 520 521 522 523 524 |
|
LoggingConfig
¶
Bases: ConfigItem
Logging parameters. TODO.
Properties
Source code in tm2py\config.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
ManualJourneyLevelsConfig
¶
Bases: ConfigItem
Manual Journey Level Specification
Source code in tm2py\config.py
1185 1186 1187 1188 1189 1190 |
|
MatrixFactorConfig
¶
Bases: ConfigItem
Mapping of zone or list of zones to factor value.
Source code in tm2py\config.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
|
valid_zone_index(value)
¶
Validate zone index and turn to list if isn’t one.
Source code in tm2py\config.py
417 418 419 420 421 422 423 424 425 |
|
RunConfig
¶
Bases: ConfigItem
Model run parameters.
Note that the components will be executed in the order listed.
Properties
Source code in tm2py\config.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
end_iteration_gt_start(value, values)
¶
Validate end_iteration greater than start_iteration.
Source code in tm2py\config.py
146 147 148 149 150 151 152 153 154 |
|
start_component_used(value, values)
¶
Validate start_component is listed in *_components.
Source code in tm2py\config.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
ScenarioConfig
¶
Bases: ConfigItem
Scenario related parameters.
Properties
Source code in tm2py\config.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
TimeOfDayClassConfig
¶
Bases: ConfigItem
Configuration for a class of time of day model.
Source code in tm2py\config.py
289 290 291 292 293 294 |
|
TimeOfDayConfig
¶
Bases: ConfigItem
Configuration for time of day model.
Source code in tm2py\config.py
297 298 299 300 301 |
|
TimePeriodConfig
¶
Bases: ConfigItem
Time time period entry.
Properties
Source code in tm2py\config.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
TimeSplitConfig
¶
Bases: ConfigItem
Split matrix i and j.
i.e. for time of day splits.
Source code in tm2py\config.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
|
TollChoiceConfig
¶
Bases: ConfigItem
Toll choice parameters.
Properties
Source code in tm2py\config.py
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
|
TransitClassConfig
¶
Bases: ConfigItem
Transit demand class definition.
Source code in tm2py\config.py
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 |
|
TransitConfig
¶
Bases: ConfigItem
Transit assignment parameters.
Source code in tm2py\config.py
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 |
|
deprecate_capacitated_assignment(value, values)
¶
Validate use_ccr is false.
Source code in tm2py\config.py
1389 1390 1391 1392 1393 1394 1395 |
|
TransitJourneyLevelsConfig
¶
Bases: ConfigItem
Transit manual journey levels structure.
Source code in tm2py\config.py
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 |
|
manual = (ManualJourneyLevelsConfig(level_id=1, group_fare_systems=(25,)),)
class-attribute
instance-attribute
¶
If ‘specify_manually’ is set to True
, there should be at least one faresystem group specified here.
The format includes two entries: level_id
, which is the serial number of the group specified,
and group_fare_system
, which is a list of all faresystems belonging to that group.
For example, to specify MUNI as one faresystem group, the right configuration would be:
[[transit.journey_levels.manual]]
level_id = 1
group_fare_systems = [25]
If there are multiple groups required to be specified, for example, MUNI in one and Caltrain in the other group,
it can be achieved by adding another entry of manual
, like:
[[transit.journey_levels.manual]]
level_id = 1
group_fare_systems = [25][[transit.journey_levels.manual]]
level_id = 2
group_fare_systems = [12,14]
specify_manually = True
class-attribute
instance-attribute
¶
An alternative to using an algorithm to specify the journey levels is to use specify them manually.
If this option is set to True
, the manual
parameter can be used to assign fare systems to faresystem groups (or journey levels).
Consider, for example, the following three journey levels: 0 - has yet to board transit; 1 - has boarded SF Muni; 2 - has boarded all other transit systems.
To specify this configuration, a single manual
entry identifying the SF Muni fare systems is needed.
The other faresystem group is automatically generated in the code with the rest of the faresystems which are not specified in any of the groups.
See the manual
entry for an example.
use_algorithm = False
class-attribute
instance-attribute
¶
The original translation from Cube to Emme used an algorithm to, as faithfully as possible, reflect transfer fares via journey levels.
The algorithm examines fare costs and proximity of transit services to create a set of journey levels that reflects transfer costs.
While this algorithm works well, the Bay Area’s complex fare system results in numerous journey levels specific to operators with low ridership.
The resulting assignment compute therefore expends a lot of resources on these operators.
Set this parameter to True
to use the algorithm. Exactly one of use_algorithm
or specify_manually
must be True
.
check_exclusivity(v, values)
¶
Valdiates that exactly one of specify_manually and use_algorithm is True
Source code in tm2py\config.py
1236 1237 1238 1239 1240 1241 1242 1243 |
|
TransitModeConfig
¶
Bases: ConfigItem
Transit mode definition (see also mode in the Emme API).
Source code in tm2py\config.py
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
|
headway_fraction_valid(value, values)
¶
Validate headway_fraction exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1139 1140 1141 1142 1143 1144 |
|
in_vehicle_perception_factor_valid(value, values)
¶
Validate in_vehicle_perception_factor exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1111 1112 1113 1114 1115 1116 |
|
initial_boarding_penalty_valid(value, values)
¶
Validate initial_boarding_penalty exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1125 1126 1127 1128 1129 1130 |
|
mode_id_valid(value)
classmethod
¶
Validate mode_id.
Source code in tm2py\config.py
1153 1154 1155 1156 1157 1158 |
|
speed_or_time_factor_valid(value, values)
¶
Validate speed_or_time_factor exists if assign_type is AUX_TRANSIT.
Source code in tm2py\config.py
1118 1119 1120 1121 1122 1123 |
|
transfer_boarding_penalty_valid(value, values)
¶
Validate transfer_boarding_penalty exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1132 1133 1134 1135 1136 1137 |
|
transfer_wait_perception_factor_valid(value, values)
¶
Validate transfer_wait_perception_factor exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1146 1147 1148 1149 1150 1151 |
|
TransitVehicleConfig
¶
Bases: ConfigItem
Transit vehicle definition (see also transit vehicle in the Emme API).
Source code in tm2py\config.py
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 |
|
TripDistributionClassConfig
¶
Bases: ConfigItem
Trip Distribution parameters.
Properties
Source code in tm2py\config.py
558 559 560 561 562 563 564 565 566 567 568 569 570 |
|
TripDistributionConfig
¶
Bases: ConfigItem
Trip Distribution parameters.
Source code in tm2py\config.py
602 603 604 605 606 607 608 609 610 |
|
TripGenerationClassConfig
¶
Bases: ConfigItem
Trip Generation parameters.
Source code in tm2py\config.py
540 541 542 543 544 545 546 547 548 |
|
TripGenerationConfig
¶
Bases: ConfigItem
Trip Generation parameters.
Source code in tm2py\config.py
551 552 553 554 555 |
|
TripGenerationFormulaConfig
¶
Bases: ConfigItem
TripProductionConfig.
Trip productions or attractions for a zone are the constant plus the sum of the rates * values in land use file for that zone.
Source code in tm2py\config.py
527 528 529 530 531 532 533 534 535 536 537 |
|
TruckClassConfig
¶
Bases: ConfigItem
Truck class parameters.
Source code in tm2py\config.py
573 574 575 576 577 578 |
|
TruckConfig
¶
Bases: ConfigItem
Truck model parameters.
Source code in tm2py\config.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
|
highway_demand_file
instance-attribute
¶
@validator(“classes”) def class_consistency(cls, v, values): # TODO Can’t get to work righ tnow _class_names = [c.name for c in v] _gen_classes = [c.name for c in values[“trip_gen”]] _dist_classes = [c.name for c in values[“trip_dist”]] _time_classes = [c.name for c in values[“time_split”]] _toll_classes = [c.name for c in values[“toll_choice”]]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
WarmStartConfig
¶
Bases: ConfigItem
Warm start parameters.
Note that the components will be executed in the order listed.
Properties
Source code in tm2py\config.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
check_warmstart_method(value, values)
¶
When warmstart, either skim or demand should be true.
Source code in tm2py\config.py
112 113 114 115 116 117 118 119 |
|
Configurations for each component are listed with those components
Components ¶
Base Component ¶
Root component ABC.
Component
¶
Bases: ABC
Template for Component class with several built-in methods.
A component is a piece of the model that can be run independently (of other components) given the required input data and configuration. It communicates information to other components via disk I/O (including the emmebank).
Note: if the component needs data that is not written to disk, it would be considered a subcomponent.
Abstract Methods – Each component class must have the following methods: __init___: constructor, which associates the RunController with the instantiated object run: run the component without any arguments validate_inputs: validate the inputs to the component report_progress: report progress to the user verify: verify the component’s output write_top_sheet: write outputs to topsheet test_component: test the component
Template Class methods - component classes inherit
Template Class Properties - component classes inherit
:: class MyComponent(Component):
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Source code in tm2py\components\component.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
congested_transit_assn_max_iteration
property
¶
Return mapping of time periods to max iteration in congested transit assignment.
controller
property
¶
Parent controller.
logger
property
¶
Reference to logger.
time_period_durations
property
¶
Return mapping of time periods to durations in hours.
time_period_names
property
¶
Return input time_period name or names and return list of time_period names.
Implemented here for easy access for all components.
Returns: list of uppercased string names of time periods
top_sheet
property
¶
Reference to top sheet.
trace
property
¶
Reference to trace.
__init__(controller)
¶
Model component template/abstract base class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Reference to the run controller object. |
required |
Source code in tm2py\components\component.py
79 80 81 82 83 84 85 86 |
|
get_abs_path(path)
¶
Convenince method to get absolute path from run directory.
Source code in tm2py\components\component.py
97 98 99 100 101 102 |
|
report_progress()
¶
Write progress to log file.
Source code in tm2py\components\component.py
148 149 |
|
run()
abstractmethod
¶
Run model component.
Source code in tm2py\components\component.py
143 144 145 |
|
validate_inputs()
abstractmethod
¶
Validate inputs are correct at model initiation, raise on error.
Source code in tm2py\components\component.py
139 140 141 |
|
verify()
¶
Verify component outputs / results.
Source code in tm2py\components\component.py
152 153 |
|
write_top_sheet()
¶
Write key outputs to the model top sheet.
Source code in tm2py\components\component.py
156 157 |
|
FileFormatError
¶
Bases: Exception
Exception raised when a file is not in the expected format.
Source code in tm2py\components\component.py
16 17 18 19 20 21 22 23 24 25 26 |
|
__init__(f, *args)
¶
Exception for invalid file formats.
Source code in tm2py\components\component.py
19 20 21 22 |
|
__str__()
¶
String representation for FileFormatError.
Source code in tm2py\components\component.py
24 25 26 |
|
Subcomponent
¶
Bases: Component
Template for sub-component class.
A sub-component is a more loosly defined component that allows for input into the run() method. It is used to break-up larger processes into smaller chunks which can be: (1) re-used across components (i.e toll choice) (2) updated/subbed in to a parent component(s) run method based on the expected API (3) easier to test, understand and debug. (4) more consistent with the algorithms we understand from transportation planning 101
Source code in tm2py\components\component.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
__init__(controller, component)
¶
Constructor for model sub-component abstract base class.
Only calls the super class constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Reference to the run controller object. |
required |
component
|
Component
|
Reference to the parent component object. |
required |
Source code in tm2py\components\component.py
171 172 173 174 175 176 177 178 179 180 181 |
|
run(*args, **kwargs)
abstractmethod
¶
Run sub-component, allowing for multiple inputs.
Allowing for inputs to the run() method is what differentiates a sub-component from a component.
Source code in tm2py\components\component.py
183 184 185 186 187 188 189 |
|
Demand Components ¶
Demand loading from OMX to Emme database.
EmmeDemand
¶
Abstract base class to import and average demand.
Source code in tm2py\components\demand\prepare_demand.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
logger
property
¶
Reference to logger.
__init__(controller)
¶
Constructor for PrepareDemand class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Run controller for the current run. |
required |
Source code in tm2py\components\demand\prepare_demand.py
30 31 32 33 34 35 36 37 38 39 |
|
PrepareHighwayDemand
¶
Bases: EmmeDemand
Import and average highway demand.
Demand is imported from OMX files based on reference file paths and OMX matrix names in highway assignment config (highway.classes). The demand is average using MSA with the current demand matrices (in the Emmebank) if the controller.iteration > 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
parent RunController object |
required |
Source code in tm2py\components\demand\prepare_demand.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
|
__init__(controller)
¶
Constructor for PrepareHighwayDemand.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Reference to run controller object. |
required |
Source code in tm2py\components\demand\prepare_demand.py
149 150 151 152 153 154 155 156 157 158 |
|
prepare_household_demand()
¶
Prepares highway and transit household demand matrices from trip lists produced by CT-RAMP.
Source code in tm2py\components\demand\prepare_demand.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
|
run()
¶
Open combined demand OMX files from demand models and prepare for assignment.
Source code in tm2py\components\demand\prepare_demand.py
172 173 174 175 176 177 178 |
|
PrepareTransitDemand
¶
Bases: EmmeDemand
Import transit demand.
Demand is imported from OMX files based on reference file paths and OMX matrix names in transit assignment config (transit.classes). The demand is average using MSA with the current demand matrices (in the Emmebank) if transit.apply_msa_demand is true if the controller.iteration > 1.
Source code in tm2py\components\demand\prepare_demand.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
|
__init__(controller)
¶
Constructor for PrepareTransitDemand.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
'RunController'
|
RunController object. |
required |
Source code in tm2py\components\demand\prepare_demand.py
610 611 612 613 614 615 616 617 618 619 |
|
run()
¶
Open combined demand OMX files from demand models and prepare for assignment.
Source code in tm2py\components\demand\prepare_demand.py
632 633 634 635 636 637 638 639 640 641 642 643 |
|
validate_inputs()
¶
Validate the inputs.
Source code in tm2py\components\demand\prepare_demand.py
621 622 |
|
avg_matrix_msa(prev_avg_matrix, this_iter_matrix, msa_iteration)
¶
Average matrices based on Method of Successive Averages (MSA).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prev_avg_matrix
|
NumpyArray
|
Previously averaged matrix |
required |
this_iter_matrix
|
NumpyArray
|
Matrix for this iteration |
required |
msa_iteration
|
int
|
MSA iteration |
required |
Returns:
Name | Type | Description |
---|---|---|
NumpyArray |
NumpyArray
|
MSA Averaged matrix for this iteration. |
Source code in tm2py\components\demand\prepare_demand.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
Household Demand ¶
Personal travel demand generated by household members.
Placeholder docstring for CT-RAMP related components for household residents’ model.
HouseholdModel
¶
Bases: Component
Run household resident model.
Source code in tm2py\components\demand\household.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
run()
¶
Run the the household resident travel demand model.
Steps
- Starts household manager.
- Starts matrix manager.
- Starts resident travel model (CTRAMP).
- Cleans up CTRAMP java.
Source code in tm2py\components\demand\household.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
validate_inputs()
¶
Validates inputs for component.
Source code in tm2py\components\demand\household.py
16 17 18 |
|
Bases: ConfigItem
Household (residents) model parameters.
Source code in tm2py\config.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
Air Passenger Demand ¶
Module containing the AirPassenger class which builds the airport trip matrices.
AirPassenger
¶
Bases: Component
Builds the airport trip matrices.
input: nonres/{year}_{tofrom}{airport}.csv output: five time-of-day-specific OMX files with matrices DA, SR2, SR3
Notes: These are independent of level-of-service.
Note that the reference names, years, file paths and other key details are controlled via the config, air_passenger section. See the AirPassengerConfig doc for details on specifying these inputs.
The following details are based on the default config values.
Creates air passenger vehicle trip tables for the Bay Area’s three major airports, namely SFO, OAK, and SJC. Geoff Gosling, a consultant, created vehicle trip tables segmented by time of day, travel mode, and access/egress direction (i.e. to the airport or from the airport) for years 2007 and 2035. The tables are based on a 2006 Air Passenger survey, which was conducted at SFO and OAK (but not SJC).
The travel modes are as follows
(a) escort (drive alone, shared ride 2, and shared ride 3+) (b) park (da, sr2, & sr3+) © rental car (da, sr2, & sr3+) (d) taxi ((da, sr2, & sr3+) (e) limo (da, sr2, & sr3+) (f) shared ride van (all assumed to be sr3); (g) hotel shuttle (all assumed to be sr3); and, (h) charter bus (all assumed to be sr3).
The shared ride van, hotel shuttle, and charter bus modes are assumed to have no deadhead travel. The return escort trip is included, as are the deadhead limo and taxi trips.
The scripts reads in csv files adapted from Mr. Gosling’s Excel files, and creates a highway-assignment ready OMX matrix file for each time-of-day interval.
Assumes that no air passengers use HOT lanes (probably not exactly true in certain future year scenarios, but the assumption is made here as a simplification). Simple linear interpolations are used to estimate vehicle demand in years other than 2007 and 2035, including 2015, 2020, 2025, 2030, and 2040.
Transit travel to the airports is not included in these vehicle trip tables.
Input
Year-, access/egress-, and airport-specific database file with 90 columns of data for each TAZ. There are 18 columns for each time-of-day interval as follows: (1) Escort, drive alone (2) Escort, shared ride 2 (3) Escort, shared ride 3+ (4) Park, drive alone (5) Park, shared ride 2 (6) Park, shared ride 3+ (7) Rental car, drive alone (8) Rental car, shared ride 2 (9) Rental car, shared ride 3+ (10) Taxi, drive alone (11) Taxi, shared ride 2 (12) Taxi, shared ride 3+ (13) Limo, drive alone (14) Limo, shared ride 2 (15) Limo, shared ride 3+ (16) Shared ride van, shared ride 3+ (17) Hotel shuttle, shared ride 3+ (18) Charter bus, shared ride 3+
Five time-of-day-specific tables, each containing origin/destination vehicle matrices for the following modes: (1) drive alone (DA) (2) shared ride 2 (SR2) (3) shared ride 3+ (SR3)
Internal properties
_start_year _end_year _mode_groups: _out_names:
Source code in tm2py\components\demand\air_passenger.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
|
__init__(controller)
¶
Build the airport trip matrices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
parent Controller object |
required |
Source code in tm2py\components\demand\air_passenger.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
run()
¶
Run the Air Passenger Demand model to generate the demand matrices.
Steps
- Load the demand data from the CSV files.
- Aggregate the demand data into the assignable classes.
- Create the demand matrices be interpolating the demand data.
- Write the demand matrices to OMX files.
Source code in tm2py\components\demand\air_passenger.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
validate_inputs()
¶
Validate the inputs.
Source code in tm2py\components\demand\air_passenger.py
154 155 156 157 |
|
Bases: ConfigItem
Air passenger demand aggregation input parameters.
Properties
Source code in tm2py\config.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
Commercial Demand ¶
Commercial vehicle / truck model module.
CommercialVehicleModel
¶
Bases: Component
Commercial Vehicle demand model.
Generates truck demand matrices from
- land use
- highway network impedances
- parameters
Segmented into four truck types
(1) very small trucks (two-axle, four-tire), (2) small trucks (two-axle, six-tire), (3) medium trucks (three-axle), (4) large or combination (four or more axle) trucks.
(1) MAZ csv data file with the employment and household counts.
(2) Skims (3) K-Factors (4)
Notes: (1) Based on the BAYCAST truck model, no significant updates. (2) Combined Chuck’s calibration adjustments into the NAICS-based model coefficients.
Source code in tm2py\components\demand\commercial.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
emme_scenario
property
¶
Return emme scenario from emmebank.
Use first valid scenario for reference Zone IDs.
TODO This should really be in the controller? Or part of network.skims?
emmebank
property
¶
Reference to highway assignment Emmebank.
TODO This should really be in the controller? Or part of network.skims?
matrix_cache
property
¶
Access to MatrixCache to Emmebank for given emme_scenario.
__init__(controller)
¶
Constructor for the CommercialVehicleTripGeneration component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Run controller for model run. |
required |
Source code in tm2py\components\demand\commercial.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
run()
¶
Run commercial vehicle model.
Source code in tm2py\components\demand\commercial.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
validate_inputs()
¶
Validate the inputs.
Source code in tm2py\components\demand\commercial.py
120 121 |
|
CommercialVehicleTimeOfDay
¶
Bases: Subcomponent
Commercial vehicle (truck) Time of Day Split for 4 sizes of truck.
Input: Trips origin and destination matrices by 4 truck sizes Ouput: 20 trips origin and destination matrices by 4 truck sizes by 5 times periods
Note
The diurnal factors are taken from the BAYCAST-90 model with adjustments made
during calibration to the very small truck values to better match counts.
Source code in tm2py\components\demand\commercial.py
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 |
|
class_period_splits
property
¶
Returns split fraction dictonary mapped to [time period class][time period].
__init__(controller, component)
¶
Constructor for the CommercialVehicleTimeOfDay component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Run controller for model run. |
required |
component
|
Component
|
Parent component of sub-component |
required |
Source code in tm2py\components\demand\commercial.py
765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
|
run(daily_demand)
¶
Splits the daily demand by time of day based on factors in the config.
Uses self.config.truck.classes.{class_name}.time_of_day_split to split the daily demand.
TODO use TimePeriodSplit ¶
Args: daily_demand: dictionary of truck type name to numpy array of truck type daily demand
Returns:
Type | Description |
---|---|
Dict[str, Dict[str, NumpyArray]]
|
Nested dictionary of truck class: time period name => numpy array of demand |
Source code in tm2py\components\demand\commercial.py
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 |
|
validate_inputs()
¶
Validate the inputs.
Source code in tm2py\components\demand\commercial.py
805 806 807 808 |
|
CommercialVehicleTollChoice
¶
Bases: Subcomponent
Commercial vehicle (truck) toll choice.
A binomial choice model for very small, small, medium, and large trucks. A separate value toll paying versus no value toll paying path choice model is applied to each of the twenty time period and vehicle type combinations.
(1) Trip tables by time of day and truck class
(2) Skims providing the time and cost for value toll and non-value toll paths for each; the matrix names in the OMX files are: “{period}{cls_name}_time” “{period}{cls_name}dist” “{period}{cls_name}bridgetoll{grp_name}” “{period}{cls_name}toll_time” “{period}{cls_name}toll_dist” “{period}{cls_name}toll_bridgetoll{grp_name}” “{period}_{cls_name}toll_valuetoll{grp_name}” Where period is the assignment period, cls_name is the truck assignment class name (as very small, small and medium truck are assigned as the same class) and grp_name is the truck type name (as the tolls are calculated separately for very small, small and medium).
(1) TOLLCLASS is a code, 1 through 10 are reserved for bridges; 11 and up is
reserved for value toll facilities.
1 2 3 4 5 6 7 |
|
Source code in tm2py\components\demand\commercial.py
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
|
__init__(controller, component)
¶
Constructor for Commercial Vehicle Toll Choice.
Also calls Subclass init().
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
model run controller |
required | |
component
|
parent component |
required |
Source code in tm2py\components\demand\commercial.py
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 |
|
run(trkclass_tp_demand_dict)
¶
Split per-period truck demands into nontoll and toll classes.
Uses OMX skims output from highway assignment: traffic_skims_{period}.omx
Source code in tm2py\components\demand\commercial.py
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
|
validate_inputs()
¶
Validate the inputs.
Source code in tm2py\components\demand\commercial.py
900 901 902 903 |
|
CommercialVehicleTripDistribution
¶
Bases: Subcomponent
Commercial vehicle (truck) Trip Distribution for 4 sizes of truck.
The four truck types are
(1) very small trucks (two-axle, four-tire), (2) small trucks (two-axle, six-tire), (3) medium trucks (three-axle), (4) large or combination (four or more axle) trucks.
(1) Trips by 4 truck sizes
(2) highway skims for truck, time, distance, bridgetoll and value toll (3) friction factors lookup table (4) k-factors matrix
A simple gravity model is used to distribute the truck trips, with separate friction factors used for each class of truck.
A blended travel time is used as the impedance measure, specifically the weighted average of the AM travel time (one-third weight) and the midday travel time (two-thirds weight).
Input
Level-of-service matrices for the AM peak period (6 am to 10 am) and midday period (10 am to 3 pm) which contain truck-class specific estimates of congested travel time (in minutes)
A matrix of k-factors, as calibrated by Chuck Purvis. Note the very small truck model does not use k-factors; the small, medium, and large trucks use the same k-factors.
A table of friction factors in text format with the following fields, space separated: - impedance measure (blended travel time); - friction factors for very small trucks; - friction factors for small trucks; - friction factors for medium trucks; and, - friction factors for large trucks.
Notes on distribution steps
load nonres/truck_kfactors_taz.csv load nonres/truckFF.dat Apply friction factors and kfactors to produce balancing matrix apply the gravity models using friction factors from nonres/truckFF.dat (note the very small trucks do not use the K-factors) Can use Emme matrix balancing for this - important note: reference matrices by name and ensure names are unique Trips rounded to 0.01, causes some instability in results
Notes: (1) Based on the BAYCAST truck model, no significant updates. (2) Combined Chuck’s calibration adjustments into the NAICS-based model coefficients.
Source code in tm2py\components\demand\commercial.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 |
|
friction_factors
property
¶
Table of friction factors for each time band by truck class.
Returns:
Type | Description |
---|---|
pd.DataFrame: DataFrame of friction factors read from disk. |
k_factors
property
¶
Zone-to-zone values of truck K factors.
Returns:
Name | Type | Description |
---|---|---|
NumpyArray |
Zone-to-zone values of truck K factors. |
__init__(controller, component)
¶
Constructor for the CommercialVehicleTripDistribution component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Run controller for model run. |
required |
component
|
Component
|
Parent component of sub-component |
required |
Source code in tm2py\components\demand\commercial.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
|
blended_skims(mode)
¶
Get blended skim. Creates it if doesn’t already exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode
|
str
|
Mode for skim |
required |
Returns:
Name | Type | Description |
---|---|---|
_type_ |
description |
Source code in tm2py\components\demand\commercial.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
|
friction_factor_matrices(trk_class, k_factors=None)
¶
Zone to zone NumpyArray of impedances for a given truck class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trk_class
|
str
|
Truck class abbreviated name |
required |
k_factors
|
Union[None, NumpyArray]
|
If not None, gives an zone-by-zone array of k-factors–additive impedances to be added on top of friciton factors. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
NumpyArray |
NumpyArray
|
Zone-by-zone matrix of friction factors |
Source code in tm2py\components\demand\commercial.py
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
|
run(tripends_df)
¶
Run commercial vehicle trip distribution.
Source code in tm2py\components\demand\commercial.py
632 633 634 635 636 637 638 639 |
|
validate_inputs()
¶
Validate the inputs.
Source code in tm2py\components\demand\commercial.py
627 628 629 630 |
|
CommercialVehicleTripGeneration
¶
Bases: Subcomponent
Commercial vehicle (truck) Trip Generation for 4 sizes of truck.
The four truck types are
(1) very small trucks (two-axle, four-tire), (2) small trucks (two-axle, six-tire), (3) medium trucks (three-axle), (4) large or combination (four or more axle) trucks.
Trip generation ¶
Use linear regression models to generate trip ends, balancing attractions to productions. Based on BAYCAST truck model.
The truck trip generation models for small trucks (two-axle, six tire), medium trucks (three-axle), and large or combination (four or more axle) trucks are taken directly from the study: “I-880 Intermodal Corridor Study: Truck Travel in the San Francisco Bay Area”, prepared by Barton Aschman in December 1992. The coefficients are on page 223 of this report.
The very small truck generation model is based on the Phoenix four-tire truck model documented in the TMIP Quick Response Freight Manual.
Note that certain production models previously used SIC-based employment categories. To both maintain consistency with the BAYCAST truck model and update the model to use NAICS-based employment categories, new regression models were estimated relating the NAICS-based employment data with the SIC-based-predicted trips. The goal here is not to create a new truck model, but to mimic the old model with the available data. Please see the excel spreadsheet TruckModel.xlsx for details. The NAICS-based model results replicate the SIC-based model results quite well.
Source code in tm2py\components\demand\commercial.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
|
__init__(controller, component)
¶
Constructor for the CommercialVehicleTripGeneration component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Run controller for model run. |
required |
component
|
Component
|
Parent component of sub-component |
required |
Source code in tm2py\components\demand\commercial.py
222 223 224 225 226 227 228 229 230 |
|
run()
¶
Run commercial vehicle trip distribution.
Source code in tm2py\components\demand\commercial.py
237 238 239 240 241 242 243 244 |
|
validate_inputs()
¶
Validate the inputs.
Source code in tm2py\components\demand\commercial.py
232 233 234 235 |
|
Bases: ConfigItem
Truck model parameters.
Source code in tm2py\config.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
|
highway_demand_file
instance-attribute
¶
@validator(“classes”) def class_consistency(cls, v, values): # TODO Can’t get to work righ tnow _class_names = [c.name for c in v] _gen_classes = [c.name for c in values[“trip_gen”]] _dist_classes = [c.name for c in values[“trip_dist”]] _time_classes = [c.name for c in values[“time_split”]] _toll_classes = [c.name for c in values[“toll_choice”]]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Inter-regional Demand ¶
Module containing Internal <-> External trip model.
ExternalDemand
¶
Bases: Subcomponent
Forecast of daily internal<->external demand based on growth from a base year.
Create a daily matrix that includes internal/external, external/internal, and external/external passenger vehicle travel (based on Census 2000 journey-to-work flows). These trip tables are based on total traffic counts, which include trucks, but trucks are not explicitly segmented from passenger vehicles. This short-coming is a hold-over from BAYCAST and will be addressed in the next model update.
The row and column totals are taken from count station data provided by Caltrans. The BAYCAST 2006 IX matrix is used as the base matrix and scaled to match forecast year growth assumptions. The script generates estimates for the model forecast year; the growth rates were discussed with neighboring MPOs as part of the SB 375 target setting process.
Input: (1) Station-specific assumed growth rates for each forecast year (the lack of external/external movements through the region allows simple factoring of cells without re-balancing); (2) An input base matrix derived from the Census journey-to-work data.
Output: (1) Four-table, forecast-year specific trip tables containing internal/external, external/internal, and external/external vehicle (xxx or person xxx) travel.
Governed by class DemandGrowth Config:
highway_demand_file:
input_demand_file:
input_demand_matrixname_tmpl:
modes:
reference_year:
annual_growth_rate:
special_gateway_adjust:
Source code in tm2py\components\demand\internal_external.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
run(base_demand=None)
¶
Calculate adjusted demand based on scenario year and growth rates.
Steps: - 1.1 apply special factors to certain gateways based on ID - 1.2 apply gateway-specific annual growth rates to results of step 1 to generate year specific forecast
Parameters:
Name | Type | Description | Default |
---|---|---|---|
demand
|
dictionary of input daily demand matrices (numpy arrays) |
required |
Returns:
Type | Description |
---|---|
Dict[str, NumpyArray]
|
Dictionary of Numpy matrices of daily PA by class mode |
Source code in tm2py\components\demand\internal_external.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
ExternalTollChoice
¶
Bases: Subcomponent
Toll choice ¶
Apply a binomial choice model for drive alone, shared ride 2, and shared ride 3 internal/external personal vehicle travel.
(1) Time-period-specific origin/destination matrices of drive alone, shared ride 2,
and share ride 3+ internal/external trip tables.
1 2 3 4 5 6 7 8 9 10 11 |
|
Output: Five, six-table trip matrices, one for each time period. Two tables for each vehicle class representing value-toll paying path trips and non-value-toll paying path trips
Governed by TollClassConfig:
1 2 3 4 5 6 7 8 |
|
Source code in tm2py\components\demand\internal_external.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
run(period_demand)
¶
Binary toll / non-toll choice model by class.
input: result of ix_time_of_day skims: traffic_skims{period}.omx, where {period} is the time period ID, {class} is the class name da, sr2, sr2, with the following matrix names Non-value-toll paying time: {period}{class}_time, Non-value-toll distance: {period}{class}dist, Non-value-toll bridge toll is: {period}{class}bridgetoll{class}, Value-toll paying time is: {period}{class}toll_time, Value-toll paying distance is: {period}{class}toll_dist, Value-toll bridge toll is: {period}{class}toll_bridgetoll{class}, Value-toll value toll is: {period}{class}toll_valuetoll{class},
STEPS: 3.1: For each time of day, for each da, sr2, sr3, calculate - utility of toll and nontoll - probability of toll / nontoll - split demand into toll and nontoll matrices
Source code in tm2py\components\demand\internal_external.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
InternalExternal
¶
Bases: Component
Develop Internal <-> External trip tables from land use and impedances.
- Grow demand from base year using static rates ::ExternalDemand
- Split by time of day using static factors ::TimePeriodSplit
- Apply basic toll binomial choice model: ::ExternalTollChoice
Governed by InternalExternalConfig
Source code in tm2py\components\demand\internal_external.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
run()
¶
Run internal/external travel demand component.
Source code in tm2py\components\demand\internal_external.py
67 68 69 70 71 72 73 74 |
|
validate_inputs()
¶
Validate inputs to component.
Source code in tm2py\components\demand\internal_external.py
62 63 64 65 |
|
Bases: ConfigItem
Internal <-> External model parameters.
Source code in tm2py\config.py
514 515 516 517 518 519 520 521 522 523 524 |
|
Visitor Demand ¶
Highway Network Components ¶
Module for highway network preparation steps.
Creates required attributes and populates input values needed for highway assignments. The toll values, VDFs, per-class cost (tolls+operating costs), modes and skim link attributes are calculated.
The following link attributes are used as input
- “@capclass”: link capclass index
- “length”: standard link length, in miles
- “@tollbooth”: label to separate bridgetolls from valuetolls
- “@tollseg”: toll segment, used to index toll value lookups from the toll file (under config.highway.tolls.file_path)
- “@ft”: functional class, used to assign VDFs
The following keys and tables are used from the config
highway.tolls.file_path: relative path to input toll file highway.tolls.src_vehicle_group_names: names used in tolls file for toll class values highway.tolls.dst_vehicle_group_names: corresponding names used in network attributes toll classes highway.tolls.valuetoll_start_tollbooth_code: index to split point bridge tolls (< this value) from distance value tolls (>= this value) highway.classes: the list of assignment classes, see the notes under highway_assign for detailed explanation highway.capclass_lookup: the lookup table mapping the link @capclass setting to capacity (@capacity), free_flow_speed (@free_flow_speec) and critical_speed (used to calculate @ja for akcelik type functions) highway.generic_highway_mode_code: unique (with other mode_codes) single character used to label entire auto network in Emme highway.maz_to_maz.mode_code: unique (with other mode_codes) single character used to label MAZ local auto network including connectors
The following link attributes are created (overwritten) and are subsequently used in the highway assignments. - “@flow_XX”: link PCE flows per class, where XX is the class name in the config - “@maz_flow”: Assigned MAZ-to-MAZ flow
The following attributes are calculated
- vdf: volume delay function to use
- “@capacity”: total link capacity
- “@ja”: akcelik delay parameter
- “@hov_length”: length with HOV lanes
- “@toll_length”: length with tolls
- “@bridgetoll_YY”: the bridge toll for class subgroup YY
- “@valuetoll_YY”: the “value”, non-bridge toll for class subgroup YY
- “@cost_YY”: total cost for class YY
PrepareNetwork
¶
Bases: Component
Highway network preparation.
Source code in tm2py\components\network\highway\highway_network.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
__init__(controller)
¶
Constructor for PPrepareNetwork.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Reference to run controller object. |
required |
Source code in tm2py\components\network\highway\highway_network.py
66 67 68 69 70 71 72 73 74 75 76 |
|
run()
¶
Run network preparation step.
Source code in tm2py\components\network\highway\highway_network.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
validate_inputs()
¶
Validate inputs files are correct, raise if an error is found.
Source code in tm2py\components\network\highway\highway_network.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
Highway assignment and skim component.
Performs equilibrium traffic assignment and generates resulting skims. The assignmend is configured using the “highway” table in the source config. See the config documentation for details. The traffic assignment runs according to the list of assignment classes under highway.classes.
Other relevant parameters from the config are: - emme.num_processors: number of processors as integer or “MAX” or “MAX-N” - time_periods[].emme_scenario_id: Emme scenario number to use for each period - time_periods[].highway_capacity_factor
The Emme network must have the following attributes available:
Link - attributes: - “length” in feet - “vdf”, volume delay function (volume delay functions must also be setup) - “@useclass”, vehicle-class restrictions classification, auto-only, HOV only - “@free_flow_time”, the free flow time (in minutes) - “@tollXX_YY”, the toll for period XX and class subgroup (see truck class) named YY, used together with @tollbooth to generate @bridgetoll_YY and @valuetoll_YY - “@maz_flow”, the background traffic MAZ-to-MAZ SP assigned flow from highway_maz, if controller.iteration > 0 - modes: must be set on links and match the specified mode codes in the traffic config
Network results - attributes: - @flow_XX: link PCE flows per class, where XX is the class name in the config - timau: auto travel time - volau: total assigned flow in PCE
Notes: - Output matrices are in miles, minutes, and cents (2010 dollars) and are stored/ as real values; - Intrazonal distance/time is one half the distance/time to the nearest neighbor; - Intrazonal bridge and value tolls are assumed to be zero
AssignmentClass
¶
Highway assignment class, represents data from config and conversion to Emme specs.
Source code in tm2py\components\network\highway\highway_assign.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 |
|
emme_class_analysis
property
¶
Construct and return a list of path analyses specs which generate the required skims.
Returns:
Type | Description |
---|---|
List[EmmeHighwayAnalysisSpec]
|
A list of nested dictionaries corresponding to the Emme path analysis |
List[EmmeHighwayAnalysisSpec]
|
(per-class) specification used in the SOLA assignment. |
emme_highway_class_spec
property
¶
Construct and return Emme traffic assignment class specification.
Converted from input config (highway.classes), see Emme Help for SOLA traffic assignment for specification details. Adds time_period as part of demand and skim matrix names.
Returns:
Type | Description |
---|---|
EmmeHighwayClassSpec
|
A nested dictionary corresponding to the expected Emme traffic |
EmmeHighwayClassSpec
|
class specification used in the SOLA assignment. |
emme_highway_class_spec_wo_pa
property
¶
Construct and return Emme traffic assignment class specification.
Converted from input config (highway.classes), see Emme Help for SOLA traffic assignment for specification details. Adds time_period as part of demand and skim matrix names.
Returns:
Type | Description |
---|---|
EmmeHighwayClassSpec
|
A nested dictionary corresponding to the expected Emme traffic |
EmmeHighwayClassSpec
|
class specification used in the SOLA assignment. |
skim_matrices
property
¶
__init__(class_config, time_period, iteration, reliability, warmstart)
¶
Constructor of Highway Assignment class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_config
|
_type_
|
description |
required |
time_period
|
_type_
|
description |
required |
iteration
|
_type_
|
description |
required |
reliability
|
bool
|
include reliability in path analysis or not. If true, reliability is included in path analysis using link field. If false, reliability is not included in path analysis, reliability skim is overwritten as 0. |
required |
warmstart
|
bool
|
True if assigning warmstart demand |
required |
Source code in tm2py\components\network\highway\highway_assign.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
|
emme_analysis_spec(link_attr, matrix_name)
staticmethod
¶
Returns Emme highway class path analysis spec.
See Emme Help for SOLA assignment for full specification details. Args: link_attr: input link attribute for which to sum values along the paths matrix_name: full matrix name to store the result of the path analysis
Returns:
Type | Description |
---|---|
EmmeHighwayAnalysisSpec
|
The nested dictionary specification which will generate the skim |
EmmeHighwayAnalysisSpec
|
of link attribute values. |
Source code in tm2py\components\network\highway\highway_assign.py
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
|
skim_analysis_link_attribute(skim, group)
staticmethod
¶
Return the link attribute name for the specified skim type and group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
skim
|
str
|
name of skim requested, one of dist, hovdist, tolldist, freeflowtime, bridgetoll, or valuetoll |
required |
group
|
str
|
subgroup name for the bridgetoll or valuetoll, corresponds to one of the names from config.highway.tolls.dst_vehicle_group_names |
required |
Source code in tm2py\components\network\highway\highway_assign.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 |
|
HighwayAssignment
¶
Bases: Component
Highway assignment and skims. Args: controller: parent RunController object
Source code in tm2py\components\network\highway\highway_assign.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
|
__init__(controller)
¶
Constructor for HighwayAssignment components.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Reference to current run controller. |
required |
Source code in tm2py\components\network\highway\highway_assign.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
run()
¶
Run highway assignment.
Source code in tm2py\components\network\highway\highway_assign.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
validate_inputs()
¶
Validate inputs files are correct, raise if an error is found.
Source code in tm2py\components\network\highway\highway_assign.py
126 127 128 129 |
|
Bases: ConfigItem
Highway assignment and skims parameters.
Properties
Source code in tm2py\config.py
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
|
unique_capclass_numbers(value)
¶
Validate list of capclass_lookup has unique .capclass values.
Source code in tm2py\config.py
1003 1004 1005 1006 1007 1008 1009 |
|
unique_class_names(value)
¶
Validate list of classes has unique .name values.
Source code in tm2py\config.py
1011 1012 1013 1014 1015 1016 1017 |
|
valid_skim_matrix_name_template(value)
¶
Validate skim matrix template has correct {}.
Source code in tm2py\config.py
989 990 991 992 993 994 995 996 997 998 999 1000 1001 |
|
valid_skim_template(value)
¶
Validate skim template has correct {} and extension.
Source code in tm2py\config.py
978 979 980 981 982 983 984 985 986 987 |
|
validate_class_keyword_lists(value, values)
¶
Validate classes .skims, .toll, and .excluded_links values.
Source code in tm2py\config.py
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
|
validate_class_mode_excluded_links(value, values)
¶
Validate list of classes has unique .mode_code or .excluded_links match.
Source code in tm2py\config.py
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 |
|
Bases: ConfigItem
Highway assignment class definition.
Note that excluded_links, skims and toll attribute names include vehicle groups (“{vehicle}”) which reference the list of highway.toll.dst_vehicle_group_names (see HighwayTollsConfig). The default example model config uses: “da”, “sr2”, “sr3”, “vsm”, sml”, “med”, “lrg”
Example single class config
name = “da” description= “drive alone” mode_code= “d” [[highway.classes.demand]] source = “household” name = “SOV_GP_{period}” [[highway.classes.demand]] source = “air_passenger” name = “da” [[highway.classes.demand]] source = “internal_external” name = “da” excluded_links = [“is_toll_da”, “is_sr2”], value_of_time = 18.93, # $ / hr operating_cost_per_mile = 17.23, # cents / mile toll = [“@bridgetoll_da”] skims = [“time”, “dist”, “freeflowtime”, “bridgetoll_da”],
Properties
Source code in tm2py\config.py
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 |
|
Bases: ConfigItem
Highway assignment and skim input tolls and related parameters.
Properties
Source code in tm2py\config.py
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 |
|
dst_vehicle_group_names_length(value, values)
¶
Validate dst_vehicle_group_names has same length as src_vehicle_group_names.
Source code in tm2py\config.py
841 842 843 844 845 846 847 848 849 850 851 |
|
Bases: ConfigItem
Grouping of counties for assignment and demand files.
Properties
Source code in tm2py\config.py
867 868 869 870 871 872 873 874 875 876 877 |
|
Assigns and skims MAZ-to-MAZ demand along shortest generalized cost path.
MAZ to MAZ demand is read in from separate OMX matrices as defined under the config table highway.maz_to_maz.demand_county_groups,
The demand is expected to be short distance (e.g. <0.5 miles), or within the same TAZ. The demand is grouped into bins of origin -> all destinations, by distance (straight-line) to furthest destination. This limits the size of the shortest path calculated to the minimum required. The bin edges have been predefined after testing as (in miles): [0.0, 0.9, 1.2, 1.8, 2.5, 5.0, 10.0, max_dist]
Input: Emme network with: Link attributes: - time attribute, either timau (resulting VDF congested time) or @free_flow_time Node attributes: @maz_id, x, y, and #node_county Demand matrices under highway.maz_to_maz.demand_file, and can have a placeholder auto_{period}MAZ_AUTO{number}_{period}.omx
Output: The resulting MAZ-MAZ flows are saved in link @maz_flow which is used as background traffic in the equilibrium Highway assignment.
AssignMAZSPDemand
¶
Bases: Component
MAZ-to-MAZ shortest-path highway assignment.
Calculates shortest path between MAZs with demand in the Emme network and assigns flow.
Source code in tm2py\components\network\highway\highway_maz.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
|
__init__(controller)
¶
MAZ-to-MAZ shortest-path highway assignment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
parent Controller object |
required |
Source code in tm2py\components\network\highway\highway_maz.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
run()
¶
Run MAZ-to-MAZ shortest path assignment.
Source code in tm2py\components\network\highway\highway_maz.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
validate_inputs()
¶
Validate inputs files are correct, raise if an error is found.
Source code in tm2py\components\network\highway\highway_maz.py
111 112 113 114 |
|
SkimMAZCosts
¶
Bases: Component
MAZ-to-MAZ shortest-path skim of time, distance and toll.
Source code in tm2py\components\network\highway\highway_maz.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
|
__init__(controller)
¶
MAZ-to-MAZ shortest-path skim of time, distance and toll.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
parent RunController object |
required |
Source code in tm2py\components\network\highway\highway_maz.py
676 677 678 679 680 681 682 683 684 685 686 687 |
|
run()
¶
Run shortest path skims for all available MAZ-to-MAZ O-D pairs.
Runs a shortest path builder for each county, using a maz_skim_cost to limit the search. The valid gen cost (time + cost), distance and toll (drive alone) are written to CSV at the output_skim_file path: FROM_ZONE, TO_ZONE, COST, DISTANCE, BRIDGETOLL
The following config inputs are used directly in this component. Note also that the network mode_code is prepared in the highway_network component using the excluded_links.
config.highway.maz_to_maz: skim_period: name of the period used for the skim, must match one the defined config.time_periods demand_county_groups: used for the list of counties, creates a list out of all listed counties under [].counties output_skim_file: relative path to save the skims value_of_time: value of time used to convert tolls and auto operating cost operating_cost_per_mile: auto operating cost max_skim_cost: max cost value used to limit the shortest path search mode_code:
Source code in tm2py\components\network\highway\highway_maz.py
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
|
validate_inputs()
¶
Validate inputs files are correct, raise if an error is found.
Source code in tm2py\components\network\highway\highway_maz.py
701 702 703 704 |
|
Bases: ConfigItem
Highway MAZ to MAZ shortest path assignment and skim parameters.
Properties
Source code in tm2py\config.py
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
|
unique_group_numbers(value)
¶
Validate list of demand_county_groups has unique .number values.
Source code in tm2py\config.py
918 919 920 921 922 923 |
|
Transit Network Components ¶
Transit assignment module.
TransitAssignment
¶
Bases: Component
Run transit assignment.
Source code in tm2py\components\network\transit\transit_assign.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 |
|
__init__(controller)
¶
Constructor for TransitAssignment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
'RunController'
|
RunController object. |
required |
Source code in tm2py\components\network\transit\transit_assign.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
|
run()
¶
Run transit assignments.
Source code in tm2py\components\network\transit\transit_assign.py
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
|
validate_inputs()
¶
Validate the inputs.
Source code in tm2py\components\network\transit\transit_assign.py
422 423 |
|
TransitAssignmentClass
¶
Transit assignment class, represents data from config and conversion to Emme specs.
Internal properties
Source code in tm2py\components\network\transit\transit_assign.py
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 |
|
emme_transit_spec
property
¶
Return Emme Extended transit assignment specification.
Converted from input config (transit.classes, with some parameters from transit table), see also Emme Help for Extended transit assignment for specification details.
name
property
¶
The class name.
__init__(tclass_config, config, time_period, iteration, num_processors, fare_modes, spec_dir)
¶
Assignment class constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tclass_config
|
TransitClassConfig
|
the transit class config (TransitClassConfig) |
required |
config
|
TransitConfig
|
the root transit assignment config (TransitConfig) |
required |
time_period
|
str
|
the time period name |
required |
iteration
|
int
|
the current iteration |
required |
num_processors
|
int
|
the number of processors to use, loaded from config |
required |
fare_modes
|
Dict[str, Set[str]]
|
the mapping from the generated fare mode ID to the original source mode ID |
required |
spec_dir
|
str
|
directory to find the generated journey levels tables from the apply fares step |
required |
Source code in tm2py\components\network\transit\transit_assign.py
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 |
|
calc_adjusted_headway(segment, segment_capacity)
¶
Headway adjusted based on ....?
TODO: add documentation about source and theory behind this.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment
|
Emme transit segment object |
required | |
segment_capacity
|
float
|
description |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Adjusted headway |
Source code in tm2py\components\network\transit\transit_assign.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
calc_extra_wait_time(segment, segment_capacity, eawt_weights, mode_config, use_fares=False)
¶
Calculate extra added wait time based on…
TODO document fully. ¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment
|
_type_
|
Emme transit segment object. |
required |
segment_capacity
|
float
|
description |
required |
eawt_weights
|
extra added wait time weights |
required | |
mode_config
|
dict
|
mode character to mode config |
required |
use_fares
|
bool
|
description. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
_type_ |
description |
Source code in tm2py\components\network\transit\transit_assign.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
calc_offs_thru_segment(segment)
¶
summary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment
|
_type_
|
description |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
description |
Source code in tm2py\components\network\transit\transit_assign.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
calc_total_offs(line)
¶
Calculate total alightings for a line.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
line
|
_type_
|
description |
required |
Source code in tm2py\components\network\transit\transit_assign.py
196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
func_returns_calc_updated_perceived_headway(time_period_duration, eawt_weights, mode_config, use_fares)
¶
function that returns the calc_headway function for emme assignment, with partial preloaded parameters acts like partial as emme does not take partial
Source code in tm2py\components\network\transit\transit_assign.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
func_returns_crowded_segment_cost(time_period_duration, weights)
¶
function that returns the calc_segment_cost function for emme assignment, with partial preloaded parameters acts like partial as emme does not take partial
Source code in tm2py\components\network\transit\transit_assign.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
func_returns_segment_congestion(time_period_duration, scenario, weights, use_fares=False)
¶
function that returns the calc_segment_cost function for emme assignment, with partial preloaded parameters acts like partial as emme does not take partial
Source code in tm2py\components\network\transit\transit_assign.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
time_period_capacity(vehicle_capacity, headway, time_period_duration)
¶
summary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vehicle_capacity
|
float
|
Vehicle capacity per hour. For vehicles with multiple cars (i.e. trainsets), should be the capacity of all of them that are traveling together. |
required |
headway
|
float
|
Vehicle (or train sets) per hour. |
required |
time_period_duration
|
float
|
duration of the time period in minutes |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
capacity for the whole time period |
Source code in tm2py\components\network\transit\transit_assign.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
Transit skims module.
TransitSkim
¶
Bases: Component
Transit skim calculation methods.
Source code in tm2py\components\network\transit\transit_skim.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 |
|
skim_properties
property
¶
List of Skim Property named tuples: name, description.
TODO put these in config.
__init__(controller)
¶
Constructor for TransitSkim class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
'RunController'
|
The RunController instance. |
required |
Source code in tm2py\components\network\transit\transit_skim.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
emmebank_skim_matrices(time_periods=None, transit_classes=None, skim_properties=None)
¶
Gets skim matrices from emmebank, or lazily creates them if they don’t already exist.
Source code in tm2py\components\network\transit\transit_skim.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
mask_above_max_transfers(time_period, transit_class)
¶
Reset skims to 0 if number of transfers is greater than max_transfers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time_period
|
str
|
Time period name abbreviation |
required |
transit_class
|
_type_
|
description |
required |
Source code in tm2py\components\network\transit\transit_skim.py
888 889 890 891 892 893 894 895 896 897 898 899 900 |
|
mask_if_not_required_modes(time_period, transit_class)
¶
Enforce the required_mode_combo
parameter by setting IVTs to 0 if don’t have required modes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time_period
|
str
|
Time period name abbreviation |
required |
transit_class
|
_type_
|
description |
required |
Source code in tm2py\components\network\transit\transit_skim.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 |
|
run()
¶
Run transit skims.
Source code in tm2py\components\network\transit\transit_skim.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
run_skim_set(time_period, transit_class)
¶
Run the transit skim calculations for a given time period and assignment class.
Results are stored in transit emmebank.
Steps
- determine if using transit capacity constraint
- skim walk, wait time, boardings, and fares
- skim in vehicle time by mode
- mask transfers above max amount
- mask if doesn’t have required modes
Source code in tm2py\components\network\transit\transit_skim.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
skim_crowding(time_period, transit_class)
¶
Source code in tm2py\components\network\transit\transit_skim.py
764 765 766 767 768 769 |
|
skim_drive_walk(time_period, transit_class)
¶
Source code in tm2py\components\network\transit\transit_skim.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
|
skim_invehicle_time_by_mode(time_period, transit_class, use_ccr=False)
¶
Skim in-vehicle by mode for a time period and transit class and store results in Emmebank.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time_period
|
str
|
time period abbreviation |
required |
transit_class
|
str
|
transit class name |
required |
use_ccr
|
bool
|
if True, will use crowding, capacity, and reliability (ccr). Defaults to False |
False
|
Source code in tm2py\components\network\transit\transit_skim.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
|
skim_penalty_toll(time_period, transit_class)
¶
Source code in tm2py\components\network\transit\transit_skim.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
|
skim_reliability_crowding_capacity(time_period, transit_class)
¶
Generate skim results for CCR assignment and stores results in Emmebank.
Generates the following: 1. Link Unreliability: LINKREL 2. Crowding penalty: CROWD 3. Extra added wait time: EAWT 4. Capacity penalty: CAPPEN
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time_period
|
str
|
time period abbreviation |
required |
transit_class
|
transit class |
required |
Source code in tm2py\components\network\transit\transit_skim.py
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
|
skim_walk_wait_boards_fares(time_period, transit_class)
¶
Skim wait, walk, board, and fares for a given time period and transit assignment class.
Skim the first and total wait time, number of boardings, (transfers + 1) fares, total walk time, total in-vehicle time.
Source code in tm2py\components\network\transit\transit_skim.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
validate_inputs()
¶
Validate inputs.
Source code in tm2py\components\network\transit\transit_skim.py
53 54 55 56 |
|
Bases: ConfigItem
Transit mode definition (see also mode in the Emme API).
Source code in tm2py\config.py
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
|
headway_fraction_valid(value, values)
¶
Validate headway_fraction exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1139 1140 1141 1142 1143 1144 |
|
in_vehicle_perception_factor_valid(value, values)
¶
Validate in_vehicle_perception_factor exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1111 1112 1113 1114 1115 1116 |
|
initial_boarding_penalty_valid(value, values)
¶
Validate initial_boarding_penalty exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1125 1126 1127 1128 1129 1130 |
|
mode_id_valid(value)
classmethod
¶
Validate mode_id.
Source code in tm2py\config.py
1153 1154 1155 1156 1157 1158 |
|
speed_or_time_factor_valid(value, values)
¶
Validate speed_or_time_factor exists if assign_type is AUX_TRANSIT.
Source code in tm2py\config.py
1118 1119 1120 1121 1122 1123 |
|
transfer_boarding_penalty_valid(value, values)
¶
Validate transfer_boarding_penalty exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1132 1133 1134 1135 1136 1137 |
|
transfer_wait_perception_factor_valid(value, values)
¶
Validate transfer_wait_perception_factor exists if assign_type is TRANSIT.
Source code in tm2py\config.py
1146 1147 1148 1149 1150 1151 |
|
Bases: ConfigItem
Transit assignment parameters.
Source code in tm2py\config.py
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 |
|
deprecate_capacitated_assignment(value, values)
¶
Validate use_ccr is false.
Source code in tm2py\config.py
1389 1390 1391 1392 1393 1394 1395 |
|
Active Network Components ¶
To come.
Emme Wrappers ¶
Bases: ConfigItem
Emme-specific parameters.
Properties
Source code in tm2py\config.py
1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 |
|
Errata ¶
Logging module.
Note the general definition of logging levels as used in tm2py:
highly detailed level information which would rarely be of interest
except for detailed debugging by a developer
LogCache
¶
Bases: LogFormatter
Caches all messages for later recording in on error logfile.
Properties
- file_path: the absolute file path to write to
Source code in tm2py\logger.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
|
__init__(file_path)
¶
Constructor for LogCache object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
the absolute file path to write to. |
required |
Source code in tm2py\logger.py
528 529 530 531 532 533 534 535 536 |
|
clear()
¶
Clear message cache.
Source code in tm2py\logger.py
563 564 565 |
|
log(text, level, indent, timestamp)
¶
Format and store text for later recording.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
level
|
int
|
logging level |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
required |
timestamp
|
str
|
formatted datetime as a string or None |
required |
Source code in tm2py\logger.py
543 544 545 546 547 548 549 550 551 552 553 554 |
|
open()
¶
Initialize log file (remove).
Source code in tm2py\logger.py
538 539 540 541 |
|
write_cache()
¶
Write all cached messages.
Source code in tm2py\logger.py
556 557 558 559 560 561 |
|
LogDisplay
¶
Bases: LogFormatter
Format and print log text to console / Notebook.
Properties
- level: the log level as an int
Source code in tm2py\logger.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
|
log(text, level, indent, timestamp)
¶
Format and display text on screen (print).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
level
|
int
|
logging level |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
required |
timestamp
|
str
|
formatted datetime as a string or None |
required |
Source code in tm2py\logger.py
508 509 510 511 512 513 514 515 516 517 518 |
|
LogFile
¶
Bases: LogFormatter
Format and write log text to file.
Properties
- level: the log level as an int
- file_path: the absolute file path to write to
Source code in tm2py\logger.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
|
__init__(level, file_path)
¶
Constructor for LogFile object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level
|
int
|
the log level as an int. |
required |
file_path
|
str
|
the absolute file path to write to. |
required |
Source code in tm2py\logger.py
433 434 435 436 437 438 439 440 441 442 |
|
close()
¶
Close the open log file.
Source code in tm2py\logger.py
464 465 466 467 |
|
log(text, level, indent, timestamp)
¶
Log text to file and display depending upon log level and config.
Note that log will not write to file until opened with a context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
level
|
int
|
logging level |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
required |
timestamp
|
str
|
formatted datetime as a string or None for timestamp |
required |
Source code in tm2py\logger.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
|
open()
¶
Open the log file for writing.
Source code in tm2py\logger.py
444 445 446 |
|
LogFileLevelOverride
¶
Bases: LogFile
Format and write log text to file.
Properties
- level: the log level as an int
- file_path: the absolute file path to write to
- iter_component_level: TODO
- controller: TODO
Source code in tm2py\logger.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
|
level
property
¶
Current log level with iter_component_level config override.
__init__(level, file_path, iter_component_level, controller)
¶
Constructor for LogFileLevelOverride object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level
|
_type_
|
TODO |
required |
file_path
|
_type_
|
TODO |
required |
iter_component_level
|
_type_
|
TODO |
required |
controller
|
_type_
|
TODO |
required |
Source code in tm2py\logger.py
480 481 482 483 484 485 486 487 488 489 490 491 |
|
LogFormatter
¶
Base class for recording text to log.
Properties
Source code in tm2py\logger.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
|
level
property
¶
The current filter level for the LogFormatter.
__init__(level)
¶
Constructor for LogFormatter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level
|
int
|
log filter level (as an int) |
required |
Source code in tm2py\logger.py
357 358 359 360 361 362 363 364 |
|
decrease_indent(level)
¶
Decrease current indent if the log level is filtered in.
Source code in tm2py\logger.py
376 377 378 379 |
|
increase_indent(level)
¶
Increase current indent if the log level is filtered in.
Source code in tm2py\logger.py
371 372 373 374 |
|
log(text, level, indent, timestamp)
abstractmethod
¶
Format and log message text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
level
|
int
|
logging level |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
required |
timestamp
|
str
|
formatted datetime as a string or None |
required |
Source code in tm2py\logger.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
|
LogStartEnd
¶
Log the start and end time with optional message.
Used as a Component method decorator. If msg is not provided a default message is generated with the object class and method name.
Example:: @LogStartEnd(“Highway assignment and skims”, level=”STATUS”) def run(self): pass
Properties
text (str): message text to use in the start and end record. level (str): logging level as a string.
Source code in tm2py\logger.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
|
__call__(func)
¶
Ability to call logger.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
_type_
|
description |
required |
Returns:
Name | Type | Description |
---|---|---|
_type_ |
description |
Source code in tm2py\logger.py
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
|
__init__(text=None, level='INFO')
¶
Constructor for LogStartEnd object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
message text to use in the start and end record. Defaults to None. |
None
|
level
|
str
|
logging level as a string. Defaults to “INFO”. |
'INFO'
|
Source code in tm2py\logger.py
587 588 589 590 591 592 593 594 595 596 |
|
Logger
¶
Logging of message text for display, text file, and Emme logbook, as well as notify to slack.
The log message levels can be one of: TRACE, DEBUG, DETAIL, INFO, STATUS, WARN, ERROR, FATAL Which will filter all messages of that severity and higher. See module note on use of descriptive level names.
logger.log(“a message”) with logger.log_start_end(“Running a set of steps”): logger.log(“Message with timestamp”) logger.log(“A debug message”, level=”DEBUG”) # equivalently, use the .debug: logger.debug(“Another debug message”) if logger.debug_enabled: # only generate this report if logging DEBUG logger.log(“A debug report that takes time to produce”, level=”DEBUG”) logger.notify_slack(“A slack message”)
Methods can also be decorated with LogStartEnd (see class for more).
Note that the Logger should only be initialized once per model run. In places where the controller is not available, the last Logger initialized can be obtained from the class method get_logger::
1 |
|
Internal properties
Source code in tm2py\logger.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
debug_enabled
property
¶
Returns True if DEBUG is currently filtered for display or print to file.
Can be used to enable / disable debug logging which may have a performance impact.
trace_enabled
property
¶
Returns True if TRACE is currently filtered for display or print to file.
Can be used to enable / disable trace logging which may have a performance impact.
__del__()
¶
Destructor for logger object
Source code in tm2py\logger.py
142 143 144 145 146 147 148 |
|
__init__(controller)
¶
Constructor for Logger object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
Associated RunController instance. |
required |
Source code in tm2py\logger.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
__new__(controller)
¶
Logger new method override. TODO.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
controller
|
RunController
|
TODO. |
required |
Source code in tm2py\logger.py
89 90 91 92 93 94 95 96 97 |
|
clear_msg_cache()
¶
Clear all log messages from cache.
Source code in tm2py\logger.py
318 319 320 |
|
debug(text, indent=False)
¶
Log text with level=DEBUG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
False
|
Source code in tm2py\logger.py
187 188 189 190 191 192 193 194 |
|
detail(text, indent=False)
¶
Log text with level=DETAIL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
False
|
Source code in tm2py\logger.py
196 197 198 199 200 201 202 203 |
|
error(text, indent=False)
¶
Log text with level=ERROR.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
False
|
Source code in tm2py\logger.py
232 233 234 235 236 237 238 239 |
|
fatal(text, indent=False)
¶
Log text with level=FATAL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
False
|
Source code in tm2py\logger.py
241 242 243 244 245 246 247 248 |
|
get_logger()
classmethod
¶
Return the last initialized logger object.
Source code in tm2py\logger.py
150 151 152 153 |
|
info(text, indent=False)
¶
Log text with level=INFO.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
False
|
Source code in tm2py\logger.py
205 206 207 208 209 210 211 212 |
|
log(text, level='INFO', indent=True)
¶
Log text to file and display depending upon log level and config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
level
|
str
|
logging level |
'INFO'
|
indent
|
bool
|
if true indent text based on the number of open contexts |
True
|
Source code in tm2py\logger.py
164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
log_dict(mapping, level='DEBUG')
¶
Format dictionary to string and log as text.
Source code in tm2py\logger.py
302 303 304 |
|
log_start_end(text, level='STATUS')
¶
Use with ‘with’ statement to log the start and end time with message.
If using the Emme logbook (config.logging.use_emme_logbook is True), will also create a logbook nest in the tree view using logbook_trace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
message text |
required |
level
|
str
|
logging level |
'STATUS'
|
Source code in tm2py\logger.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
log_time(text, level=1, indent=False)
¶
Log message with timestamp
Source code in tm2py\logger.py
250 251 252 253 254 255 256 257 |
|
notify_slack(text)
¶
Send message to slack if enabled by config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to send to slack |
required |
Source code in tm2py\logger.py
155 156 157 158 159 160 161 162 |
|
status(text, indent=False)
¶
Log text with level=STATUS.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
False
|
Source code in tm2py\logger.py
214 215 216 217 218 219 220 221 |
|
trace(text, indent=False)
¶
Log text with level=TRACE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
False
|
Source code in tm2py\logger.py
178 179 180 181 182 183 184 185 |
|
warn(text, indent=False)
¶
Log text with level=WARN.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
text to log |
required |
indent
|
bool
|
if true indent text based on the number of open contexts |
False
|
Source code in tm2py\logger.py
223 224 225 226 227 228 229 230 |
|
SlackNotifier
¶
Notify slack of model run status.
The slack channel can be input directly, or is configured via text file found at “M:\Software\Slack\TravelModel_SlackWebhook.txt” (if on MTC server) rr”C:\Software\Slack\TravelModel_SlackWebhook.txt” (if local)
Properties
- logger (Logger): object for logging of trace messages
- slack_webhook_url (str): optional, url to use for sending the message to slack
Source code in tm2py\logger.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 |
|
__init__(logger, slack_webhook_url=None)
¶
Constructor for SlackNotifier object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logger
|
Logger
|
logger instance. |
required |
slack_webhook_url
|
str
|
. Defaults to None, which is replaced by either: - r”M:\Software\Slack\TravelModel_SlackWebhook.txt” (if on MTC server) - r”C:\Software\Slack\TravelModel_SlackWebhook.txt” (otherwise) |
None
|
Source code in tm2py\logger.py
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
|
post_message(text)
¶
Posts text to the slack channel via the webhook if slack_webhook_url is found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
text message to send to slack |
required |
Source code in tm2py\logger.py
673 674 675 676 677 678 679 680 681 682 683 684 685 |
|
Tools module for common resources / shared code and “utilities” in the tm2py package.
SpatialGridIndex
¶
Simple spatial grid hash for fast (enough) nearest neighbor / within distance searches of points.
Source code in tm2py\tools.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
|
__init__(size)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
float
|
the size of the grid to use for the index, relative to the point coordinates |
required |
Source code in tm2py\tools.py
327 328 329 330 331 332 333 |
|
insert(obj, x, y)
¶
Add new obj with coordinates x and y. Args: obj: any python object, will be returned from search methods “nearest” and “within_distance” x: x-coordinate y: y-coordinate
Source code in tm2py\tools.py
335 336 337 338 339 340 341 342 343 344 |
|
nearest(x, y)
¶
Return the closest object in index to the specified coordinates Args: x: x-coordinate y: y-coordinate
Source code in tm2py\tools.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
|
within_distance(x, y, distance)
¶
Return all objects in index within the distance of the specified coordinates Args: x: x-coordinate y: y-coordinate distance: distance to search in point coordinate units
Source code in tm2py\tools.py
383 384 385 386 387 388 389 390 391 392 393 394 |
|
within_square(x, y, distance)
¶
Return all objects in index within a square box distance of the specified coordinates. Args: x: x-coordinate y: y-coordinate distance: distance to search in point coordinate units
Source code in tm2py\tools.py
396 397 398 399 400 401 402 403 404 405 406 407 |
|
download_unzip(url, out_base_dir, target_dir, zip_filename='test_data.zip')
¶
Download and unzips a file from a URL. The zip file is removed after extraction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
Full URL do download from. |
required |
out_base_dir
|
str
|
Where to unzip the file. |
required |
target_dir
|
str
|
What to unzip the file as. |
required |
zip_filename
|
str
|
Filename to store zip file as. Defaults to “test_data.zip”. |
'test_data.zip'
|
Source code in tm2py\tools.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
emme_context()
¶
Return True if Emme is installed.
Source code in tm2py\tools.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
interpolate_dfs(df, ref_points, target_point, ref_col_name='ends_with')
¶
Interpolate for the model year assuming linear growth between the reference years.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
dataframe to interpolate on, with ref points contained in column name per ref_col_name. |
required |
ref_points
|
Collection[Union[float, int]]
|
reference years to interpolate between |
required |
target_point
|
Union[float, int]
|
target year |
required |
ref_col_name
|
str
|
column name to use for reference years. Defaults to “ends_with”. |
'ends_with'
|
Source code in tm2py\tools.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
mocked_inro_context()
¶
Mocking of modules which need to be mocked for tests.
Source code in tm2py\tools.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
parse_num_processors(value)
¶
Parse input value string “MAX-X” to number of available processors.
Used with Emme procedures (traffic and transit assignments, matrix caculator, etc.) Does not raise any specific errors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
[str, int, float]
|
int, float or string; string value can be “X” or “MAX-X” |
required |
Source code in tm2py\tools.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|
run_process(commands, name='')
¶
Run system level commands as blocking process and log output and error messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
commands
|
Collection[str]
|
list of one or more commands to execute |
required |
name
|
str
|
optional name to use for the temp bat file |
''
|
Source code in tm2py\tools.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
temp_file(mode='w+', prefix='', suffix='')
¶
Temp file wrapper to return open file handle and named path.
A named temporary file (using mkstemp) with specified prefix and suffix is created and opened with the specified mode. The file handle and path are returned. The file is closed and deleted on exit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode
|
str
|
mode to open file, [rw][+][b] |
'w+'
|
prefix
|
str
|
optional text to start temp file name |
''
|
suffix
|
str
|
optional text to end temp file name |
''
|
Source code in tm2py\tools.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
zonal_csv_to_matrices(csv_file, i_column='ORIG', j_column='DEST', value_columns=['VALUE'], default_value=0.0, fill_zones=False, max_zone=None, delimiter=',')
¶
Read a CSV file with zonal data and into dataframes.
Input CSV file should have a header row specifying the I, J, and Value column names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
csv_file
|
str
|
description |
required |
i_column
|
str
|
Name of j zone column. Defaults to “ORIG”. |
'ORIG'
|
j_column
|
str
|
Name of i zone column. Defaults to “DEST”. |
'DEST'
|
value_columns
|
str
|
List of columns to turn into matrices. Defaults to [“VALUE”]. |
['VALUE']
|
default_value
|
float
|
Value to fill empty cells with. Defaults to 0.0. |
0.0
|
fill_zones
|
bool
|
If true, will fill zones without values to max zone with default value. Defaults to False. |
False
|
max_zone
|
int
|
If fill_zones is True, used to determine matrix size. Defaults to max(I, J). |
None
|
delimiter
|
str
|
Input file delimeter. Defaults to “,”. |
','
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Mapping[str, DataFrame]
|
Dictionary of Pandas dataframes with matrix names as keys. |
Source code in tm2py\tools.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
Download and unzip examples for tm2py, used in tests.
get_example(example_name=_DEFAULT_EXAMPLE_NAME, example_subdir=_DEFAULT_EXAMPLE_SUBDIR, root_dir=_ROOT_DIR, retrieval_url=_DEFAULT_EXAMPLE_URL)
¶
Returns example directory; downloads if necessary from retrieval URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
example_name
|
str
|
Used to retrieve sub-folder or create it if doesn’t exist. Defaults to _DEFAULT_EXAMPLE_NAME. |
_DEFAULT_EXAMPLE_NAME
|
example_subdir
|
str
|
Where to find examples within root dir. Defaults to _DEFAULT_EXAMPLE_SUBDIR. |
_DEFAULT_EXAMPLE_SUBDIR
|
root_dir
|
str
|
Root dir of project. Defaults to _ROOT_DIR. |
_ROOT_DIR
|
retrieval_url
|
str
|
URL to retrieve example data zip from. Defaults to _DEFAULT_EXAMPLE_URL. |
_DEFAULT_EXAMPLE_URL
|
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If can’t find the files after trying to download it. |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to example data. |
Source code in tm2py\examples.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|