You are on page 1of 20

ClassProject#2

ATrafficAssignmentAssessment:
TheAnaheimTrafficNetwork

NicholasLinesch
njlinesch@ucdavis.edu

ECI257
Winter2006

Linesch1

TableofContents:
1. ExecutiveSummary............................................... Page2
2. ObjectiveandOverview......................................... Page3
3. DescriptionofFrankWolfeAlgorithm.................. Page5
datacollected
methodsused
4. Results.................................................................... Page7
5. Figures....................................................................Page10
6. References............................................................. Page12
7. Code....................................................................... Page13

Linesch2

1. ExecutiveSummary
ThisreportisananalysisoftheAnaheimtrafficnetworkandagroupoforigindestination(OD)pairs.
With38nodesthatareoriginsanddestinationswehave38x37ODpairsinthenetworkor1406ODpairs.
Eachofthesepairshasacertaindemandallocatedtoitwhichwewillbeevaluatingbasedontheuser
equilibrium(UE)aswellasthesystemoptimal(SO).Theusersofasystemwillwanttooptimizetheir
owncosts,whichisevaluatedusingtheuserequilibriumfunctionanalysis.ThiscontrastswiththeSO
analysiswhichoptimizesthetotaltraveltimeofthesystem,ratherthantheindividualtraveltimes.Using
twodifferentlinkperformancefunctionsweseethattheBPRworkswellwithFrankWolfealthough
Davidson'sdoesnot,basedonthisobservationwedecidetoanalyzethesystemusingtheBPRlink
performancefunction.

MatlabcodewasdevelopedtoimplementtheshortestpathalgorithmwhichiscalledbyFrankWolfe
whencalculatingtheUserEquilibriumandtheSystemOptimalsituationsofthenetwork.Anassignment
functioncontainsDijkstra'sshortestpathalgorithmwhichiscalledwithinaloopintheFrankWolfe
algorithm.TheobjectivefunctionwithinFrankWolfeismodifiedinordertoacheiveSOorUEtotal
traveltimes.

Linesch3

2. ObjectiveandOverview
Themainobjectiveistounderstandthedifferencesbetweenoptimizingatrafficnetworkbasedon
differentobjectivefunctions.Inthecaseoftheuserequilibriumweuseanobjectivefunctionthatgets
slightlymodifiedtobecomeasystemoptimalproblem.
Functionsthatareinvolvedinthisparticularoptimizationproblemare:
allornothingassignment
FrankWolfe
Dijkstra'sAlgorithm
Theuserequilibriumproblemmodelstrafficbehaviormoreaccuratelythanthetheoreticalsystemoptimal
answerwecangettosolvingatrafficproblem.Asusersgettoknowatrafficnetworktheywillchoose
theroutethattheyknowwillminimizetheirtraveltime;wecansafelysaythatusersofanetworkwillnot
choosearoutebasedonweatherornottheywilloptimizethetotalsystemtraveltimebecausetheywill
notbeabletocomputetheseroutechoicesintheirheadorbewillingtogooutoftheirwayforthe
bettermentofothers.Wefindthatuserswhoknowasystemcanoptimizetheirtraveltimebytakingless
congestedroutes,resultinginsomethingclosertotheUEthantheSO.ThestudyofaSOofanetwork
canhelpusunderstandhowtobuildnetworksefficientlysothatthenaturaltendencyofthenetworkleans
towardoptimizingthetotalsystemtime,althoughasdemandchangesoverdecades,itishardtoplanfor
systemoptimality.

Linesch4

3. DescriptionofFrankWolfeAlgorithm

TheexperimenttofindtheuserequilibriumtrafficflowontheAnaheimnetworkinvolvesfindingthe
shortestpathbetweeneachODpairandthenallocatingthetrafficdemandtothosepaths.Oncethe
demandisplaceduponeachlinkthatmakesupthepathofthenetworktheflowsareupdatedasthecost
foreachlinkhaschanged(thelinkswithmoreflowplaceduponthembecomemorecostly).Thisprocess
continuestoupdateovermanyiterationsuntiltheoptimalflowpatternisreached.
FortheUEassessmentweutilizethefollowingBPRlinkperformancefunction:

t a = t 1 + a , = 0.15 , = 4, ca = 0.9ca
ca

0
a

