-
Notifications
You must be signed in to change notification settings - Fork 7
Learning Guide
ASU Trans+AI Lab edited this page Oct 27, 2024
·
1 revision
TAPLite.cpp is a C++ program that performs traffic assignment calculations, building on implementations provided by Dr. Hillel Bar-Gera’s TNTP and mincostroutes.cpp. It includes advanced data structures, such as deque for modified label-correcting (MLC) algorithms, and is optimized for performance using OpenMP for parallel processing. This guide will cover key sections of the code, including data structures, cost functions, assignment algorithms, and file input/output methods.
- Constants like
FLOAT_ACCURACY,NO_COSTPARAMETERS, andIVTTare defined for use in computations and comparisons. - Macros such as
MIN(x, y),MAX(x, y),SQR(x), andFABS(x)simplify and streamline calculations.
-
link_recordStructure: Holds data on network links, including IDs, capacities, travel times, and costs. -
mode_typeStructure: Represents each mode of travel (e.g., car, truck) with attributes like Value of Time (VOT), Passenger Car Equivalents (PCE), and occupancy rates.
- Utility functions
Alloc_1D,Alloc_2D, andAlloc_3Dallocate dynamic memory for one-dimensional, two-dimensional, and three-dimensional arrays, respectively. -
Example:
Alloc_3D(number_of_modes, no_zones, no_zones, sizeof(double))allocates a 3D array to hold data for each mode.
-
Settings File (
settings.csv): Configuration options for the number of processors, demand period, and logging preferences. -
Mode Type File (
mode_type.csv): Information on each mode, includingmode_type,vot,pce, andocc. -
Node and Link Files (
node.csvandlink.csv): Define network geometry and link attributes.
-
InitFunction: Initializes variables, reads the OD flow data, and sets up links. -
InitLinksFunction: Sets up links by reading data fromlink.csv, calculates the allowed usage modes, and initializes link capacities.
-
Link_Travel_TimeFunction: Calculates link travel time based on volume, capacity, and free-flow travel time using a Volume-Delay Function (VDF). -
Link_Travel_Time_IntegralFunction: Computes the travel time integral for a link. -
Link_GenCostFunction: Combines travel time and additional costs (e.g., tolls) into a generalized link cost.
-
MinpathFunction: Implements the shortest path search using the deque MLC algorithm. It updates link costs based on the minimum path cost between nodes. -
FindMinCostRoutesFunction: Computes the minimum cost routes across the network and stores them in a tree structure.
-
All_or_Nothing_AssignFunction: Assigns OD flows to links based on the shortest paths. -
Search Direction Calculation (
VolumeDifference): Computes the difference in volumes between the current and sub-assignment volumes.
-
LinksSDLineSearchFunction: Uses a bisection method to optimize the assignment by adjusting the step sizeLambda.
-
Logging: The program logs results to files like
TAP_log.csvandlink_performance.csv, capturing iteration details, travel times, volumes, and more. - Performance Calculation: Summarizes system-wide travel times and outputs OD performance.
-
double Link_Travel_Time(int k, double* Volume): Calculates the travel time for a link based on current volume. -
double Link_GenCost(int k, double* Volume): Computes the generalized cost including tolls for each link.
-
int Minpath(int mode, int Orig, int* PredLink, double* CostTo): Calculates the minimum path cost using MLC. -
void All_or_Nothing_Assign(...): Executes the traffic assignment based on shortest paths.
-
double LinksSDLineSearch(double* MainVolume, double* SDVolume): Uses bisection for step size adjustment in iterative optimization.
To execute TAPLite:
- Set configuration parameters in
settings.csv. - Define modes and demand data in
mode_type.csvand corresponding demand files. - Run the program, observing output logs for each iteration and final convergence metrics.