Presentation is loading. Please wait.

Presentation is loading. Please wait.

EMME/2 Macro Programming With Release 9: Non Trivial Solutions to Trivial Problems Vladimir Livshits University of Toronto.

Similar presentations

Presentation on theme: "EMME/2 Macro Programming With Release 9: Non Trivial Solutions to Trivial Problems Vladimir Livshits University of Toronto."— Presentation transcript:

1 EMME/2 Macro Programming With Release 9: Non Trivial Solutions to Trivial Problems Vladimir Livshits University of Toronto

2 Some Major Problems Inherent to the Macro Language As a Keystroke Record: lExchange of information between modules, banks, and scenarios lHandling complex data structures lUser interface

3 More than a Keystroke Record lFile processing lLoops and text registers in compound lines lConvolutions of complex data structures in text strings lHandling of complex repetitive expressions See paper for: aGraphical user interface in macro routines aUseful macro utilities aInteractions with operating system in macro routines

4 Some Painful Stuff (1) Information exchange between: Modules - often the most difficult: , , , , , etc. Banks - a lot easier with 1.31 (can be done naturally via keystroke record!), But might involve complicated logic in macros (checking what exists, ensuring data compatibility, etc.) Scenarios - depends on a task at hand - can be straight forward, can be difficult

5 File Processing: Example 1 t nodes a* … centroids data … a … regular nodes data... t links a … links data … file for links input in 2.11: t links d … links data... file for nodes input in 2.11: d* … centroids data … d … regular nodes data... MACRO

6 ~<<214.Out ~# One compound row below till the '~$' sign links;~$>links; ~t2=%%t1.1%%;~>>;~?t2=a;~"d%%t1.-1%%; ~?t2=d;~"a%%t1.-1%%;~?t2=t;~"%%t1%%;~>>;~$ ~# End of compound line ~:links ~+;~>>;~"%%t1%%;~>> ~# One compound row below till the '~$' sign ?t2=a;~"d%%t1.-1%%;~?t2=d;~"a %%t1.-1%%;~?t2=t;~"%%t1%%;~>>;~$ ~# End of compound line ~:exit ~+;~<< ~+;~>>;~" ;~>>;~>>;~" ;~>>

7 File Processing: Example 2 ~/Select: 1. Delete all old station centroids ~/ 2. Add new station centroids ~/ 3. Remove all subway station centroids ~/ without parking lots and insert parking ~/ data in the retained centroids attributes ~/ 4. Connect station centroids to the road ~/ network ~/ 5. Check if station centroids have been ~/ inserted ~/ 6. Speed run - run options 1,2,3,4 using ~/ defaults ~/ 7. Change macro parameters ~/ 8. Display copyright notice

8 Example Schema for Automated Road Network Modifications Mark up network elements Produce input files for file processing Reformat files in a macro Read files in a bank MACRO

9 Main Principles of File Processing in Emme/2 Macro Language Release 9 ¶Utilisation of text registers to exchange information between different files ·Utilisation of sub-strings (text substitutions) to reformat text lines ¸Careful closing of files opened for writing In a compound line in order to avoid undesirable writing to the files ¹Utilisation of compound lines For efficient handling of file processing procedures ºUtilisation of the t0 text register and positional parameters %1% … %32% For reformatting and for exchanging text strings between files

10 Some Painful Stuff (2) Processing complex data structures: No modular programming or object-oriented programming elements in the macro language Many modeling procedures are based on data structure rather then operations (hierarchical logit models estimations, counts stations and screen lines)

11 Expressions in Compound Lines and Convolution of Complex Data Structures in Text Strings

12 Output file inode jnode result Complex Data Structures: Example 1 Input file: inode jnode result station code ~

13 ~+;~t1=%%1%%;~t2=%%2%% ~# String of screen lines: %t1% ~# String of stations: %t2% batchout=output m=2.41 ~# Change module parameters ~+;5;n;y;y;n;n;n ~# Input stations codes in tmpl1 ~+;3;tmpl1;*;;~* input file name;n;y ~+;1;n ~# One compound row below till 0: ~+;~?t2=;~$>l;volau*(tmpl1==%%t1.2%%01%%t2.3%%)+; ~t2=%%t2.-3%%;~?!t2=;~$;0 ~+;;!ul1=0;;3 ~:l q batchout=^

14 Main Principles of Convoluting Complex Data Structures for Macro Processing Utilisation of text strings offers great flexibility for reflection of different data structures (hierarchical data, lists, etc.) and different data types (characters as well as numeric data) in emme/2 macros. Utilisation of text substitutions handling of the different data structures with text strings can be efficiently done with text substitutions, especially with text substitutions in text registers. Flow control based on the encoded in a text string data structure text registers with text substitutions can be used as loop counters and / or criteria.

15 Conclusions Ê Complex emme/2 based models can be efficiently encoded entirely in emme/2 software Ë File processing in emme/2 macro language offers additional possibilities to automate complex network or matrix manipulations outside of matrix or network editors Ì Processing of complex data structures (e.g. hierarchical matrix organisations in nested logit models) can be efficiently done by convoluting information about the data structures in text strings and including expressions in compound line loops

16 Acknowledgements Data Management Group INRO Consultants Inc. University of Toronto

Download ppt "EMME/2 Macro Programming With Release 9: Non Trivial Solutions to Trivial Problems Vladimir Livshits University of Toronto."

Similar presentations

Ads by Google