Thisfunctionwillbeusedtocomputethelinkflowasweallocatetraffictoeachofthearcsinvolvedin
thetrafficnetwork.Thegeneralstepsofthealgorithmareasfollows:
1.
2.
3.
4.
5.
6.
7.

Importthenetwork
InitializethetraveltimesandfindtheshortestpathforallODpairs
Updatethetravelcostsforeachlinkinthenetwork
Findtheauxiliaryflowbasedonthenewtravelcosts
Usethelinesearchtofindanalphawhichtellstheprogramhowfartomove
Updatelinkflowandcost
Testforconvergenceandrepeat

AlsotheDavidsonlinkperformancefunctioncanbeused:

x a
t a = ta0 1 + J
, J = 0.25

ca x a
WewillexperimentwiththislinkperformancefunctionandhowitcompareswithBPRfunction.
Variablesthatwillbeimportedwillbe
A(Listoflinknumbersoutofconsecutivenodes)
B(Listoflinknumbersintoconsecutivenodes)
Odnodes(Listofnodesthatareorigins/destinations)
capacity(arrayofcapacityforeachlink)
demand(arrayofdemandforeachODpair)
lastnode
firstnode(firstlinkoutofeachorigin)
m(numberofnodes)
n(numberofarcs)
t0(Freeflowtraveltimeforeacharc)
Linesch5

TheSOcomputationusesasimilarfunctionastheUEcomputationalthoughthedifferenceisthatthe
costfunctiont(a)istransformedtooptimizethesystemcostratherthantheindividualusercost.

TheoptimizationoftheobjectivefunctionZwillbeatoolforallocatingflowtoeachofthelinksonthe
pathsbetweentheODpairsinordertofindtheUEandtheSOtrafficpatternsandtraveltimesofthe
systems.ThelinearprogramissolvedusingthetechniquesoftheFrankWolfealgorithmasimplemented
inthematlabcode.TheobjectivefunctionismodifiedfromUEtoSO.

Linesch6

Results:

Thecodeforthematlabalgorithmsusesthefollowingcommandstorun,withtheresultsfromtheAfter
runningthevariousalgorithmstotestforconvergencewehavefoundthefollowinginformation:
UE(A,B,ODnodes,capacity,demand,lastnode,firstnode,m,n,t0)
Max_Velocity_Capacity=
1.9401
Average_Velocity_Capacity=
0.3011
User_Equilibrium_Total_Travel_Time=
1.3278e+06
SO(A,B,ODnodes,capacity,demand,lastnode,firstnode,m,n,t0)
Max_Velocity_Capacity=
1.6686
Average_Velocity_Capacity=
0.2960
System_Optimal_Total_Travel_Time=
1.3038e+06
UE

SO

TotalTravelTime

1.3278e+06seconds

1.3038e+06seconds

Velocity/CapacityRatio(avg)

0.3011

0.2960

Velocity/CapacityRatio(max)

1.9401

1.6686

Wefindoutfromananalysisofcongestednodes(velocity/capacityratio>1.25)thatthefollowingnodes
arecongestedintheUEproblem:
congested_nodes=
5464508531566642692693695729784794795911
Linesch7

Ifwerunthealgorithmagainwiththesenodeswithincreasedcapacity(+25%)wefindthefollowing
result:
Max_Velocity_Capacity=
1.6948
Average_Velocity_Capacity=
0.2977
User_Equilibrium_Total_Travel_Time=
1.2901e+06
Witha100%increaseincapacityonthecongestedlinksweseethatthetotaltraveltimefortheUE
networkgoesfrom1.3278e+06secondsto1.2540e+06seconds,a6%decreaseintotaltraveltime.In
Figure1weobservefiftyrandomlinksonthenetworkandtheirvelocity/capacityratioswhentheoriginal
datawastakencomparedtothenewvelocity/capacityratiosafterthecongestedlinksareimproved.We
canseethethatthemajorityoftheratiosgoup,whilesomestayconstantandsomedrop.

TTT=TotalTravelTime(seconds)
UE

SO

TTT(original)

1.3278e+06

1.3038e+06

TTT(25%ImprovedCapacityoncongestednodes)

1.2901e+06

1.3009e+06

TTT(50%ImprovedCapacityoncongestednodes)

1.2692e+06

1.3021e+06

TTT(75%ImprovedCapacityoncongestednodes)

1.2618e+06

1.3012e+06

TTT(100%ImprovedCapacityoncongestednodes)

1.2540e+06

