{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Midterm_2012WinterCheng gong

# Midterm_2012WinterCheng gong - 1(1)First I solve the...

This preview shows pages 1–4. Sign up to view the full content.

1. (1)First I solve the traffic assignment problem using Matlab, and write code as follow: %initialization A=[1 0 1 0 0; 0 1 0 0 1;1 0 0 1 1]'; f=[0 0 6000]'; g=zeros(1,2); lb=0; for i=1:100 x=A*f; t1= 1*(1+0.15*(x(1)/2000)^4); t2= 3*(1+0.15*(x(2)/4000)^4); t3= 3*(1+0.15*(x(3)/4000)^4); t4= 0.5*(1+0.15*(x(4)/1000)^4); t5= 1*(1+0.15*(x(5)/2000)^4); t=[t1 t2 t3 t4 t5]; c1=t1+t3; c2=t2+t5; c3=t1+t4+t5; c=[c1 c2 c3]; [m,k]=min(c); if k==1 AN=[A(:,1) A(:,1)]; B=A(:,[2 3]); fnew=f(2:3,:); elseif k==2 AN=[A(:,2) A(:,2)]; B=A(:,[1 3]); fnew=[f(1,:) f(3,:)]'; else k==3 AN=[A(:,3) A(:,3)]; B=A(:,[1 2]); fnew=f(1:2,:); end g=t*(B-AN); %derivative of travel time td1= 1*(0.6*(x(1)^3)/(2000^4)); td2= 3*(0.6*(x(2)^3)/(4000^4)); td3= 3*(0.6*(x(3)^3)/(4000^4)); td4= 0.5*(0.6*(x(4)^3)/(1000^4)); td5= 1*(0.6*(x(5)^3)/(2000^4)); dt=[td1 td2 td3 td4 td5]'; Hdt=diag(dt); H=(B-AN)'*Hdt*(B-AN); f_new=fnew-inv(H)*g'; f_new_(1)=max(0,f_new(1)); f_new_(2)=max(0,f_new(2)); f_new(1)=f_new_(1); f_new(2)=f_new_(2); f_(k)=sum(f)-f_new(1)-f_new(2);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Midterm_2012 Cheng Gong CIV471-1 %update f if k==1 f_=[f_(k) f_new(1) f_new(2)]'; elseif k==2 f_=[f_new(1) f_(k) f_new(2)]'; else k==3 f_=[f_new(1) f_new(2) f_(k)]'; end %convergence z1 = 1*(x(1)+0.03*(x(1)^5)/(2000^4)); z2 = 3*(x(2)+0.03*(x(2)^5)/(4000^4)); z3 = 3*(x(3)+0.03*(x(3)^5)/(4000^4)); z4 = 0.5*(x(4)+0.03*(x(4)^5)/(1000^4)); z5 = 1*(x(5)+0.03*(x(5)^5)/(2000^4)); z=[z1 z2 z3 z4 z5]; x_=A*f_; t_1= 1*(1+0.15*(x_(1)/2000)^4); t_2= 3*(1+0.15*(x_(2)/4000)^4); t_3= 3*(1+0.15*(x_(3)/4000)^4); t_4= 0.5*(1+0.15*(x_(4)/1000)^4); t_5= 1*(1+0.15*(x_(5)/2000)^4); t=[t_1 t_2 t_3 t_4 t_5]; c_1=t_1+t_3; c_2=t_2+t_5; c_3=t_1+t_4+t_5; c_=[c_1 c_2 c_3]; gap=c_*(f-f_); lbnew=sum(z)+gap; if lbnew>lb lb=lbnew; else lb=lb; end u=abs(lb-sum(z))/lb; if u<0.001 break ; end %move f=f_; sum(z) z lb c pause
Midterm_2012 Cheng Gong CIV471-1 end The solution procedure is showed in programming. I will explain it in words. Procedure: 1. Initialization Build the incidence matrix A depends on path 1, 2 and 3. Choose the initialized flow as [0 0 6000]’. Set lower bound to be 0. 2.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 8

Midterm_2012WinterCheng gong - 1(1)First I solve the...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online