MATLAB WDM PROBLEM ERROR

10 visualizzazioni (ultimi 30 giorni)
Rahul Kudgi
Rahul Kudgi il 9 Apr 2017
FOR SCREENSHOTS I AM POVIDING HDLA ALGORITHM function [exitFlag lightpathTable lightpathRoutingMatrix numberOfOccupiedTWCs numberOfOccupiedTxs numberOfOccupiedRxs] = libraryVTD_HLDA(traff_trafficMatrix, phys)
%MAIN VARIABLES*********************************************************
exitFlag=0;
numberOfNodes = phys.N; numberOfLinks = phys.M;
lightpathTable=[]; lightpathRoutingMatrix=[]; numberOfOccupiedTxs = zeros (numberOfNodes,1); numberOfOccupiedRxs = zeros (numberOfNodes,1); numberOfOccupiedTWCs = zeros (numberOfNodes,1); % does not change as this is a non-wavelength-converting heuristic
%"freeWavelengths" is a matrix, where rows are each link %((1,1)(2,1)(3,1)(4,1)(1,2)(2,2)...) and columns are a specifical %wavelength: w0, w1, w2... Each value is 0 or 1 if that is free freeWavelengths=zeros(numberOfLinks,max(phys.numberWavelengthPerFiber)); for i=1:numberOfLinks, freeWavelengths(i,1:phys.numberWavelengthPerFiber(i))=1; end
%total number of node pairs whose traffic must be considered numberOfNodePairsToBeConsidered = length(traff_trafficMatrix)^2-... sum(sum(traff_trafficMatrix==zeros(length(traff_trafficMatrix),length(traff_trafficMatrix))));
iteration=1;
%ALGORITHM DEVELOPMENT*********************************************
numberOfLightpaths=0; consideredNodePairs=[];
%Main loop. It works along such iterations as possible traffics to route while size(consideredNodePairs,1) < numberOfNodePairsToBeConsidered
%First maximum traffic value
%at first, we find the maximum traffic value. It is avoid two equal
%maximums, we take the first one.
maximumTraffic=max(max(traff_trafficMatrix));
[aux1,aux2]=find(traff_trafficMatrix==max(max(traff_trafficMatrix)));
source(iteration)=aux1(1);
destination(iteration)=aux2(1);
if(isempty(intersect(consideredNodePairs,[source(iteration) destination(iteration)],'rows')))
consideredNodePairs=[consideredNodePairs;[source(iteration) destination(iteration)]];
end
%FIRST CONDITION: A TRANSMITER IN SOURCE NODE AND A RECEIVER IN DESTINATION NODE
if(numberOfOccupiedRxs(destination(iteration))<phys.numberRxPerNode(destination(iteration)) &&...
numberOfOccupiedTxs(source(iteration))<phys.numberTxPerNode(source(iteration))),
%SECOND CONDITION: FIND A physical ROUTE BETWEEN SOURCE AND DESTINATION
linkTable=[phys.linkTable ones(numberOfLinks,1)];
[sequenceOfSPFLinkIds, sequenceOfSPFNodeIds, totalCost] = ...
libraryGraph_shortestPath (linkTable, source(iteration), destination(iteration));
%THIRD CONDITION: IT'S NECESSARY THE SAME WAVELENGTH IN ALL physical ROUTE
%A matrix such "freeWavelengths" is built. It only contains the links of
%the physical route. Now we can check which of them are availables to be used.
freeWavelengthsOnRoute = freeWavelengths(sequenceOfSPFLinkIds,:);
usedWavelength=0;
for i=1:size(freeWavelengthsOnRoute,2)%we check all wavelengths
%The column with all-ones is the used as wavelength
if(freeWavelengthsOnRoute(:,i)==ones(size(freeWavelengthsOnRoute,1),1)),
usedWavelength=i;%the wavelength is established
%trasmitters and receivers are updated in source and destination nodes
numberOfOccupiedTxs(source(iteration))=numberOfOccupiedTxs(source(iteration))+1;
numberOfOccupiedRxs(destination(iteration))=numberOfOccupiedRxs(destination(iteration))+1;
%freeWavelengths is updated when the used wavelength which is occupied (0)
freeWavelengths(sequenceOfSPFLinkIds,usedWavelength)=0;
%virtualTopology is updated with the new lightpath
serialNumberOfLightpath=size(lightpathTable,1)+1;
lightpathTable=[lightpathTable; [serialNumberOfLightpath source(iteration) destination(iteration)]];
currentLightpathRouting=zeros(1,numberOfLinks);
currentLightpathRouting(sequenceOfSPFLinkIds)=usedWavelength;
lightpathRoutingMatrix=[lightpathRoutingMatrix; currentLightpathRouting];
numberOfLightpaths=numberOfLightpaths+1;
%traff_trafficMatrix is updated
%we are going to search the second maximum value at traffic
%matrix
traff_trafficMatrix(source(iteration),destination(iteration))=0;
[aux1,aux2]=find(traff_trafficMatrix==max(max(traff_trafficMatrix)));
sourceOfSecond=aux1(1);
destinationOfSecond=aux2(1);
traff_trafficMatrix(source(iteration),destination(iteration))=maximumTraffic;%we complete the original matrix again
if traff_trafficMatrix(source(iteration),destination(iteration))>0,
traff_trafficMatrix(source(iteration),destination(iteration))=...
traff_trafficMatrix(source(iteration),destination(iteration))-traff_trafficMatrix(sourceOfSecond,destinationOfSecond);
end
break%we don't continue checking wavelengths when a successful one has been found
end
end
%Condition of used wavelength
if usedWavelength==0 %There is not avalaible wavelength for the selected physical route;
%traff_trafficMatrix updating
traff_trafficMatrix(source(iteration),destination(iteration))=0;
end
else %There is not available transmitters or receivers at node pair
%traff_trafficMatrix updating
traff_trafficMatrix(source(iteration),destination(iteration))=0;
end
iteration=iteration+1;
end%End of the main loop
if isempty(lightpathTable) isempty(lightpathRoutingMatrix), exitFlag = 1; end % there is no sufficient resources to establish any lightpath.

Risposte (0)

Categorie

Scopri di più su Software Development Tools in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by