1.3014e+06

Figure2givesaplotofthetableabove,showingthattheincreasedcapacityforlinkswitha
velocity/capacityratiohigherthan1.25byavarietyofpercentageshelpedthetotaltraveltimeonlyforthe
UEsystem,buthadlittleeffectontheSO.TheUserEquilibriumquicklybecamefasterwithanumberof
nodesoperatingatincreasedcapacity.
Figure3showsacomparisonofhowtheimprovedcapacitysystembehavesinaUEenvironmentversusa
SOenvironment.Weobservethechangeofthevelocitycapacityratiosbetweentheoriginalsystemand
Linesch8

theimprovedcapacitysystemforbothcases(UEandSO)andplottheabsolutevalueofthedifference.
FromthisgraphwecanseethattherearemuchgreaterdifferencesintheseratiosintheUEsystemwhere
asthedifferenceintheSOsystemwasrelativelyslight.
IfwemodifytheperformancefunctionanduseDavidsonslinkperformancefunction:

x a
t a = ta0 1 + J
, J = 0.25

ca x a
wecanseethatthesystemdoesnotconverge.Davidson'slinkperformancefunctionusesthedifference
betweenthecapacitiesandtheflowswhichcanmaketheupdatedflowsnegative.Thefactthattheflows
wouldbeseenasnegativeintheDavidsonfunctionwouldnotbeunderstoodbyDijkstra'salgorithmwhen
findingtheshortestpathbetweentwonodes.Thiscontributestotheproblemofalackofconvergencein
theUEandtheSOwhenusingDavidson'slinkperformancefunctiontofindthetotaltraveltimes.

Linesch9

ListofFigures
Figure1.

Figure2.

Linesch10

Figure3.

Linesch11

Code:
UserEquilibriumFunction:
%Nicholas Linesch
%ECI 257 Project 2

function [vcratio]=UE (A,B,ODnodes,capacity,demand,lastnode,firstnode,m,n,t0)


ALPHA=.15
BETA=4

%Following for loop used to increase capacity on given nodes


congested_nodes=[54
64
508
531
566
642
692
693
695
794
795
911];
for(i=1:14)
capacity(congested_nodes(i))=capacity(congested_nodes(i))*1;
end
%
%

729

784

Frank Wolf Algorithm


Solves for the User Equilibrium of a traffic network

% the
%
%
%
%

following are the inputs to run the algorithm.


free flow travel times (t0)
corresponding capacities (ca).
the number of links (n)
the number of nodes (m)

%First step is to import the road network and travel demand information
%we don't want the roads to ever be at full capacity so we take 90% of the
%total capacity.
capacity1=.9*capacity;
%Next step is to initialize ta=ta(0) and find the shortest path between all
%O-D Pairs
ta=t0;
x=assignment(ta,A,B,lastnode,m,ODnodes,firstnode,demand);
%calculates the shortest path using the method of "all or nothing"
%x will be a list of the flows along a path
bin=0;
count=1;

Linesch12

while(bin==0) && (count<1000)


y=zeros(n,1); %initialize aux flow
for(i=1:n)
ta(i)=t0(i)*(1+ALPHA*((x(i)/capacity1(i))^BETA)); %computes the latest link
flow pattern that results from the frank wolf algorithm assignment of the OD pairs
in the previous origin
end
y=assignment(ta,A,B,lastnode,m,ODnodes,firstnode,demand);
direction=y-x;
%line search tells how far to move, or the step size that we will need
%to use
alpha=UElinesearch(ta,n,x,y,capacity);
xnew=x+alpha*direction;
xdirec=xnew-x;
difference=(sum(xdirec.^2))/(sum(x));
if(difference<0.00001)
bin=1;
end

end

x=xnew; %this line updates x


count=count+1;

linkflow=x;
for(i=1:n)
TotalTravelTime(i)=t0(i)*(1+0.15*((x(i)/capacity1(i))^4));
end
size(x);
size(capacity);
Velocity_Capacity_Ratio=x./capacity;
vcratio=Velocity_Capacity_Ratio;
%congested_nodes=[];
%for(i=1:914)
%
if Velocity_Capacity_Ratio(i)>1.25
%
congested_nodes=[congested_nodes,i];
%
end
%end
%hist(Velocity_Capacity_Ratio)
%congested_nodes
Max_Velocity_Capacity=max(Velocity_Capacity_Ratio)
Average_Velocity_Capacity=mean(Velocity_Capacity_Ratio)
User_Equilibrium_Total_Travel_Time=sum(linkflow.*TotalTravelTime)

