~o=32 ~?!i&32768 ~o|7 / run in silent mode ~$>end_of_copyright ~############################################################################### ~/ DEMADJMC: multiclass demand matrix adjustment (1.15) ~/ ~/ This macro is a generalization of the demadj22.mac macro created ~/ by Heinz Spiess (C) , CH-2558 Aegerten, 1989-99. All rights reserved. ~/ Copyright (C) Yolanda Noriega, INRO, Canada. ~/ All rights reserved. ~/ ~/ The right to use this macro is granted to all Emme 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 software ~/ licence and there is no explicit or implied warranty or support ~/ provided with this macro. ~/ 3) This macro must not be modified without also changing its name. ~/ 4) The comments in this macro must not be removed and any additions or ~/ modification must be appropriately identified as such and give at least ~/ the date, the name and the reason of the modification. ~:end_of_copyright ~x=%0% ~?x>0 ~$>end_of_comments ~/ DEMADJMC (1.15) ~/ ~/ This macro implements a generalization of the gradient method used for the ~/ O-D matrix adjustment to multiple classes of traffic by using observed ~/ volumes (counts) on a subset of links (and optionally turns). Initial O-D ~/ matrices are adjusted to provide a better fit to the observed volumes. ~/ The gradient method is adapted to solve this bi-level minimization problem. ~/ The "steepest descent" property of the gradient approach ensures that ~/ the adjustments of the O-D matrices are minimal. ~# Here is a summary of the computations performed by this macro ~# at each step of the method: ~# - auto assignment to get the link (and turn) volumes 5.11/5.21 ~# - computing link derivatives and objective functions 2.41 ~# - generating scattergram of observed vs predicted volumes 2.43 ~# - path analysis assignment to compute gradient matrix 5.11/5.21 ~# - multiplying gradient matrix with weights (optional) 3.21 ~# - path analysis assignment to assign gradient matrix 5.11/5.21 ~# - computing maximal gradient 3.21 ~# - computing optimal step lengths 2.41 ~# - updating demand matrices and step counter 3.21 ~# As for all matrix adjustment methods, it is extremely important to ensure ~# that the differences between observed and assigned are indeed due to the ~# demand matrices and not a result of coding in the network, inappropriate ~# volume delay functions or wrong counts. Very careful analysis of the network ~# and count data before and after the adjustment is highly recommended! ~# ~# The main differences when compared to demadj22.mac are: ~# Multiclass demand adjustment by using the assignment variant: generalized ~# cost multiclass assignment with path analysis; available since Emme 3. ~# Up to 12 classes to work with simultaneously. ~# The possibility of choosing the type of assignment is no longer supported. ~# The registers t3 to t7 are no longer used to pass parameters to the macro. ~# The user can specify the number of the demand matrix for the first class ~# considered. The rest of the numbers of the matrices to be used are fixed ~# as explained below. ~# The extra attributes used are fixed. ~# Some unnecessary comments have been removed. ~# When zero iterations are required the macro stops after computing the ~# objective function. ~# ~# When using demadjmc.mac: ~# The user can specify the classes to be adjusted. ~# For each class to adjust it is possible to: ~# * Restrict the adjustment to a subset of O-D pairs by specifying an ~# adjustability matrix (contains a value of 1 if the demand of an O-D pair ~# can be adjusted and 0 if it should not be changed). ~# * Consider counts on the turns. ~# * Specify weight factors for the links and for the turns. ~/ ~/ Macro usage: ~/ ~ ~/ ~/ [] ~/ where: ~/ is a single string listing the modes of all the considered classes. ~/ For example: axy. ~/ The number and order of the specified modes should be respected in ~/ the remaining input parameters. ~/ is a single string composed of 1's and 0's, one value ~/ for each mode specified. ~/ A "1" means that a class is to be adjusted, "0" otherwise. ~/ For example: 110 (the third class will not be adjusted). ~/ is the number of iterations for the gradient multiclass adjustment. ~/ is the number of iterations for the multiclass assignment. ~/ is the relative gap stopping criterion used in the assignment. ~/ is the normalized gap stopping criterion used in the assignment. ~/ is the number of the first class demand matrix. The demand ~/ by class must be placed in consecutive matrices - sorted in the same ~/ way as the modes. ~/ (Note: Since the initial contents of these matrices will be overwritten ~/ with the resulting adjusted matrices, it is recommended to first make ~/ a copy of the matrices. These matrices must not be write-protected.) ~/ The subsequent matrices (one for each class) must be reserved to store ~/ the gradients; and the subsequent matrices must be used to store the ~/ adjustability factor (1 if the demand of an O-D pair can be adjusted ~/ and 0 if it should not be changed) for each class, if required. ~/ For example: if there are 3 classes (even if not all the classes will be ~/ adjusted) and the demand of class 1 is stored in the matrix mf20, ~/ then, matrices mf21 and mf22 must contain the demand for classes 2 and 3 ~/ respectively. Matrices mf23, mf24 and mf25 must be reserved for the macro ~/ (the gradient matrices). If classes have adjustability factors, they ~/ will be specified in matrices mf26, mf27 and mf28 for classes 1, 2 and ~/ 3 respectively. Even if not all the classes have adjustability matrices, ~/ this numbering must be respected. ~/ is a single binary string showing which classes have ~/ adjustability factors to apply. "1" if the matrix of factors must be ~/ considered, "0" otherwise. For example: 100 means that only the first ~/ class has an adjustability factor matrix. ~/ is a single binary string showing which classes have ~/ adjustability link factors. "1" if the link factors must be considered, ~/ "0" otherwise. ~/ is a single binary string showing which classes have ~/ counts on the turns. "1" if the counts must be considered, "0" otherwise. ~/ is a single binary string showing which classes have ~/ adjustability turn factors. "1" if the turn factors must be considered, ~/ "0" otherwise. ~/ Scaling factor to avoid output format overflow. ~/ [] Optional argument. If set to "1", the first "half-step" (regular ~/ assignment to compute volumes) is skipped, assuming that the assignment ~/ was already performed; used only when continuing with more steps on the ~/ same adjustment (that is, higher value). ~/ ~/ For instance, "demadjmc.mac ayz 110 5 10 .01 .01 20 110 000 100 000 .001" ~/ means: 3 modes a,y,z; classes 1 and 2 to be adjusted; 5 adjustment ~/ iterations; (10,.01,.01) the stopping criteria for the assignments; ~/ demand class 1 in mf20; classes 1 and 2 have adjustability factor ~/ matrices; no adjustability link factors at all; class 1 has counts ~/ on the turns; no adjustability turn factors at all; scaling factor ~/ is 0.001; start computations from the beginning. ~/ ~# Link and turn storage: ~/ The link counts must be stored in @lco1, ..., @lco12 ~/ The turn counts must be stored in @pco1, ..., @pco12 ~/ The link adjustability factors must be stored in @lwf1, ..., @lwf12 ~/ The turn adjustability factors must be stored in @pwf1, ..., @pwf12 ~/ The link volumes will be stored in: @lvo1, ..., @lvo12 ~/ The turn volumes will be stored in: @pvo1, ..., @pvo12 ~# The auxiliary link attributes are: @ltc1, ..., @ltc12 ~# The auxiliary turn attributes are: @ptc1, ..., @ptc12 ~/ ~/ Be aware that the macro requires many extra attributes (8 for each class) ~/ and that the limit per scenario is 100. It is recommended to run this ~/ macro in a scenario in which the extra attributes table is initialized. ~/ ~# Functions: ~# The set of functions must be read before carrying out the adjustment. ~# ~# Requirements: ~# This macro must be started at the main menu. ~# This macro needs Emme version 3.0 or later. ~# ~# General comments: ~# The step counter (ms90) is initialized at the launching of the program ~# except when is 1. ~# Registers t1, ..., t9; g1, g2, g3, g91, g92, g93; r1, ..., r13, ~# r91, r92 and r93, x, y and z are used during the computations. ~# Relevant information is saved in a file named demadjmc.sum: ~# the list of parameters; the initial and final computation times; ~# the R^2 by class (for the classes being adjusted); the RMSE ~# and the objective function value (the sum of squares of the differences ~# between the observed and the simulated flows, for all the classes being ~# adjusted). ~# A scattergram is produced at each iteration for each class being adjusted. ~# If there are counts on the turns, additional scattergrams are generated. ~# These scattergrams plot the observed versus the simulated flows. ~# The R^2 measure reported in the report file is based on a linear ~# regression *without* a constant term. ~# The RMSE (Root Mean Squared Error) is computed as: ~# Sqrt(Somme(observed-simulated)^2/n) ~# ~# References: ~# demadj22.mac (www.inro.ca/en/download/macros.php) ~# Spiess, H., "A GRADIENT APPROACH FOR THE O-D MATRIX ADJUSTMENT ~# PROBLEM", Publication 693, CRT, University of Montreal, 1990. ~# Noriega, Y., Florian, M. "MULTI-CLASS DEMAND MATRIX ADJUSTMENT", ~# CIRRELT, Montreal, 2007. ~# ~# Warning. The following inputs are not validated: ~# 1. The individual characters of all the binary strings. Depending on the case, ~# sometimes a value of "1" is required to do the computation, sometimes ~# a "0"; values others than "0" and "1" will cause some computations to ~# not be carried out. ~# 2. . It must be 1 to skip the first part of the computations. ~# 3. The O-D values (they must be >=0). ~# ~# Fatal errors occur: ~# - If there is no more room to create a new gradient matrix. ~# - If the link and turn attributes used to store the volumes do not exist ~# already when the option =1 is used (since, in this case, ~# they will not be created by the macro). ~# ~# To improve: ~# Possibility to choose the number of adjustment steps for each class. ~############################################################################### ~$>END ~:end_of_comments ~#get hours, minutes and seconds of current time and test if switch 25 is on ~+;~p=2009;~r7=%%%p%%%;~p=2010;~r8=%%%p%%%;~p=2011;~r9=%%%p%%%;~?!i&33554432 ~+;~x=1;on=25 c=demadjmc/1 %1% %2% %3% %4% %5% %6% c=demadjmc/2 %7% %8% %9% c=demadjmc/3 %10% %11% %12% %13% ~>>demadjmc.sum ~/ demadjmc %1% %2% %3% %4% %5% %6% %7% %8% %9% %10% %11% %12% %13% ~/ Scenario %s%: %ts% ~/ Date: %d% ~/ Initial time: %r7%h%r8%m%r9%s ~>> ~?x=1 off=25 reports=grad-mc.rep batchout=grad-mc.out ~# ##### Input parameters validation ##### ~x=%0% ~?x<11 ~+;~/*** Error: Input parameters missing! ;~/ Usage: ~ ;~/ [];~$>STOP ~?!m=000 ~+;~/*** Error: Macro must be started from the main menu! ;~$>STOP ~#test version of module 5.11 to make sure option 6 is available ~+;5.11;~?v<907 ~+;~/*** Error: Emme version must be 3.0 or later! ;q;~$>STOP q ~t1=%1% ~r1=0 ~+;~r1+1;~t1=%%%t1.-1%%%;~?t1>;~$ ~#r1 contains the number of classes ~?r1>12 ~+;~/*** Error: Too many classes (%1%)! Maximum is 12;~$>STOP ~x=%3% ~?x<0 ~+;~/*** Error: Wrong number of gradient steps (%3%)! must be >=0;~$>STOP ~x=%4% ~?x<0 ~+;~/*** Error: Wrong number of iterations (%4%)! must be >=0;~$>STOP ~x=%5% ~?x<0 ~+;~/*** Error: Wrong value for relative gap (%5%)! must be >=0;~$>STOP ~x=%6% ~?x<0 ~+;~/*** Error: Wrong value for normalized gap (%6%)! must be >=0;~$>STOP ~r2=%12% .001 ~?!r2>0 ~+;~/*** Error: Wrong value for scaling factor (%12%)! must be >0;~$>STOP ~t9=%r2% ~x=0 ~:label-39 ~x+1 ~?x=1 ~+;~t1=%2%;~$>label-40 ~?x=2 ~+;~t1=%8%;~$>label-40 ~?x=3 ~+;~t1=%9%;~$>label-40 ~?x=4 ~+;~t1=%10%;~$>label-40 ~t1=%11% ~:label-40 ~y=0 / the class counter ~+;~y+1;~t1=%%%t1.-1%%%;~?t1>;~$ ~?y=%r1% ~$>label-41 ~?x=1 ~+;~/*** Error: Incomplete list of (%2%)! ;~$>STOP ~?x=2 ~+;~/*** Error: Incomplete list of (%8%)! ;~$>STOP ~?x=3 ~+;~/*** Error: Incomplete list of (%9%)!;~$>STOP ~?x=4 ~+;~/*** Error: Incomplete list of (%10%)! ;~$>STOP ~+;~/*** Error: Incomplete list of (%11%)! ;~$>STOP ~:label-41 ~?x<5 ~$label-39 ~# ##### Matrices validation ##### ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t3=%8% / the adj-factor matrices ~r3=%7% / the first demand matrix ~r3-1 ~r4=%r3% / the gradient matrix ~r4+%r1% ~r5=%r4% / the adj-factor matrix ~r5+%r1% 3.12 ~:label-37 ~y+1 ~r3+1 ~r4+1 ~r5+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% 2 / try to delete the matrix to see if it exists mf%r3% ~?e ~+;' ';q;~/*** Error: Matrix class %y% : mf%r3% missing! ;~$>STOP n ~?t2=0 ~$>label-42 1 / initialize a matrix mf%r4% ~?!e ~+;gr-%y%;gradient matrix class %y% ~?t4=0 ~$>label-42 2 mf%r5% ~?e ~+;' ';q;~/*** Error: Adj-fac-matrix class %y% : mf%r5% missing! ;~$>STOP n ~:label-42 ~?y<%r1% ~$label-37 1 ms90 ~?!e ~+;step;matrix adjustment step counter q ~# ##### Link and turn attribute validation ##### ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t3=%9% / the link weight factor ~t5=%10% / counts on turns ~t7=%11% / the turn weight factor 2.41 ~:label-45 ~y+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% ~+;~t6=%t5.1%;~t5=%t5.-1% ~+;~t8=%t7.1%;~t7=%t7.-1% ~?t2=0 ~$>label-46 ~+|1|n|~g1=0|~g2=0|put(get(1)+(@lco%y%>0))+put(get(2)+(@lco%y%<0))| ~?e ~+|~/*** Error: Link count attribute @lco%y% not defined! ||q|~$>STOP ~+|all|5|~r10=%%%g1%%%|~r11=%%%g2%%%|r ~/ Link counts: @lco%y% contain counts on %r10% links ~?r11>0 ~+|~/*** Error: Class %y%, negative link counts detected! |q|~$>STOP ~?t4=0 ~$>label-47 ~+|1|n|~g1=0|~g2=0|put(get(1)+(@lwf%y%>0))+put(get(2)+(@lwf%y%<0))| ~?e ~+|~/*** Error: Link weight factor attribute @lwf%y% not defined! ||q|~$>STOP ~+|all|5|~r11=%%%g2%%%|r ~?r11>0 ~+|~/*** Error: Class %y%, negative link weight factors detected! |q|~$>STOP ~:label-47 ~?t6=0 ~$>label-46 ~+|1|n|~g1=0|~g2=0|0*tpf+put(get(1)+(@pco%y%>0))+put(get(2)+(@pco%y%<0))| ~?e ~+|~/*** Error: Turn count attribute @pco%y% not defined! ||q|~$>STOP ~+|all|all|5|~r12=%%%g1%%%|~r13=%%%g2%%%|r ~/ Turn counts: @pco%y% contains counts on %r12% turns ~?r13>0 ~+|~/*** Error: Class %y%, negative turn counts detected! |q|~$>STOP ~?t8=0 ~$>label-46 ~+|1|n|~g1=0|~g2=0|0*tpf+put(get(1)+(@pwf%y%>0))+put(get(2)+(@pwf%y%<0))| ~?e ~+|~/*** Error: Turn weight factor attribute @pwf%y% not defined! ||q|~$>STOP ~+|all|all|5|~r13=%%%g2%%%|r ~?r13>0 ~+|~/*** Error: Class %y%, negative turn weight factors detected! |q|~$>STOP ~:label-46 ~?y<%r1% ~$label-45 q / quit module 2.41 ~# ##### Skip the first part ##### ~r6=%13% 0 / Continuing steps ~?r6=1 ~$>CONTINUE STEP ~# ##### Initialization ##### ~+;3.21;1;y;ms90;n;0; ; ;2;q ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t3=%10% / counts on turns 2.42 ~:label-1 ~y+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% 3 @lvo%y% ~?e ~?q=1 y 2 2 ~?e ~+|q|~/*** No space for extra link attribute @lvo%y%! |~$>STOP ~+;@lvo%y%;Link volume class %y%;0 ~?t2=0 ~$>label-22 3 @ltc%y% ~?e ~?q=1 y 2 2 ~?e ~+|q|~/*** No space for extra link attribute @ltc%y%! |~$>STOP ~+;@ltc%y%;Auxiliary link storage class %y%;0 ~?t4=0 ~$>label-22 3 @pvo%y% ~?e ~?q=1 y 2 5 ~?e ~+|q|~/*** No space for extra turn attribute @pvo%y%! |~$>STOP ~+;@pvo%y%;Turn volume class %y%;0 3 @ptc%y% ~?e ~?q=1 y 2 5 ~?e ~+|q|~/*** No space for extra turn attribute @ptc%y%! |~$>STOP ~+;@ptc%y%;Auxiliary turn storage class %y%;0 ~:label-22 ~?y<%r1% ~$label-1 q ~/ ***************************************************************** ~:NEXT STEP ~/ ~/ Gradient step %ms90%: ~/.... Assign demand to get link and turn volumes ~# ##### Prepare multiclass assignment to compute volumes ##### ~y=0 / the class counter ~t1=%1% / the modes ~t3=%10% / counts on turns ~r3=%7% / the first demand matrix ~r3-1 5.11 1 / fixed demand auto assignment ~?q=2 2 / new assignment 6 / type of assignment (multiclass with path analysis) 1 / no additional volumes / no link attribute for analysis ~:label-2 ~y+1 ~r3+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% %t2% / mode class %y% ~?e ~+;' ';q;~/*** Error: Mode "%t2%", class %y%, does not exist! ;~$>STOP / no fixed link costs mf%r3% / demand class %y% / no auto times saved @lvo%y% / link volumes class %y% y / change description link volume class %y% it %ms90% ~?t4=0 / no turn volumes saved ~?t4=1 ~+;@pvo%y%;y;turn volume class %y% it %ms90% / demand to be analyzed for class %y% ~?y<%r1% ~$label-2 ~?y<12 / no more classes ~+;%4%;~?e ~+;~/*** Error: Wrong number of iterations (%4%)!;;;;~$>STOP ~+;%5%;~?e ~+;~/*** Error: Wrong value for relative gap (%5%)!;;;~$>STOP ~+;%6%;~?e ~+;~/*** Error: Wrong value for normalized gap (%6%)!;;~$>STOP ~# ##### Perform assignment to compute volumes ##### 5.21 ~?q=2 2 ~# ##### Compute R^2 (observed vs simulated volumes) ##### ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t3=%10% / counts on turns ~:label-3 ~y+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% ~?t2=0 ~$>label-4 2.41 1 n put(get(1)+%t9%*(@lco%y%>0)*(@lco%y%)*@lvo%y%)+ put(get(2)+%t9%*(@lco%y%>0)*(@lco%y%)*(@lco%y%))+ put(get(3)+%t9%*(@lco%y%>0)*@lvo%y%*@lvo%y%) all 4 ~?t4=0 ~$>label-25 1 n put(get(1)+%t9%*(@pco%y%>0)*(@pco%y%)*@pvo%y%)+ put(get(2)+%t9%*(@pco%y%>0)*(@pco%y%)*(@pco%y%))+ put(get(3)+%t9%*(@pco%y%>0)*@pvo%y%*@pvo%y%) all all 4 ~:label-25 ~r2=%g1% ~r2*%g1% ~r2/%g2% ~r2/%g3% ~>>demadjmc.sum ~/.... R^2 observed vs. simulated volumes for class %y% is %r2.5% ~>> q ~:label-4 ~?y<%r1% ~$label-3 ~# ##### Compute RMSE (observed vs simulated volumes) ##### ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t3=%10% / counts on turns ~:label-53 ~y+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% ~?t2=0 ~$>label-54 2.41 ~+|1|n|put(get(1)+%t9%*(@lco%y%>0))||all|5|~r10=%%%g1%%%|r ~?t4=1 ~+|1|n|put(get(1)+%t9%*(@pco%y%>0))||all|all|5|~r10=%%%g1%%%|r ~g1=0 1 n put(get(1)+%t9%*(@lco%y%>0)*(@lco%y%-@lvo%y%)*(@lco%y%-@lvo%y%)) all 4 ~?t4=0 ~$>label-55 1 n put(get(1)+%t9%*(@pco%y%>0)*(@pco%y%-@pvo%y%)*(@pco%y%-@pvo%y%)) all all 4 ~:label-55 ~r11=%g1% ~r11/%r10% ~+|1|n|~g1=0|get(put(sqrt(%r11%)))||ci=1||4|~r11=%%%g1%%% ~>>demadjmc.sum ~/.... RMSE (Root Mean Squared Error) observed vs. simulated volumes for class %y% is %r11.5% ~>> q ~:label-54 ~?y<%r1% ~$label-53 ~# ##### Compute the gradient ##### ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t3=%9% / the link weight factor ~t5=%10% / counts on turns ~t7=%11% / the turn weight factor ~:label-5 ~y+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% ~+;~t6=%t5.1%;~t5=%t5.-1% ~+;~t8=%t7.1%;~t7=%t7.-1% ~?t2=0 ~$>label-6 2.41 1 y @ltc%y% y link grad - demadj class %y% (it %ms90%) %t9%*(@lco%y%>0)*(@lco%y%-@lvo%y%) ~?t4=1 *(@lwf%y%) all 4 ~?t6=0 ~+;q;~$>label-6 1 y @ptc%y% y turn grad - demadj class %y% (it %ms90%) %t9%*(@pco%y%>0)*(@pco%y%-@pvo%y%) ~?t8=1 *(@pwf%y%) all all 4 q ~:label-6 ~?y<%r1% ~$label-5 ~# ##### Compute the objective function ##### ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t3=%9% / the link weight factor 2.41 1 n put(get(puti(91)) ~:label-7 ~y+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% ~?t2=0 ~$>label-21 +(@lco%y%>0)*(@lco%y%-@lvo%y%)*(@lco%y%-@lvo%y%)*%t9% ~?t4=1 *(@lwf%y%) ~:label-21 ~?y<%r1% ~$label-7 ) all 4 ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t5=%10% / counts on turns ~t7=%11% / the turn weight factor 1 n put(get(puti(91)) ~:label-27 ~y+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t6=%t5.1%;~t5=%t5.-1% ~+;~t8=%t7.1%;~t7=%t7.-1% ~?t2=0 ~$>label-28 ~?t6=0 ~$>label-28 +(@pco%y%>0)*(@pco%y%-@pvo%y%)*(@pco%y%-@pvo%y%)*%t9% ~?t8=1 *(@pwf%y%) ~:label-28 ~?y<%r1% ~$label-27 ) all ~?q=0 all 4 ~r91=%g91% q ~>>demadjmc.sum ~/.... Objective function at step %ms90% is %r91% ~>> ~# ##### Plot scattergrams (observed vs simulated volumes) ##### on=1 ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t3=%10% / counts on turns ~:label-8 ~y+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% ~?t2=0 ~$>label-9 plots=scat-l-%ms90%-%y%.plt ~+;2.43;2;@lco%y%;@lvo%y%;n;~?q=1;n;~?q=1;n;not @lco%y%=0; ;y ~?q>0 ~/No links selected in scattergram ~?q=0 ~+;0;0;~?q=2;2; q ~/.... Link scatterplot written to scat-l-%ms90%-%y%.plt plots=^ ~?t4=0 ~$>label-9 plots=scat-t-%ms90%-%y%.plt ~+;2.43;5;@pco%y%;@pvo%y%;n;~?q=1;n;~?q=1;n;not 0;;not 0;;.00001,99999999;;y ~?q>0 ~/No turns selected in scattergram ~?q=0 ~+;0;0;~?q=2;2; q ~/.... Turn scatterplot written to scat-t-%ms90%-%y%.plt plots=^ ~:label-9 ~?y<%r1% ~$label-8 off=1 ~:CONTINUE STEP ~# ##### Done ? ##### ~x=%3% ~?x=0 ~$STOP ~?x<%ms90% ~$STOP ~y=0 / the class counter ~r3=%7% / the first demand matrix ~r3-1 ~r4=%r3% / the gradient demand matrix ~r4+%r1% ~t1=%2% / the classes to adjust ~t3=%1% / the modes ~t7=%10% / counts on turns ~:label-10 ~y+1 ~r3+1 ~r4+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% ~+;~t8=%t7.1%;~t7=%t7.-1% ~?t2=0 ~$>label-11 ~/.... Compute gradient matrix class %y% ~# ##### Prepare multiclass assignment ##### 5.11 1 / fixed demand auto assignment ~?q=2 2 / new assignment 6 / type of assignment (multiclass with path analysis) 1 / no additional volumes @ltc%y% / link attribute to path analysis ~?!t8=1 / no turn attribute to path analysis ~?t8=1 @ptc%y% / turn attribute to path analysis + / path operator -99999,99999 / threshold 3 / weighted additional path attributes in matrix %t4% / mode first class / no fixed link costs mf%r3% / demand first class / no auto times saved / no link volumes saved / no turn volumes saved / no demand to be analyzed mf%r4% / hold - demand to be analyzed y / change info? gr%y% / name Dem grad class %y% it %ms90% y / initialize 0 / zero / no extra link attribute select link vols / no extra turn attribute select link vols ~x=0 / the aux class counter ~r5=%7% / the demand matrix ~r5-1 ~t5=%1% / the modes ~:label-12 ~x+1 ~?x>%r1% ~+;~x-1;~$>label-13 ~r5+1 ~+;~t6=%t5.1%;~t5=%t5.-1% ~?x=%y% ~$label-12 %t6% / mode / no fixed link costs mf%r5% / demand matrix / no auto times saved / no link volumes saved / no turn volumes saved / no demand to be analyzed / no hold O-D attributes / no extra link attribute select link vols / no extra turn attribute select link vols ~?x<%r1% ~$label-12 ~:label-13 ~?x<12 / no more classes ~+;%4%;%5%;%6% ~# ##### Perform assignment ##### 5.21 ~?q=2 2 ~:label-11 ~?y<%r1% ~$label-10 ~# ##### Multiply gradient matrix with adjustability factor - if applicable ##### ~y=0 / the class counter ~r3=%7% / the first demand matrix ~r3-1 ~r4=%r3% / the gradient matrix ~r4+%r1% ~r5=%r4% / the adj-fac matrix ~r5+%r1% ~t1=%2% / the classes to adjust ~t3=%8% / the adj-factor matrices ~:label-14 ~y+1 ~r4+1 ~r5+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~r3=%t2% ~+;~t2=%t3.1%;~t3=%t3.-1% ~r3*%t2% ~?r3=0 ~$>label-15 3.21 1 y mf%r4% n mf%r4%*mf%r5% / no constraint matrix n / no submatrix ~?q=2 2 q ~:label-15 ~?y<%r1% ~$label-14 ~/.... Assign gradient matrices to obtain volume directions ~y=0 / the class counter ~t1=%1% / the modes ~t3=%2% / the classes to adjust ~t5=%10% / counts on turns ~r3=%7% / the first demand matrix ~r3-1 ~r4=%r3% / the gradient matrix ~r4+%r1% ~# ##### Prepare multiclass assignment ##### 5.11 1 / fixed demand auto assignment ~?q=2 2 / new assignment 6 / type of assignment (multiclass with path analysis) 1 / no additional volumes / no link attribute for analysis ~:label-16 ~y+1 ~r3+1 ~r4+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% ~+;~t6=%t5.1%;~t5=%t5.-1% %t2% / mode class %y% / no fixed link costs mf%r3% / demand class %y% / no auto times saved @lvo%y% / link volumes class %y% y / change description volume class %y% it %ms90% analysis ~?t6=0 / no turn volumes saved ~?t6=1 ~+;@pvo%y%;y;volume class %y% it %ms90% analysis ~?!t4=0 ~+;mf%r4%;@ltc%y%;y;slink volume class %y% it %ms90% ~?t4=0 ~+; ;~# demand to be analyzed for class %y%;~$>label-18 ~?!t6=1 ~+; ;~# no select turn volumes class %y%;~$>label-18 ~?t6=1 ~+;@ptc%y%;~#turn volumes class %y%;y;sturn volume class %y% it %ms90% ~:label-18 ~?y<%r1% ~$label-16 ~?y<12 / no more classes ~+;%4%;%5%;%6% ~# ##### Perform assignment ##### 5.21 ~?q=2 2 ~# ##### Compute maximum gradient ##### ~y=0 / the class counter ~t1=%2% / the classes to adjust ~t3=%9% / the link weight factor ~t5=%10% / counts on turns ~t7=%11% / the turn weight factor ~r3=%7% / the first demand matrix ~r3-1 ~r4=%r3% / the gradient matrix ~r4+%r1% ~:label-19 ~y+1 ~+;~t2=%t1.1%;~t1=%t1.-1% ~+;~t4=%t3.1%;~t3=%t3.-1% ~+;~t6=%t5.1%;~t5=%t5.-1% ~+;~t8=%t7.1%;~t7=%t7.-1% ~r3+1 ~r4+1 ~?t2=0 ~$>label-20 3.21 1 n put(get(puti(92)).max.abs(mf%r4%/mf%r3%)) mf%r3% 0,0,ex n ~+;.max.;.max. ~?q=2 2 ~r92=%g92% q ~/.... Maximum gradient class %y% is %r92% ~?r92=0 ~$>label-17 ~# ##### Compute optimal step length class %y% ##### 2.41 1 n put(get(puti(94))+(@lco%y%>0)*@ltc%y%*@ltc%y%/%r92%) all 4 ~?!t6=0 ~+;1;n;put(get(puti(94))+(@pco%y%>0)*@ptc%y%*@ptc%y%/%r92%);;all;all;4 1 n put(get(puti(93))+(@lco%y%>0)*(@lco%y%-@lvo%y%)*@ltc%y%/get(94) ~?t4=1 *(@lwf%y%) ) all 4 ~?t6=0 ~$>label-36 1 n put(get(puti(93))+(@pco%y%>0)*(@pco%y%-@pvo%y%)*@ptc%y%/get(94) ~?t8=1 *(@pwf%y%) ) all all 4 ~:label-36 ~r93=%g93% q ~/.... Optimal step length class %y% is %r93% ~# ##### Update demand matrix ##### 3.21 1 y mf%r3% y gpq%ms90% Demand class %y% at step %ms90% ~?q=1 n mf%r3%+(%r93%.min.1)*mf%r4%/%r92% ~/.... Update class %y% demand: mf%r3% := mf%r3%+(%r93%.min.1)*mf%r4%/%r92% n ~?q=2 2 q ~$>label-20 ~:label-17 ~/.... Class %y% has reached the optimum; no more iterations on it ~+;~t2=%2%;~z=%y%;~z-1;~t4= ~?!z=0 ~+;~t4=%%%t2.%z%%%% ~+;~t2=%%%t2.-%y%%%%;~t4=%%%t4%%%0%%%t2%%% ~t0=%1% %t4% %3% %4% %5% %6% %7% %8% %9% %10% %11% %12% %13% ~:label-20 ~?y<%r1% ~$label-19 ~# ##### Increment step counter ms90 ##### 3.21 1 y ms90 n ms90+1 ~?q=2 2 q ~$NEXT STEP ~:STOP ~# ##### The end ##### reports=^ batchout=^ ~+;~p=2009;~r7=%%%p%%%;~p=2010;~r8=%%%p%%%;~p=2011;~r9=%%%p%%% ~>>demadjmc.sum ~/ Final time: %r7%h%r8%m%r9%s ~/ ~>> ~############################################################################### ~:END ~o=6