| checkNetState_MH(netState_mh , phys, trafficMatrix_mh, flag_checkLoops, flag_removeLoops , flag_checkLpRoutingMatrix, flag_lossesAllowed)
|
% checkNetState_MH
% [flag_modifiedNetState_mh newNetState_mh] = checkNetState_MH(netState_mh , phys, trafficMatrix_mh,...
% flag_removeLoops , flag_checkLpRoutingMatrix)
%The function checks if the 'netState_mh' cell (each cell element is a
%'netState' structure) is right and coherent with the 'phys' structure,
%with the trafficMatrix_mh and if the serial numbers of the lightpaths are
%kept equal in all the time slots. If there is a error on checking, a error is
%returned, except if the the error is a detected loop
% and the input 'flag_removeLoops'=1, then, the loop is removed.
%INPUT arguments:
%1)netState_mh: original 'netState' structure
%2)phys: 'phys' structure
%3)trafficMatrix_mh: offered traffic matrix for all the time slots.
%Array(node s, node d, time slot t)
%4)flag_checkLoops: '1' if the function is allowed to check if there
% are loops in both lightpaths and flows. '0' if the function do not
% check if there exist loops.
%5)flag_removeLoops: '1' if the function is allowed to remove loops in
% both lightpaths and flows. '0', otherwise.
%6)flag_checkLpRoutingMatrix: '1' if the function is allowed to check
% the lightpath routing matrix. '0', otherwise.
%7)flag_lossesAllowed: '1' if traffic losses are allowed in the flow
% routing. '0', otherwise.
%OUTPUT arguments:
%1)flag_modifiedNetState: '1', if the 'netState' structure was modified
%on removing loops; '0', if 'newNetState' = 'netState'.
%2)newNetState_mh: outgoing 'newNetState_mh' cell. It can be the same as
%the input 'netState_mh', or the cell of structs without loops if the input option
%'flag_checkLpRoutingMatrix' is activated and loops were detected.
function [flag_modifiedNetState_mh newNetState_mh] = checkNetState_MH(netState_mh , phys, trafficMatrix_mh, flag_checkLoops, flag_removeLoops , flag_checkLpRoutingMatrix, flag_lossesAllowed)
T = length (netState_mh);
if(~isempty(trafficMatrix_mh))
if (length(trafficMatrix_mh) ~= T), error ('Number T different in netstate and traffic matrixes'); end
end
flag_modifiedNetState_mh = 0;
newNetState_mh = cell(T,1);
for t=1:T
[flag_modifiedNetState newNetState_mh{t}]= checkNetState(netState_mh{t} , phys, [] , flag_checkLoops, flag_removeLoops , flag_checkLpRoutingMatrix , flag_lossesAllowed);
if flag_modifiedNetState == 1, flag_modifiedNetState_mh = 1; end
end
%%% check that all lps with the same serial number have the same ingress
%%% egress pair
lpTableAll = zeros (0,4);
for t=1:T, lpTableAll=[lpTableAll ; netState_mh{t}.lightpathTable(:,1:3) t*ones(size(netState_mh{t}.lightpathTable,1),1)]; end
lpTableAll = sortrows(lpTableAll,[1 4]);
serialNumbers = (unique(lpTableAll(:,1)))';
for thislpSN = serialNumbers,
lpIdsTableAll = find(lpTableAll(:,1)==thislpSN);
previousLpIngress = [];
previousLpEgress = [];
lpTime = zeros(1,T+1);
for lpIdTableAll = lpIdsTableAll
% check if same SN means same ingress and egress node
if numel(previousLpIngress)==0
previousLpIngress = lpTableAll(lpIdTableAll,2);
previousLpEgress = lpTableAll(lpIdTableAll,3);
elseif (previousLpIngress ~= lpTableAll(lpIdTableAll,2)) ||(previousLpEgress ~= lpTableAll(lpIdTableAll,3))
error ('Not the same ingress or egress, with the same SN');
end
% check if the same SN appears in two lightpaths in the same time
if (lpTime(1+lpTableAll(lpIdTableAll,4)) ~= 0), error ('Same SN appears in two lightpaths in the same time'); end
lpTime(1+lpTableAll(lpIdTableAll,4)) = 1;
end
lpTime(1) = lpTime(end);
slotsTheLpIsInitiated = (diff(lpTime)>0);
if (sum(slotsTheLpIsInitiated)>1), error ('The lightpath is not contiguous: it is initiated more than once'); end
end
end
|
|