Linesch13

SystemOptimalFunction:
%Nicholas Linesch
%ECI 257 Project 2

function [vcratio]=SO (A,B,ODnodes,capacity,demand,lastnode,firstnode,m,n,t0)


ALPHA=.15
BETA=4
tic

%
%

Frank Wolf Algorithm


Solves for the User Equilibrium of a trafffic network

% the
%
%
%
%

following are the inputs to run the algorithm.


free flow travel times (t0)
corresponding capacities (ca).
the number of links (n)
the number of nodes (m)

%First step is to import the road network and travel demand information

%we don't want the roads to ever be at full capacity so we take 90% of the
%total capacity.
congested_nodes=[54
64
508
531
566
642
692
693
695
794
795
911];
for(i=1:14)
capacity(congested_nodes(i))=capacity(congested_nodes(i))*1;
end
capacity1=.9*capacity;

729

784

%Next step is to initialize ta=ta(0) and find the shortest path between all
%O-D Pairs
ta=t0;
x=assignment(ta,A,B,lastnode,m,ODnodes,firstnode,demand);
%calculates the shorest path using the method of "all or nothing"
%x will be a list of the flows along a path
bin=0;
count=1;
while(bin==0) && (count<1000)

Linesch14

y=zeros(n,1);

%initialize aux flow

for(i=1:n)
ta(i)=t0(i)*(1+(1+BETA)*ALPHA*((x(i)/capacity1(i))^BETA)); %computes the
latest link flow pattern that results from the frank wolf algorithm assignment of
the OD pairs in the previous origin
end
%y=assignment3(ta,A,B);%(ta,A,B,m,n,lastnode,demand,firstnode);
%
%compute aux flows
y=assignment(ta,A,B,lastnode,m,ODnodes,firstnode,demand);
direction=y-x;
alpha=SOlinesearch(ta,n,x,y,capacity); %using the line search we find the
appropriate step size to use
xnew=x+alpha*direction;
xdirec=xnew-x;
difference=(sum(xdirec.^2))/(sum(x));
if(difference<0.00001)
bin=1;
end
x=xnew; %this line updates x
count=count+1;
end
linkflow=x;
for(i=1:n)
TotalTravelTime(i)=t0(i)*(1+ALPHA*((x(i)/capacity1(i))^BETA));
end
size(x);
size(capacity);
Velocity_Capacity_Ratio=x./capacity;
vcratio=Velocity_Capacity_Ratio;
%congested_nodes=[];
%for(i=1:914)
%
if Velocity_Capacity_Ratio(i)>1.25
%
congested_nodes=[congested_nodes,i];
%
end
%end
%hist(Velocity_Capacity_Ratio)
%congested_nodes
Max_Velocity_Capacity=max(Velocity_Capacity_Ratio)
Average_Velocity_Capacity=mean(Velocity_Capacity_Ratio)
System_Optimal_Total_Travel_Time=sum(linkflow.*TotalTravelTime)

Linesch15

AssignmentFunction:
function Flow=assignment(ta,A,B,lastnode,m,ODnodes,firstnode,demand)
%The first part of this section will solve for the shortest path from each
%origin to the respective destinations
flow=zeros(914,38);
%This for loop runs through ever possible origin
for(root=379:416)
closed=[root];
% start with just the root node as closed
open=[1:m];
% all of the other nodes are open to start off with
open(root)=[];
% now take the root node out of the list of open nodes.
%initially the distances are all set to infinity and the p's are all set=
%to the root
d=inf*ones(1,m);
d(root)=0; %setting the distance label of root node to 0
p=root*ones(1,m);
p(root)=root;

%now we apply the Dijkstra algorithm to find the shortest path, adding
%nodes to the closed node list as we explore all of their paths and then
%scanning to new open nodes to look for the shortest path through the
%network
%this next while loop is the main step for the shortest path algorithm
while(length(open)>0)
i=length(closed);
j=closed(i);

for(k=A(j):B(j))
if(d(lastnode(k))>=d(j)+length(k))
d(lastnode(k))= d(j)+ta(k);
p(lastnode(k))=j;
end
end
min=d(open(1));
jbar=1;
for(i=1:length(open))

Linesch16

