No BSD License  

Highlights from
MatPlanWDM v0.5

image thumbnail
from MatPlanWDM v0.5 by Pablo Pavon MariƱo
Educational network planning tool for the RWA problem in WDM networks (MILP and heuristic based)

checkPhys(phys)
% checkPhys
%
% Usage: checkPhys(phys)
%
% The function checks if the 'phys' structure is right and coherent. If
% there is a error on checking, a error is returned.
%
%INPUT arguments:
    %2)phys: 'phys' structure 
   
function checkPhys(phys)

%%%% 1. Checking sizes and dimensions in phys  %%%%
numberOfNodes = phys.N;
numberOfFibres = phys.M;
if ((numberOfNodes < 1) ||(numberOfFibres < 1)), error ('Non positive number of nodes and/or links'); end
%1. field "Node Names" 
if (length(phys.nodeName)~=numberOfNodes || numel(phys.nodeName)~=numberOfNodes),error('Incorrect dimensions of "phys.nodeName"');end
%2. field "Nodes Placement" 
if  not(isequal(size(phys.nodesPlaceMatrix),[numberOfNodes 2])), error('Incorrect dimensions of "phys.nodesPlaceMatrix"');end
%3. field "Node Populations"
if (length(phys.nodePopulation)~=numberOfNodes || numel(phys.nodePopulation)~=numberOfNodes),error('Incorrect dimensions of "phys.nodePopulation"');end
%4. field "Node Timezones"
if (length(phys.nodeTimezone)~=numberOfNodes || numel(phys.nodeTimezone)~=numberOfNodes) ,error('Incorrect dimensions of "phys.nodeTimezone"');end
%5. field "Node Level" 
if (length(phys.nodeLevel)~=numberOfNodes || numel(phys.nodeLevel)~=numberOfNodes), error('Incorrect dimensions of "phys.nodeLevel"');end
%6. field "Number of Tx Per Node"
if (length(phys.numberTxPerNode)~=numberOfNodes || numel(phys.numberTxPerNode)~=numberOfNodes), error('Incorrect dimensions of "phys.numberTxPerNode"');end
%7. field "Number of Rx Per Node" 
if (length(phys.numberRxPerNode)~=numberOfNodes || numel(phys.numberRxPerNode)~=numberOfNodes), error('Incorrect dimensions of "phys.numberRxPerNode"');end
%8. field "Number of TWC Per Node"
if (length(phys.numberTWCPerNode)~=numberOfNodes || numel(phys.numberTWCPerNode)~=numberOfNodes),error('Incorrect dimensions of "phys.numberTWCPerNode"');end
%9. field "Link Table" 
if not(isequal(size(phys.linkTable),[numberOfFibres 2])), error('Incorrect dimensions of "phys.linkTable"'); end
%10. field "Link Length In Km"
if (length(phys.linkLengthInKm)~=numberOfFibres || numel(phys.linkLengthInKm)~=numberOfFibres), error('Incorrect dimensions of "phys.linkLengthInKm"');end
%11. field "Number of Wavelengths per Fiber"
if (length(phys.numberWavelengthPerFiber)~=numberOfFibres || numel(phys.numberWavelengthPerFiber)~=numberOfFibres), error('Incorrect dimensions of "phys.numberWavelengthPerFiber"');end
%12. field "Level Matrix"
if isempty(phys.levelMatrix), error('"phys.levelMatrix" is empty!!!');end
if size(phys.levelMatrix,1)~=size(phys.levelMatrix,2), error('Incorrect dimensions of "phys.levelMatrix"');end
%13. field "Lightpath Capacity"
if length(phys.lightpathCapacity)~=1, error('Incorrect dimensions of "phys.lightpathCapacity"');end
%14. field "Incoming Links To Node"
if (length(phys.incomingLinksToNode)~=numberOfNodes || numel(phys.incomingLinksToNode)~=numberOfNodes), error('Incorrect dimensions of "phys.incomingLinksToNode"');end
%15. field "Outgoings Links From Node"
if (length(phys.outgoingLinksFromNode)~=numberOfNodes || numel(phys.outgoingLinksFromNode)~=numberOfNodes), error('Incorrect dimensions of "phys.outgoingLinksFromNode"');end
%16. field "Distances Matrix"
if isempty(phys.distancesMatrix), error('"phys.distancesMatrix" is empty!!!');end
if size(phys.distancesMatrix,1)~=size(phys.distancesMatrix,2), error('Incorrect dimensions of "phys.distancesMatrix"');end

