% Program to resolve RWA % User Enters the node information in form of a n*n matrix % n=input('Enter Matrix Information: First Number of nodes '); % m=[]; % m=input('Enter the transmutation matrix '); m=[inf 1 1 1 inf 1 inf 1 1 inf 1 1 inf inf 1 1 1 inf inf inf inf inf 1 inf inf]; n=length(m); n_conn=n-1; %m_conn=input('Enter the fiber connection information as a martix where the matrix values represent represent the number of wavelenghts supported'); m_conn=[1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8]; path_info=zeros(3,2); % path_no=input('Enter the number of paths to be computed') % path_info=input('Enter the paths to be computed') path_no=3; path_info=[1 3 1 5 2 4 ]; cost_tot=0; path_out=[]; path_out=zeros(path_no,n); for i=1:path_no test123=pathonly(path_info(i,1), path_info(i,2), m); testlen=length(test123); cost_tot=cost_tot+costonly(path_info(i,1), path_info(i,2), m); for j=1:testlen path_out(i,j)=test123(j); end end for i=1:path_no for j=1:n if(path_out(i,j)==0) path_out(i,j)=inf; end end end %path_out is the first solution to routing without wavelength assignment % test=matrow(path_out,1) % p=[]; % for i=1:path_no % p(i)=matrow(path_out,i); % end %now to find the number of overlaps and the overlapping shit mo=m; overlap=0; overlap_initial=0; overlap_test=0; path_outO=path_out; %space out matrix for i=path_no:path_no+1 for j=n:n+1 path_out(i,j)=inf; end end % path_out =[1 3 Inf Inf Inf 0 % 1 3 5 Inf Inf 0 % 2 3 5 Inf Inf Inf % 0 0 0 0 Inf Inf]; for i=1:path_no for j=1:n if((path_out(i,j)==path_out(i+1,j))&(path_out(i,j+1)==path_out(i+1,j+1))&(path_out(i,j)~=inf)&(path_out(i,j+1)~=inf)) overlap_test=overlap_test+1; overlap_initial(overlap_test,overlap_test)=i; overlap_initial(overlap_test,overlap_test+1)=j; overlap_initial(overlap_test,overlap_test+2)=i; overlap_initial(overlap_test,overlap_test+3)=j+1; overlap_initial(overlap_test,overlap_test+4)=i+1; overlap_initial(overlap_test,overlap_test+5)=j; overlap_initial(overlap_test,overlap_test+6)=i+1; overlap_initial(overlap_test,overlap_test+7)=j+1; display('We have a overlap at route'); display(path_out(i,j)); display(path_out(i,j+1)); display('Resolving Overlap via alternate route') %Breaking the overlapping link m(path_out(i,j),path_out(i,j+1))=inf; m(path_out(i,j+1),path_out(i,j))=inf; path_test=pathonly(path_out(i,j),path_out(i,j+1),m); %cost_tot=cost_tot+costonly(path_out(i,j),path_out(i,j+1),m); len_test=length(path_test); path_copy=path_out; for k=len_test+1:n path_out(i,k+1)=path_copy(i,k); end for k=1:len_test path_out(i,k)=path_test(k); end end end end for i=1:path_no for j=1:n if((path_out(i,j)==path_out(i+1,j))&(path_out(i,j+1)==path_out(i+1,j+1))&(path_out(i,j)~=inf)&(path_out(i,j+1)~=inf)) overlap=overlap+1; overlap_loc(overlap,overlap)=i; overlap_loc(overlap,overlap+1)=j; overlap_loc(overlap,overlap+2)=i; overlap_loc(overlap,overlap+3)=j+1; overlap_loc(overlap,overlap+4)=i+1; overlap_loc(overlap,overlap+5)=j; overlap_loc(overlap,overlap+6)=i+1; overlap_loc(overlap,overlap+7)=j+1; end end end if(overlap==0) display('All overlaps have been resolved and we have a RWA solution') end if(overlap~=0) for i=1:overlap if(m_conn(path_out(overlap_loc(i),overlap_loc(i+1)),path_out(overlap_loc(i+2),overlap_loc(i+4)))~=1) dispay('Assigning the next smallest wavelength avaliable to the data path to resolve data collision'); m_conn(path_out(overlap_loc(i),overlap_loc(i+1)),path_out(overlap_loc(i+2),overlap_loc(i+4)))=m_conn(path_out(overlap_loc(i),overlap_loc(i+1)),path_out(overlap_loc(i+2),overlap_loc(i+4)))-1; end end for i=1:overlap if(m_conn(path_out(overlap_loc(i),overlap_loc(i+1)),path_out(overlap_loc(i+2),overlap_loc(i+4)))==1) display('Wait till we have the path free as it is a single mode fibre'); end end end