Update an Arc matrix after the detection of a congestion on the direction d of the ith arc.
[A] = NL_R_ARCCongestionLR(A,I,P,D,T)
ARC matrix.
ARC index.
Modification parameter.
Direction.
Type (multiplicative or additive).
NL_R_ARCCongestionLR updates the ARC matrix A after the detection of a congestion on the direction D of the Ith arc (D=1 congestion on left, D=2 congestion on right, D=0 congestion on left and right). P is the modification parameter. T is the type (0: multiplicative and 1: additive). For a congestion on right, we have pr=pr*p (t=0), or pr=pr-p (t=1). For a congestion on left, pl=pl*p (t=0) or pl=pl-p (t=1). When all the traffic is forwarded to the opposite direction (pr=1 to 0 and pl=0 to 1, and vice versa for an ARC), the cursor location must be changed to the next node of the ARC where an upper ARC is joining. For a congestion on right and left, a notification of congestion to the upper ARCs connected to the ARC I (pl=pr=0.5 for each connected arc).
Ax=[500 465 450 465 500 535 550 535]; Ay=[100 150 200 250 300 250 200 150]; Bx=[400 300 200 250 300 350 400]; By=[100 100 150 175 200 200 200]; Cx=[600 700 800 750 700 650 600]; Cy=[100 100 150 175 200 200 200]; Dx=[175 175 200 225 275 300]; Dy=[225 300 350 400 375 300]; Ex=[350 375 415 450]; Ey=[300 350 400 350]; Fx=[550 600 650 650]; Fy=[350 400 350 300]; Gx=[700 725 750 775 800]; Gy=[300 350 400 350 300]; Hx=[250 275 325 375 400]; Hy=[500 550 600 550 500]; Ix=[650 675 715 750 750]; Iy=[450 550 600 550 450]; Jx=[550 550 575 625 675]; Jy=[450 550 650 700 650]; Kx=[350 400 450 515 575]; Ky=[700 750 800 800 750]; nodx=[Ax Bx Cx Dx Ex Fx Gx Hx Ix Jx Kx]; nody=[Ay By Cy Dy Ey Fy Gy Hy Iy Jy Ky]; heA=[1 2 3 4 5 6 7 8]; taA=[2 3 4 5 6 7 8 1]; heB=[1 9 10 11 12 13 14 15]; taB=[9 10 11 12 13 14 15 3]; heC=[1 16 17 18 19 20 21 22]; taC=[16 17 18 19 20 21 22 7]; heD=[11 23 24 25 26 27 28]; taD=[23 24 25 26 27 28 13]; heE=[14 29 30 31 32]; taE=[29 30 31 32 4]; heF=[6 33 34 35 36]; taF=[33 34 35 36 21]; heG=[20 37 38 39 40 41]; taG=[37 38 39 40 41 18]; heH=[26 42 43 44 45 46]; taH=[42 43 44 45 46 31]; heI=[35 47 48 49 50 51]; taI=[47 48 49 50 51 39]; heJ=[33 52 53 54 55 56]; taJ=[52 53 54 55 56 49]; heK=[44 57 58 59 60 61]; taK=[57 58 59 60 61 55]; he=[heA heB heC heD heE heF heG heH heI heJ heK]; ta=[taA taB taC taD taE taF taG taH taI taJ taK]; n=length(nodx); [gt] = NL_G_MakeGraph('ARC',n,ta,he,nodx,nody); f=NL_G_ShowGraphN(gt,1); marc=zeros(11,30);//11 arcs marc(1,1:length(heA)+1)=[heA taA($)];marc(1,$)=length(heA)+1; marc(2,1:length(heB)+1)=[heB taB($)];marc(2,$)=length(heB)+1; marc(3,1:length(heC)+1)=[heC taC($)];marc(3,$)=length(heC)+1; marc(4,1:length(heD)+1)=[heD taD($)];marc(4,$)=length(heD)+1; marc(5,1:length(heE)+1)=[heE taE($)];marc(5,$)=length(heE)+1; marc(6,1:length(heF)+1)=[heF taF($)];marc(6,$)=length(heF)+1; marc(7,1:length(heG)+1)=[heG taG($)];marc(7,$)=length(heG)+1; marc(8,1:length(heH)+1)=[heH taH($)];marc(8,$)=length(heH)+1; marc(9,1:length(heI)+1)=[heI taI($)];marc(9,$)=length(heI)+1; marc(10,1:length(heJ)+1)=[heJ taJ($)];marc(10,$)=length(heJ)+1; marc(11,1:length(heK)+1)=[heK taK($)];marc(11,$)=length(heK)+1; [cmarc]=NL_R_ARCCursor(marc); [RTARC]=NL_R_ARCRT(cmarc); s=1; [RTARCO]=NL_R_ARCRTInit(RTARC,s);//initial routing table A=[cmarc(:,1:$-1) zeros(lc,2) cmarc(:,$)]; [lc cc]=size(cmarc); A=[cmarc(:,1:$-1) zeros(lc,2) cmarc(:,$)]; for i=1:lc curs=A(i,$-3); direct=RTARCO(curs,3); if (direct==1) then A(i,$-2)=1;//left A(i,$-1)=0;//right else A(i,$-2)=0;//left A(i,$-1)=1;//right end end s1=30;//first source [L1]=NL_R_ARCTrafficNode(A,s1,gt); s2=35;//second source [L2]=NL_R_ARCTrafficNode(A,s2,gt); t1=25; t2=0; T=t1*L1+t2*L2;//total traffic Tmax=100;//maximum throughput dmax=10;//border display Tcong=Tmax/2; t1=Tcong+1; T=t1*L1+t2*L2;//total traffic [go]=NL_R_ARCTrafficPlot(A,T,Tmax,dmax,gt,2);//application of NL_R_ARCTrafficPlot [congarc,dircongarc]=NL_R_ARCCongestionDetect(T,Tcong,A,gt)//application of NL_R_ARCCongestionDetect for j=1:length(congarc) [A]=NL_R_ARCCongestionLR(A,congarc(j),0.1,dircongarc(j),1); end A | ![]() | ![]() |