%%%% 2. Checking the correctness of the values in phys  %%%%
%2.1 We check the correctness of the values for the nodes-dependant fields
for i=1:numberOfNodes,
    %3. field "Node Population" 
    if ((phys.nodePopulation(i) ~= round(phys.nodePopulation(i))) || (phys.nodePopulation(i) <= 0)), error(['"phys.nodePopulation" in the node ', num2str(i),' must be a positive integer']);end
    %4. field "Node Timezones"
    if ((phys.nodeTimezone(i) > 12) || (phys.nodeTimezone(i) < -12)), error(['"phys.nodeTimezone" in the node ', num2str(i),' must be in the range [-12,+12]']);end   
    %5. field "Node Level" 
    if ((phys.nodeLevel(i) ~= round(phys.nodeLevel(i))) || (phys.nodeLevel(i) <= 0)),error(['"phys.nodeLevel" in the node ', num2str(i),' must be a positive integer']);end         
    if (phys.nodeLevel(i) > size(phys.levelMatrix,1)), error(['"phys.nodeLevel in the node ', num2str(i),' must be lower to the user-defined Nr of Levels']);end       
    %6. field "Number of Tx Per Node"
    if ((phys.numberTxPerNode(i) ~= round(phys.numberTxPerNode(i))) || (phys.numberTxPerNode(i) <= 0)),error(['"phys.numberTxPerNode" in the node ', num2str(i),' must be a positive integer']);end         
    %7. field "Number of Rx Per Node"
    if ((phys.numberRxPerNode(i) ~= round(phys.numberRxPerNode(i))) || (phys.numberRxPerNode(i) <= 0)),error(['"phys.numberRxPerNode" in the node ', num2str(i),' must be a positive integer']);end 
    %8. field "Number of TWC Per Node"
    if ((phys.numberTWCPerNode(i) ~= round(phys.numberTWCPerNode(i))) || (phys.numberTWCPerNode(i) < 0)),error(['"phys.numberTWCPerNode" in the node ', num2str(i),' must be a non-negative integer']);end
    %14. field "Incoming Links To Node" 
    incomingLinksToThisNode= makeRowVector(find(phys.linkTable(:,2)==i));
    if not(isequal(phys.incomingLinksToNode{i},incomingLinksToThisNode)), error(['"phys.incomingLinksToNode" in the node ', num2str(i),' does not match "Incoming Links To Node" computed from phys.linkTable']);end 
    %15. field "Outgoings Links From Node"
    outgoingLinksFromThisNode= makeRowVector(find(phys.linkTable(:,1)==i));
    if not(isequal(phys.outgoingLinksFromNode{i},outgoingLinksFromThisNode)), error(['"phys.outgoingLinksFromNode" in the node ', num2str(i),' does not match "Outgoings Links From Node" computed from phys.linkTable']);end 
end

%2.2 We check the rightness of the values for the fibre links-dependant
%fields
for i=1:numberOfFibres,
    %9. field "Link Table"
    %Origin Node
    if not(ismember(phys.linkTable(i,1),1:numberOfNodes)), error(['The origin node in the fibre ',num2str(i), 'is not in the valid range [1 ,',num2str(phys.N),'].' ]); end
    %Destination Node
    if not(ismember(phys.linkTable(i,2),1:numberOfNodes)), error(['The destination node in the fibre ',num2str(i), 'is not in the valid range [1 ,',num2str(phys.N),'].' ]); end
    %10. field "Link Length In Km"
    if (phys.linkLengthInKm(i) <= 0), error(['"phys.linkLengthInKm" in the fibre ',num2str(i), ' must be a positive value']);end
    %11. field "Number of Wavelengths per Fiber"
    if ((phys.numberWavelengthPerFiber(i) ~= round(phys.numberWavelengthPerFiber(i))) || (phys.numberWavelengthPerFiber(i) <= 0)), error(['"phys.numberWavelengthPerFiber" in the node ', num2str(i),' must be a positive integer']);end
end

%2.3 We check the rightness of the values for the non nodes-dependant
%fields neither the links-dependant fields
%12. field "Level Matrix"
for i=1:size(phys.levelMatrix,1),
    for j=1:size(phys.levelMatrix,2),
        if phys.levelMatrix(i,j) < 0, error(['"phys.levelMatrix(',num2str(i),',',num2str(j),')" must be a positive value']);end
    end 
end
%13. field "Lightpath Capacity"
if phys.lightpathCapacity < 0, error('"phys.lightpathCapacity must be a positive value');end
%16. field "Distances Matrix"
%We compute the euclidean distances (in Km) between the pairs of nodes from
%the "phys.nodesPlaceMatrix"
distancesMatrix = calculateDistanceMatrix(phys.nodesPlaceMatrix);
if not(isequal(distancesMatrix,phys.distancesMatrix )), error('"phys.distancesMatrix" does not match the "Distances Matrix" computed from phys.nodesPlaceMatrix'); end

%%%% 3. Checking the connectivity for all the node pairs.  %%%%
%It is necessary to be able to find a path between any pair of nodes. 
linkTableCheckConnectivity = [phys.linkTable ones(phys.M,1)];
for originNode = 1:phys.N,
    for destinationNode = 1:phys.N,
        if originNode == destinationNode, continue; end
        [sequenceOfSPFLinkIds] = libraryGraph_shortestPath (linkTableCheckConnectivity , originNode , destinationNode);
        if (numel(sequenceOfSPFLinkIds) == 0), error(['There is no connected path between the pair of nodes (',num2str(originNode),',',num2str(destinationNode),')']); end              
    end    
end






    



Contact us at files@mathworks.com