~?!i&32768 ~o=295 ~$>end_of_copyright ~/!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ~/Copyright (C) Heinz Spiess, CH-2558 Aegerten, 1999. All rights reserved. ~/ ~/The right to use this macro is granted to all EMME/2 users, provided the ~/following conditions are met: ~/ 1) The macro cannot be sold for a fee (but it can be used and distributed ~/ without charge within consulting projects). ~/ 2) The user is aware that this macro is not a part of the EMME/2 software ~/ licence and there is no explicit or implied warranty or support ~/ provided with this macro. ~/ 3) The comments in this macros must not be removed and any additions or ~/ modification must be appropriately identified as such and give at least ~/ date, name and the reason of the modification. ~/!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ~:end_of_copyright ~/========================================================================= ~/ SEL2LIN 1.1 - Compute transit trips using two subset of transit lines ~/ (Heinz Spiess, EMME/2 Support Center, CH-2558 Aegerten - 99-06-25) ~/ ~/ This macro performs a multi-step transit assignment to computes the ~/ volumes and demand matrix of those trips who use at least one line in ~/ each of two specified transit line subsets. ~/ ~/ Calling sequence: ~/ ~ ~/ where: Transit demand matrix ~/ Transit line selection clause for first set of lines ~/ Transit line selection clause for second set of lines ~/ Resulting active demand matrix, containing trips which ~/ use at least one line of *each* of the two line sets; ~/ must be specified with matrix number, e.g. mf67. ~/ ~/ Notes: ~/ 1) The assignment parameters are contained in text register t1 in the ~/ form of a compound macro statement. They can be set to different ~/ values in the calling macro - otherwise the values coded in this ~/ macro are used. ~/ 2) Two full matrices mf"tmp1" and mf"tmp2" are used to store intermediate ~/ results. If they exist already, their their old contents will be lost. ~/ 3) The transit line extra attribute @s2lxx is for temporary storage ~/ If a extra attribute with the same name exists already, it will ~/ will be erased. ~/ ~/========================================================================== ~x=%0% ~?x<4 ~$>end_of_macro ~# if t1 is empty (i.e no calling macro provided any values), then set ~# t1 to the (Winnipeg) default values ~?t1= ~t1=~+|*|1|1|2.5|1|0.5|2|2|2 ~/ ~+|~/ Demand matrix: %1% %%%%1%.n%%% %%%%1%.d%%% ~/ First line subset: %2% ~/ Second line subset: %3% ~/ Active demand matrix: %4% ~/ Assignment parameters: %t1.-3% ~/ ~#-------------------------------------------------------------------------- ~/ Step 0: Checking if specified line sets are valid 2.41 / Check if first line set is valid ~+|1|n|0*hdw+put(get(1)+1)||%2%|~?e|~#|~?q=0||5 ~/ Set "%2%" contains %g1% transit lines. ~?g1=0 ~+|q|~/ Invalid first line set specification! (%2%)|~$end_of_macro q 2.41 / Check if second line set is valid ~+|1|n|0*hdw+put(get(1)+1)||%3%|~?e|~#|~?q=0||5 ~/ Set "%3%" contains %g1% transit lines. ~?g1=0 ~+|q|~/ Invalid second line set specification! (%3%)|~$end_of_macro q ~/ Create transit line attribute @s2lxx 2.42 / Extra attributes ~?e ~+|~/ Cannot enter module 2.42! (No extra attribute in this data bank?)|q|~$end_of_macro ~+|3|@s2lxx|~?e||~?q=1|y|2|3 ~?e ~+|~/ Cannot create extra attribute @selxx! (Extra attribute table full?)|q|~$end_of_macro ~+|@s2lxx|Tr. line set (sel2lin)||q ~/ Create temporary matrices mf"tmpX" 3.12 / matrix manipulations ~/ Delete temporary matrix mf"tmp1" and/or mf"tmp2" - if any ~+|2|mf"tmp1"|~?e||~?q=1|y ~+|2|mf"tmp2"|~?e||~?q=1|y ~/ Checking if result matrix %4% is valid ~+|3|%4% ~?e ~+|~/ Cannot access matrix %4%!||q|~$end_of_macro ~?q=1 ~+|y|actdem|still empty (sel2lin)|0 ~+|3||still empty (se2lins) ~/ Create temporary matrix mf"tmp1" ~+|1|mf"tmp1" ~?e ~+|~/ Cannot create matrix mf"tmp1"!||q|~$end_of_macro ~+|y|temporary matrix 1 (sel2lin)|0 ~+|1|mf"tmp2" ~?e ~+|~/ Cannot create matrix mf"tmp2"!||q|~$end_of_macro ~+|y|temporary matrix 2 (sel2lin)|0|q ~#-------------------------------------------------------------------------- ~/ Step 1: Compute full transit assignment ~#specify special report file reports=sel2lin.rep 5.11 / Perform basic transit assigment and save assignable demand matrix (ALL) ~+|2|~?q=2|2|%1%||||||| %t1% ~# compute all matrix of all assignable trips ~+|y|@s2lxx||||2|.max.|||mf"tmp1"|~?q=1|y||neg. demand -%1%|~?q=1|y| ~+|5.31|~?q=2|2 3.21 / Matrix computations to compute negative demand matrix ~+|1|y|mf"tmp1"|n ~+|put(0-mf"tmp1")+0*put(get(2)-get(1))+0*put(get(3)+%1%+get(1))|||n|~?q=2|2 ~r1=%g2% ~r5=%g3% ~r6=%r5% ~r6+%r1% q ~/ Total demand: %r6.2_10% trips ~/ Unassignable demand: %r5.2_10% trips ~/ Assignable demand: %r1.2_10% trips ~#-------------------------------------------------------------------------- ~/ Step 2: Subtract trips not using any lines in set "%2%" 2.41 / Network calculation for @s2lxx=1 for "%2%" ~+|1|y|@s2lxx|n|0||all|5|r ~+|1|y|@s2lxx|n|1||%2%||5|q 5.11 / Perform additional options assigment NOTUSE(%2%) ~+|2|~?q=2|1|mf"tmp1"||||||| %t1% ~+|y|@s2lxx||||2|.max.|0,0||mf"tmp2"|~?q=1|n ~+|5.31|~?q=2|2 ~+|3.21|1|y|%4%|y|actdem|'sel2lin: D1-D2'|n ~+|put(mf"tmp2"-mf"tmp1")+0*put(get(2)+get(1))|||n|~?q=2|2 ~r2=%g2% q ~/ Demand for first line set: %r2.2_10% trips (lines "%2%") ~#-------------------------------------------------------------------------- ~/ Step 3: Subtract trips not using any lines in set "%3%" 2.41 / Network calculation for @s2lxx=1 for "%3%" ~+|1|y|@s2lxx|n|0||all|5|r ~+|1|y|@s2lxx|n|1||%3%||5|q 5.11 / Perform additional options assigment NOTUSE(%3%) ~+|2|~?q=2|1|mf"tmp1"||||||| %t1% ~+|y|@s2lxx||||2|.max.|0,0||mf"tmp2"|~?q=1|n ~+|5.31|~?q=2|2 ~+|3.21|1|y|%4%|y|actdem|'sel2lin: D1-D2-D3'|n ~+|%4%+mf"tmp2"+0*put(get(1)-mf"tmp1"+mf"tmp2")|||n|~?q=2|2 ~r3=%g1% q ~/ Demand for second line set: %r3.2_10% trips (lines "%3%") ~#-------------------------------------------------------------------------- ~/ Step 4: Add trips not using any lines in either "%2%" or "%3%" 2.41 / Network calculation for @s2lxx=1 for "%3%" ~+|1|y|@s2lxx|n|0||all|5|r ~+|1|y|@s2lxx|n|1||%2%|%3%||5|q 5.11 / Perform additional options assigment NOTUSE(%2%|%3%) ~+|2|~?q=2|1|%1%||||||| %t1% ~+|y|@s2lxx||||2|.max.|0,0||mf"tmp2"|~?q=1|n ~+|5.31|~?q=2|2 ~+|3.21|1|y|%4%|y|actdem|'demand %2% & %3%'|n ~+|put(%4%+mf"tmp2")+0*put(get(1)+get(2))+0*put(get(3)-mf"tmp1"-mf"tmp2") ~+|||n|~?q=2|2 ~r4=%g3% ~r5=%g2% q ~/ Demand for 1st OR 2nd set: %r4.2_10% trips ~/ Demand for 1st AND 2nd set: %r5.2_10% trips ~+|2.41|1|n|put(get(1)+board)||%2%||all|5|~r7=%%%g1%%%|q ~/ Boardings to first line set: %r7.2_10% boardings to "%2%" ~+|2.41|1|n|put(get(1)+board)||%3%||all|5|~r8=%%%g1%%%|q ~/ Boardings to second line set: %r8.2_10% boardings to "%3%" ~+|2.41|1|n|put(get(1)+volax)||ci=1||5|~r6=%%%g1%%%|q ~/ Active assigned demand: %r6.2_10% trips on connector links ~#-------------------------------------------------------------------------- ~reports=^ ~:done ~/========================================================================= ~/ ~/ Macro SEL2LIN terminated normally. The scenario now contains transit ~/ volumes of those trips who use both line sets "%2%" and "%3%". ~/ The corresponding partial demand matrix is stored in %4% ~/ ~/========================================================================= ~:end_of_macro ~o=6