No BSD License  

Highlights from
MatPlanWDM v0.5

image thumbnail

MatPlanWDM v0.5

by

 

29 Jan 2007 (Updated )

Educational network planning tool for the RWA problem in WDM networks (MILP and heuristic based)

trans_fijsd2flowRoutingMatrix.m
% trans_fijsd2flowRoutingMatrix
% 
%>> Usage: [flowTable flowRoutingMatrix] = ...
%        trans_fijsd2flowRoutingMatrix(f_ijsd, lightpathTable , lightpathRoutingMatrix , phys, traff_trafficMatrix)
%
%>> Abstract: This function converts the "component of traffic flow carried
%   by a given lightpath <i,j> due to a given node pair <s,d>" (variable
%   f_ijsd) into a  "flow routing matrix". We translate the information
%   about the flow routing over the virtual topology from the format used
%   in the MILP fomulation (f_ijsd) into the "netState structure" format
%   of "flow routing matrix" used in the rest of the program.
%
%>> Arguments:
% o  In: 
%  . f_ijsd(NxNxNxN): The component of traffic due to a node pair 
%   <s,d> carried by a lightpath from  node 'i' to node 'j'. An entry 
%   (i,j,s,d) is a real value in units of Gbits per second.
%
%   lightpathTable(L,2): L-by-2 integer matrix. Each row is a lightpath
%    'l', where the first and second columns of each row are the origin
%    node 'i' and destination node 'j' of this lightpath 'l' respectively
%    and L is the number of lightpaths of the virtual topology. 
%
%   lightpathRoutingMatrix (L,M): L-by-M integer matrix where L is the
%    number of lightpaths and M is the number of physical fibre links.
%    Each row is a lightpath 'l' and each column is a physical link 'm'.
%    If a lightpath 'l' uses a physical link 'm' with a certain wavelength
%    'w', the entry (l,m) is equal to 'w'. If no physical link is used by
%    the lightpath 'l', the entry is equal to '0'.
%
%  . phys: Phys Structure. More information about netState in section 
%    "Structure of phys variable" from Help.
%
%
% o Out:
%   flowTable(F,4): F-by-4 real matrix where F is the number of flows.
%    Each row is a flow 'f', where the first column is the serial number of
%    the flow, the second column is the source node 's', the third column
%    is the destination node 'd' and the fourth column is the traffic flow
%    from node 's' to node 'd'.
%
%   flowRoutingMatrix (F,L): F-by-L integer matrix where F is the number
%    of flows and L is the number of lightpaths. Each row is a flow 'f' and
%    each column is a lightpath 'l'. If a flow 'f' uses a lightpath 'l',
%    the entry (f,l) is equal to the part of the flow 'f' carried by the
%    lightpath 'l'. If no lightpath is used by the flow 'f', the entry
%    (f,l) is equal to '0'.
%

function [flowTable flowRoutingMatrix] = trans_fijsd2flowRoutingMatrix(f_ijsd, lightpathTable , lightpathRoutingMatrix , phys, traff_trafficMatrix)

    initializationMILPVariablesScript;

    NUMBERLIGHTPATHS = size (lightpathTable,1);
    MAXIMUMNUMBERFLOWS = N*(N-1);

    flowRoutingMatrix = zeros (MAXIMUMNUMBERFLOWS,NUMBERLIGHTPATHS);
    flowTable = zeros (MAXIMUMNUMBERFLOWS,4); %% (serialNumber , ingress , egress , Gbps)

    sdMap=zeros(N,N);
    counter = 0;
    for s=1:N
        for d=1:N
            if (s == d)
                continue;
            end
            counter=counter+1;
            flowTable(counter,:) = [counter s d 0];
            sdMap(s,d) = counter;
        end
    end
    
    f_ijsd_4D =vect2array(f_ijsd,[N N N N]); % We transform the vector captured from "x" into an array. 

    IDsOfOutgoingLPsFrom = cell(N);
    IDsOfIncomingLPsTo = cell(N);
    for i=1:N,
        IDsOfOutgoingLPsFrom{i} = makeRowVector(find(lightpathTable(:,1)==i));
    end
    for j=1:N,
        IDsOfIncomingLPsTo{j} = makeRowVector(find(lightpathTable(:,2)==j));
    end
   
    totalFlowInLpAggregate = zeros (N,N);
    for i=1:N,
        for j=1:N,
            if (i == j)
                continue;
            end
            
            IDsOfLPsFromItoJ= makeRowVector(intersect(IDsOfOutgoingLPsFrom{i}, IDsOfIncomingLPsTo{j}));
            nrLightpathsFromItoJ=numel(IDsOfLPsFromItoJ);
            
            if (nrLightpathsFromItoJ == 0)
                continue;
            end
                        
            lpAggregateRoutingInfo(:,:) = f_ijsd_4D(i,j,:,:);
            totalFlowInLpAggregate(i,j) = sum(sum (lpAggregateRoutingInfo));
            maximumLoadOfIJLp = totalFlowInLpAggregate(i,j)/nrLightpathsFromItoJ;
                
            for lp = IDsOfLPsFromItoJ,
                totalFlowInThisLP = 0;

                for s = 1:N
                    for d = 1:N
                        if (s == d)
                            continue;
                        end
                        
                        if f_ijsd_4D(i,j,s,d)==0,
                            continue;
                        end
                        
                        if (totalFlowInThisLP + f_ijsd_4D(i,j,s,d)) <= maximumLoadOfIJLp,
                            totalFlowInThisLP = totalFlowInThisLP + f_ijsd_4D(i,j,s,d);
                            flowRoutingMatrix(sdMap(s,d), lp) = f_ijsd_4D(i,j,s,d);
                            f_ijsd_4D(i,j,s,d)=0;
                        else 
                            remainingCapacityToAssign = maximumLoadOfIJLp - totalFlowInThisLP;
                            totalFlowInThisLP = totalFlowInThisLP + remainingCapacityToAssign;
                            flowRoutingMatrix(sdMap(s,d), lp) = remainingCapacityToAssign;
                            f_ijsd_4D(i,j,s,d) = f_ijsd_4D(i,j,s,d) - remainingCapacityToAssign; 
                        end
                        
                        if  s==i,
                            flowTable(sdMap(s,d),4) = flowTable(sdMap(s,d),4) + traff_trafficMatrix(s,d);
                        end
                        
                    end
                end
            end
        end
    end
    
end


Contact us