ارجو المساعده في برنامجي المرفق جزء


(aboazoz) #1

هذا هو المين والفنكشن اللي استدعيتها فيه ارجو التشييك بعد التعديل هل من خطا منطقي لان البرنامج لا يعطي خطا ولا ينفذ يبقى زي ماهو دون ان يكمل التنفيذ


clear all;
 
numOfInstances = 2;
networkDimensions = [50 , 60, 70 , 80 , 90];%] ;% ];%
nodesSize = [10, 20, 30  , 40 ,  40];%;%] ;%];%s
commRange = 50; 
% %--------------------------------------------------------------------------
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Options:
outer = 0;
useVarDist = 1;
VarClusterHeads = 1;
collectorHoldingRounds = 30;
 
[ ClusterSimRoundsNumber , ClusterConsumedPower , ClusterAveragePackets , ClusterPowerPerBit , ClusterAverageSensitiveDiliveredPackets , ClusterAverageTolerantDiliveredPackets] = Cluster( collectorHoldingRounds, nodesSize, networkDimensions , numOfInstances , commRange, outer ,useVarDist , VarClusterHeads);
%--------------------------------------------------------------------------
 
figure(1)
plot(nodesSize , ClusterSimRoundsNumber, 'r-*');
xlabel('Number Of Nodes');
ylabel(' (Rounds)');
 
 
function [ simRoundsNumber , simConsumedPower , averagePackets , powerPerBit , averageSensitiveDiliveredPackets , averageTolerantDiliveredPackets] = Cluster(collectorHoldingRounds, nodesSize, networkDimensions , numOfInstances , commRange, outer,useVarDist,VarClusterHeads )
 
instLen = length(nodesSize);
for simNodes = 1 : instLen
 
numberOfNodes = nodesSize(simNodes); %simNodes * 200;
networkDimension = networkDimensions(simNodes); % (simNodes + 2) * 100;
 
totalNumberOfRounds = 0;
totalConsumedPower = 0;
totalDeliveredPackets = 0;
totalSensitiveDiliveredPackets = 0;
totalTolerantDiliveredPackets = 0;
 
for instance = 1  : numOfInstances
 
 numberOfNodes
 instance
 
 
Locations = getDataCollectorLocations(networkDimension , 10 , outer);
dataCollector.startLoc = Locations(1);
% Initialize nodes data.
[ Nodes , TiersX , TiersY ]  = initializeNodes(dataCollector.startLoc , numberOfNodes,networkDimension,commRange);
 
 
 [TRNS , Nodes ] = getMobileTrajectoryNodes( Locations , numberOfNodes  , Nodes ,commRange  );
 
 
 [Nodes] = getAllNeighboursLocations(Nodes, networkDimension);
 
 [ Nodes , dataCollector, UpdatedLocations ] = setCuster( 0 ,collectorHoldingRounds, dataCollector, Nodes , numberOfNodes , Locations, commRange,0,0 , networkDimension, useVarDist );
 
 
ClusterOrNoCluster = 1;
dataCollector.loc = UpdatedLocations(1);
 
ratio = .5;
 
 [ NumberOfRounds , consumedPower, acctuallyDeliveredPackets , sensitiveDiliveredPackets , tolerantDiliveredPackets] = sendMessagesAndGetRoundsMobile(collectorHoldingRounds,networkDimension , ClusterOrNoCluster, commRange , Nodes , numberOfNodes ,Locations ,UpdatedLocations , dataCollector, TiersX , TiersY  , ratio, useVarDist,VarClusterHeads,outer);
 
totalNumberOfRounds = totalNumberOfRounds + NumberOfRounds;
totalConsumedPower  = totalConsumedPower  + consumedPower;
totalDeliveredPackets = totalDeliveredPackets + acctuallyDeliveredPackets;
totalSensitiveDiliveredPackets = totalSensitiveDiliveredPackets + sensitiveDiliveredPackets/NumberOfRounds;
totalTolerantDiliveredPackets = totalTolerantDiliveredPackets + tolerantDiliveredPackets/NumberOfRounds;
 
NumberOfRounds
end
 
avgNumOfRounds = totalNumberOfRounds/numOfInstances;
 
simRoundsNumber(simNodes) = avgNumOfRounds;
 
averageConsumedPower =  totalConsumedPower/numOfInstances;
 
simConsumedPower(simNodes) = averageConsumedPower;
 
averagePackets = totalDeliveredPackets/numOfInstances;
 
averageSensitiveDiliveredPackets(simNodes) = totalSensitiveDiliveredPackets / numOfInstances;
averageTolerantDiliveredPackets(simNodes) = totalTolerantDiliveredPackets / numOfInstances;
 
powerPerBit(simNodes) = (averageConsumedPower * 10^9) / ( averagePackets * 100  );
end
 
 
 
end
 
 بعد التعديل 
 
clear all;
 
