next up previous
Next: In the Works Up: EMME/2 News 19October 1997 Previous: Macro Tech-Tips

 

Macros from the EMME/2 Support Center

Over the past years, EMME/2 macros for solving various types of problems have been developed at the EMME/2 Support Center. Most often, these macros were written as a direct result of an exchange with an EMME/2 user asking whether this or that problem could be solved efficiently with EMME/2. Our policy has always been to make such macros freely available to all EMME/2 users. In the beginning, they were included on INRO's famous SHARE diskettes, now they can be downloaded directly via Internet from the macro archive section of our web site (http://www.spiess.ch/emme2/).

The use of these macros is twofold: First and foremost, they can, of course, be used to perform the task they were written for. But secondly, and probably as important for those EMME/2 users who write their own macros, they may also serve as ``real-life'' examples illustrating the various macro writing techniques.

As several new macros have been added to our collection during the last year, we thought that it might be interesting to list an inventory in EMME/2 News. Besides giving a short description on the task each macro performs, the inventory also includes technical notes on the macro writing techniques used. The latter may be of interest to EMME/2 macro writers, as the described techniques are by no means limited to the particular application. For a more structured introduction to the various macro writing techniques, a tutorial for EMME/2 macro writing, including many practical exercises, is available for downloading at our web site.

Here is the list of all macros that are currently available from the EMME/2 Support Center:

Macro:Description:Technical Notes:
 accumvol Accumulates boardings and alightings along the stops of a transit line to produce segment volumes. Uses put(get()) to propagate information from one expression evaluation to the next.
 angleijk This is a small macro containing only a network calculator expression which computes turning angle of a turn I-J-K. The result of the expression is the turning angle tex2html_wrap_inline602 in degrees: tex2html_wrap_inline602 =-180 for U-turns, -180< tex2html_wrap_inline602 <0 for left turns, tex2html_wrap_inline602 =0 for straight-through and 0< tex2html_wrap_inline602 <180 for right turns. Just basic trigonometry and some sub-expression optimization using the put() and get() intrinsics.
 balance3 A macro to perform 3-dimensional balancing based on group-to-group totals. Unlike the 3-dimensional balancing available in module 3.22, the 3rd dimension totals are not given as an explicit list, but correspond to the group-to-group totals of an aggregate matrix and there is no explicit limitation of the number of 3rd dimension constraints. Uses matrix calculator 3.21 to implement a 3.22-type balancing procedure. Note the handling of the flexible file naming and the operating system specific external commands.
 balmprod Performs 2-dimensional matrix balancing in the case where several different production types are given (up to 4). For each production type a production vector and a friction matrix is specified. This macro can be used for doubly constrained demand models with stratified multiple productions and unstratified single attractions. Uses matrix calculator 3.21 to implement a 3.22-type balancing procedure. Could be easily extended to more than 4 production types.
 bellman Bellman's shortest path algorithm implemented using module 2.41. It computes the shortest distances (based on an arbitrary link distance measure) from the root node to all other nodes by iteratively solving the Bellman equation. Useful for didactical purposes, and also for various location type problems where node-to-node distances are needed. Note the use of a scalar for detecting the termination of the algorithm.
 demadj (*) Auto demand matrix adjustment procedure based on the gradient method. This macro iteratively adjusts an auto demand matrix in order to improve the fit between a set of observed link counts and the corresponding assigned auto volumes. Text registers t4, t5 and t6 are used for easy customization of the macro regarding submatrix selection, type of assignment and count post specific weights.
 demadjt (*) Transit demand matrix adjustment procedure based on the gradient method. This macro iteratively adjusts a transit demand matrix in order to improve the fit between a set of observed transit segment counts and the corresponding assigned transit volumes. A nice future extension to this macro would be to allow for total link counts as alternative to segment counts.
 errchk Small macro to check for errors during execution of another macro. The macro takes as an argument another macro (plus corresponding parameters, if any). It executes the specified macro and returns the total number of errors (both fatal errors and warnings) which occurred during the execution. Especially useful for detecting warnings (e.g. batch input errors) which might otherwise remain undetected. A nice little example of a ``wrapper'' macro, i.e. a macro which does its job by calling another macro as specified in the parameters along with some pre- and post-processing.
 legimped Extract 1st leg impedance matrix tex2html_wrap_inline612 or 2nd leg impedance matrix tex2html_wrap_inline614 from a given total impedance tex2html_wrap_inline616 and an intermediate zone matrix tex2html_wrap_inline618 . See also macro splitmat for the corresponding operation on demand matrices. Uses some rather tricky convolutions to obtain the desired results efficiently.
 matreg Multiple linear regression on arbitrary matrix data. The regression can contain 4 independent variables (or 3 variables plus a constant). The variables can be specified as arbitrary matrices or matrix expressions. The output consists of the regression coefficients, t-statistics, SST, SSE, tex2html_wrap_inline620 and tex2html_wrap_inline622 . A good example how put(get()) constructs can be used to compute several side results (in this case the entire matrix X'X) with just one single expression evaluation. This saves a lot of matrix I/O compared with the traditional approach.
 mimoleg (*) This macro implement a logit type intermediate destination choice model for mixed mode trips (e.g. Park+Ride or Kiss+Ride) which computes intermediate demand matrices for the first and the second trip leg. No explicit capacities at intermediate destinations are taken into account. This macro implements a full logit model efficiently, essentially by using convolutions to perform matrix multiplications.
 mlus92 Implementation of German air pollution model MLuS-92. This is a rather coarse model based on lookup tables which was developed in 1992 by the German "Forschungsgesellschaft für Strassen- und Verkehrswesen". Multi-dimensional lookup tables are implemented by mixing the use of the get()/put() stack with macro conditionals ~?.
 netdiff Macro which compares two scenarios and reports differences in network topology, i.e. nodes, links and/or transit lines which are in one scenario but not in the other. Optionally, the macro can also compare the values of specified numerical attributes. This macro makes extensive use of temporary attributes in network calculator.
 nethist Macro for generating arbitrary network histograms. It supports numerical output on screen or into result file, as well as generating a plot of the histogram using module 4.13. The term histogram is used here for forming sums of an arbitrary network expression by any kind of classification. Macro uses the recently introduced intrinsic puti() to calculate the entire histogram with one single expression. Extensive use of fast macros loops and floating point registers.
 netreg Multiple linear regression on any network data. The regression can contain 4 independent variables (or 3 variables plus a constant). The variables can be specified as any kind of network attributes or expressions. The output consists of the regression coefficients, t-statistics, SST, SSE, tex2html_wrap_inline620 and tex2html_wrap_inline622 . Based on the same expression ``engine'' as matreg. Note how the linear equation is solved explicitly by using Cramer's rule.
 oppvol Generic macro to efficiently compute opposing volumes on turns based on turning angles. For each turn, this macro classifies the other turns at the same intersection according to their relative origin (rear, right, left, front) and destination (front, right, left, rear). The opposing flow of the turn is then computed using a user specified 4x4 coefficient matrix. This coefficient matrix can easily be customized to special situations and priority schemes. The computation for all intersection of the appropriate type are carried out in parallel. This is one of the more complex macros. Among many other things, it shows nicely how to ``climb up and down'' the hierarchy tree of the network calculator by moving turn information to the link and node level and back again.
 parkride (*) Logit model for Park+Ride parking choice with explicit capacities at parking lots. This macro computes intermediate demand matrices for the first and the second trip leg. Based on the convolution engine used in mimoleg the problem with explicit parking lot capacities is solved by a successive dual coordinate ascent method.
 pltlines Plots the itinerary of one or several transit lines in an optimally adjusted network window. The coordinates of the optimal window are computed in module 2.41 and saved in scalars from which they are accessed in module 2.23.
 rndabout This macro computes the opposing volumes for round-about intersections. As the opposing volume only depends on the incoming link of the round-about, the result is stored as an attribute of the incoming link. This macro will compute the opposing volumes for all round-about nodes in parallel. Uses the same type of angle calculations as macro oppvol, but is less complex, since the opposing volumes are fully defined by the geometry of incoming links.
 s2stimes Aggregates the segment times between consecutive stops of one or several transit lines and generates a report or punch file with the stop-to-stop times and distances. See also macro splitime. Shows nicely how module 2.41 can be used to generate arbitrary network reports or punch files.
 splitime Splits stop-to-stop transit times onto the segments between two consecutive stops. The splitting is done proportionally to the segment lengths. For the reverse type of operation see macro s2stimes. A good example showing how to use the put(get()) technique combined with the N-type segment attributes for propagating information forth and back along the segments of a transit line.
 splitmat Splits a demand matrix tex2html_wrap_inline628 into two intermediate demand matrices tex2html_wrap_inline630 (first leg) and tex2html_wrap_inline632 (second leg), given an intermediate zone matrix tex2html_wrap_inline618 . See also macro legimped for the corresponding operation on impedance matrices. A rather basic application of convolution techniques. Note the heavy use of compound macro statements.
 stochas Implementation of a stochastic auto assignment using pseudo random time perturbations. At each outer iteration, a shortest path or equilibrium assignment is generated using a new set of time perturbations. The results of the outer iterations are averaged to obtain the final assignment result. This macro contains useful expressions to compute various types of pseudo random numbers (Uniform, Normal, Exponential and Gumble distributions). Do not modify the part using module 1.11, nor try to use this technique on your own -- dangerous!
 tchain3 (*) This macro implements the necessary convolution computations to implement an activity chaining demand model for 3-legged trips. This is rather complex, so there is no point looking at this macro unless you have read and understood the corresponding theoretical paper.

Most of these macros, when called without any parameters, will display a short explanation of their functionality and detailed instructions regarding their calling sequence. For macros identified with an asterisk (*), a paper containing more detailed information on the topic (including the relevant mathematical developments) is also available on the same web site.

All macros mentioned above are not part of the EMME/2 software as such. They are distributed as is, i.e. with no explicit or implied warranty of any kind. Detailed information regarding the conditions of use are contained in the header section of each macro.


next up previous
Next: In the Works Up: EMME/2 News 19October 1997 Previous: Macro Tech-Tips


Heinz Spiess, EMME/2 Support Center, Tue Oct 28 14:21:47 MET 1997