if(d(open(i))<min)
min=d(open(i));
jbar=i;
end
end
closed=[closed,open(jbar)];
open(jbar)=[];
end
i=1;
while(i<39)
%if the root is mapping to itself, do nothing
if(root==ODnodes(i));
0;
%otherwise the flow along the shortest path for the particular
%OD-pair needs to be updated in the flow matrix
else
%starting from the first node in the list of ODnodes we
%backtrack along the path and calculate the flow as we go
predecesor=ODnodes(i);
y=1;
path=root;
while(predecesor~=root)
path(y)=p(predecesor);
predecesor=p(predecesor);
y=y+1;
end
path=[ODnodes(i),path];
%calculate the shortest path from the root
to the destination
for(j=2:length(path))
%searchlinks spans all of the links that come out of
%node j on the path
searchlinks=A(path(j)):1:B(path(j));
linknumber=A(path(j))-1+find(lastnode(searchlinks)==path(j-1));
NodeNumber=ODnodes(i)-378;
ROOT=root-378;
%load each link in the shortest path
q=firstnode(ROOT)+(NodeNumber-1);
flow(linknumber,ROOT)=flow(linknumber,ROOT)+demand(q);
end %ends the inner for loop
end %ends the if loop
i=i+1;
end %ends the while loop

end
for i=1:914
Flow(i)=sum(flow(i,:)); %sums the flow along each link and returns the value to
the main function
end

Linesch17

Line Search Function(UE):


function alpha=UElinesearch(t0,n,x,y,capasity)
ALPHA=.15
BETA=4
capasity1=capasity*.9;
%The initial interval we look at is (a,b)=(0,1)
a=0
b=1;
%while the interval length is less than .0001 we will narrow in on the
%desired point
r=(5^(1/2)-1)/2;
while(abs(a-b)>.00001)
alphaleft=a+(1-r)*(b-a);
alpharight=a+r*(b-a);
%now we need to calclulate the objective function for each alpha
%first calculate for the left
zalphaleft=0;
dleft=x+alphaleft*(y-x);
dleft1=dleft./capasity1;
for(i=1:n)
zalphaleft(i)=t0(i)*dleft(i)*(1+ALPHA*(dleft1(i)^BETA));
end
zalphaleft=sum(zalphaleft);
%calculate for the right
zalpharight=0;
dright=x+alpharight*(y-x);
dright1=dright./capasity1;
for(i=1:n)
zalpharight(i)=t0(i)*dright(i)*(1+ALPHA*(dright1(i)^4));
end
zalpharight=sum(zalpharight);
%The line search now chooses the next interval to be used.
if(zalphaleft<=zalpharight)
b=alpharight;
else
a=alphaleft;
end

end
alpha=(a+b)/2;

Linesch18

Line Search Function(SO):


function alpha=SOlinesearch(ta,n,x,y,capacity)
ALPHA=.15;
BETA=4;
capacity1=capacity*.9;
%The initial interval we look at is (a,b)=(0,1)
a=0;
b=1;
%while the interval length is less than .0001 we will narrow in on the
%desired point
r=(5^(1/2)-1)/2;
while(abs(a-b)>.00001)
alphaleft=a+(1-r)*(b-a);
alpharight=a+r*(b-a);
%now we need to calclulate the objective function for each alpha
%first calculate for the left
zalphaleft=0;
dleft=x+alphaleft*(y-x);
dleft1=dleft./capacity1;
for(i=1:n)
zalphaleft(i)=ta(i)*dleft(i)*(1+ALPHA*(1+BETA)*(dleft1(i)^4));
end
zalphaleft=sum(zalphaleft);
%calculate for the right
zalpharight=0;
dright=x+alpharight*(y-x);
dright1=dright./capacity1;
for(i=1:n)
zalpharight(i)=ta(i)*dright(i)*(1+ALPHA*(1+BETA)*(dright1(i)^4));
end
zalpharight=sum(zalpharight);
%The line search now chooses the next interval to be used.
if(zalphaleft<=zalpharight)
b=alpharight;
else
a=alphaleft;
end

end
alpha=(a+b)/2;

Linesch19

i.R.Jayakrishnan,WeiK.Tsai.EventbasedATIS:PracticalImplementationandEvaluationofOptimizedStrategies
UniversityoCalifornia,Irvine.CaliforniaPATHResearchReport.UCBITSPRR20011

You might also like