numOfInstances = 2;
networkDimensions = [50 ]
nodesSize = [10]
commRange = 50; 
mesag=[8,9,10,11,12];
% %--------------------------------------------------------------------------
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Options:
outer = 0;
useVarDist = 1;
VarClusterHeads = 1;
collectorHoldingRounds = 30;
[ ClusterSimRoundsNumber , ClusterConsumedPower , ClusterAveragePackets , ClusterPowerPerBit , ClusterAverageSensitiveDiliveredPackets , ClusterAverageTolerantDiliveredPackets] = Cluster( collectorHoldingRounds, nodesSize, networkDimensions , numOfInstances , commRange, outer ,useVarDist , VarClusterHeads, mesag);
%--------------------------------------------------------------------------
 
figure(1)
plot(msg , ClusterSimRoundsNumber, 'r-*');
xlabel('Number Of Nodes');
ylabel(' (Rounds)');
 
 
function [ simRoundsNumber , simConsumedPower , averagePackets , powerPerBit , averageSensitiveDiliveredPackets , averageTolerantDiliveredPackets] = Cluster(collectorHoldingRounds, nodesSize, networkDimensions , numOfInstances , commRange, outer,useVarDist,VarClusterHeads, mesag )
 
instLen = length(nodesSize);
for simNodes = 1 : instLen
 
numberOfNodes = nodesSize(simNodes); %simNodes * 200;
networkDimension = networkDimensions(simNodes); % (simNodes + 2) * 100;
 
totalNumberOfRounds = 0;
totalConsumedPower = 0;
totalDeliveredPackets = 0;
totalSensitiveDiliveredPackets = 0;
totalTolerantDiliveredPackets = 0;
msg= length(mesag);
 
for ggg= 1: msg
m =mesag(msg)
 
for instance = 1  : numOfInstances
 
 numberOfNodes
 instance
 
 
Locations = getDataCollectorLocations(networkDimension , 10 , outer);
dataCollector.startLoc = Locations(1);
% Initialize nodes data.
[ Nodes , TiersX , TiersY ]  = initializeNodes(dataCollector.startLoc , numberOfNodes,networkDimension,commRange);
 
 
 [TRNS , Nodes ] = getMobileTrajectoryNodes( Locations , numberOfNodes  , Nodes ,commRange  );
 
 
 [Nodes] = getAllNeighboursLocations(Nodes, networkDimension,m);
 
 [ Nodes , dataCollector, UpdatedLocations ] = setCuster( 0 ,collectorHoldingRounds, dataCollector, Nodes , numberOfNodes , Locations, commRange,0,0 , networkDimension, useVarDist,m );
 
 
ClusterOrNoCluster = 1;
dataCollector.loc = UpdatedLocations(1);
 
ratio = .5;
 
 [ NumberOfRounds , consumedPower, acctuallyDeliveredPackets , sensitiveDiliveredPackets , tolerantDiliveredPackets] = sendMessagesAndGetRoundsMobile(collectorHoldingRounds,networkDimension , ClusterOrNoCluster, commRange , Nodes , numberOfNodes ,Locations ,UpdatedLocations , dataCollector, TiersX , TiersY  , ratio, useVarDist,VarClusterHeads,outer,m);
 
totalNumberOfRounds = totalNumberOfRounds + NumberOfRounds;
totalConsumedPower  = totalConsumedPower  + consumedPower;
totalDeliveredPackets = totalDeliveredPackets + acctuallyDeliveredPackets;
totalSensitiveDiliveredPackets = totalSensitiveDiliveredPackets + sensitiveDiliveredPackets/NumberOfRounds;
totalTolerantDiliveredPackets = totalTolerantDiliveredPackets + tolerantDiliveredPackets/NumberOfRounds;
 
NumberOfRounds
end
 
avgNumOfRounds = totalNumberOfRounds/numOfInstances;
 
simRoundsNumber(mesag) = avgNumOfRounds;
 
averageConsumedPower =  totalConsumedPower/numOfInstances;
 
simConsumedPower(mesag) = averageConsumedPower;
 
averagePackets = totalDeliveredPackets/numOfInstances;
 
averageSensitiveDiliveredPackets(mesag) = totalSensitiveDiliveredPackets / numOfInstances;
averageTolerantDiliveredPackets(mesag) = totalTolerantDiliveredPackets / numOfInstances;
 
powerPerBit(mesag) = (averageConsumedPower * 10^9) / ( averagePackets * 100  );
end
 
 
 
end
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

المطلوب هو مقارنة بعد التعديل حيث اريد تنفيذ لحالة 8 ثم 9 ثم 10 ثم 11 ثم 12 لكل منهم يتم تنفيذ مرتين


(aboazoz) #2

يااخوان المين والفنكشن موجودة ثم قمت بالتعديل
اريد فقط مشاهدة التعديل هل صحيح ام لا فقط برمجيا
واي سؤال انا حاضر


(Ahmed) #3

قبل التعديل البرنامج فيه خطا في كتابة ال function
كتابة غير صحيحة

(aboazoz) #4

قبل التعديل شغال البرنامج بشكل سليم
ماهي ملاحظتك عليه وشكرا