Skip to content

Commit

Permalink
boundary-hit analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
keznikl committed Feb 18, 2014
1 parent b72903a commit 461f1b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 2 additions & 0 deletions jdeeco-simulation-demo/analysis/analyze_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def analyze(self, logname):
boundaryFailedCnt = len(boundaryFailedLines)
print 'Boundary prevented sending of:', boundaryFailedCnt

self.boundaryHits = boundaryFailedCnt

def extract_published_signatures(line):
p = re.compile('\[([^\]]*)\]')
m = p.search(line)
Expand Down
28 changes: 17 additions & 11 deletions jdeeco-simulation-demo/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def analyze():
# generic analysis
with open(s.genericResultsPath(), 'w') as results:
genericStats = [[it.genericAnalysis.sentMessagesCnt, it.genericAnalysis.receivedMessagesCnt,
it.demoAnalysis.shouldDiscover, it.demoAnalysis.reallyDiscovered] for it in s.iterations]
it.demoAnalysis.shouldDiscover, it.demoAnalysis.reallyDiscovered, it.genericAnalysis.boundaryHits] for it in s.iterations]
np.savetxt(results, genericStats, fmt='%d')


Expand Down Expand Up @@ -348,11 +348,11 @@ def plotMessageCounts():
axes = [fig.add_subplot(121), fig.add_subplot(122)]


yticks = range(0, 85000, 5000)
yticks = range(0, 185000, 5000)
xticksLabels = [s.tickLabel() for s in scenariosWithoutBoundary]

ax.set_yticks(yticks)
ax.set_yticklabels(map(lambda x: x/1000, yticks))
#ax.set_yticks(yticks)
#ax.set_yticklabels(map(lambda x: x/1000, yticks))
ax.set_frame_on(False)
ax.set_ylabel('number of messages [in thousands]')
ax.set_xlabel('total number of nodes [firefighters/others]')
Expand All @@ -364,13 +364,13 @@ def plotMessageCounts():
axes[0].set_title('Boundary disabled')
axes[0].set_yticklabels([])
axes[0].set_xticklabels(xticksLabels)
axes[0].set_yticks(yticks)
#axes[0].set_yticks(yticks)

pylab.setp(axes[0].xaxis.get_majorticklabels(), rotation=0 )

plt2 = df.loc[df['boundary'] == 'T'].plot(kind='bar', stacked=True, ax=axes[1], legend=False);
axes[1].set_title('Boundary enabled')
axes[1].set_yticks(yticks)
#axes[1].set_yticks(yticks)
axes[1].set_yticklabels([])
axes[1].set_xticklabels(xticksLabels)
pylab.setp(axes[1].xaxis.get_majorticklabels(), rotation=0 )
Expand Down Expand Up @@ -444,6 +444,11 @@ def plotDiscoveryRate():
pylab.axes().set_ylabel("discovery ratio");
pylab.axes().set_xlabel("total number of nodes [firefighters/others]");

def plotBoundaryHits():
pylab.figure(4).set_facecolor('white')
plotBoundarySplitBoxplot(scenarios, 'boundaryHits')
pylab.axes().set_ylabel("boundary hits");
pylab.axes().set_xlabel("total number of nodes [firefighters/others]");

def plot():
print 'Plotting...'
Expand All @@ -460,7 +465,7 @@ def plot():
received = map(int, contents[:, 1])
s.messageStats = [average(sent), average(received), average(received)*1.0/average(sent)]
s.discoveryRatio = map(lambda should, did: did * 1.0 / should, map(int, contents[:, 2]), map(int, contents[:, 3]))

s.boundaryHits = map(int, contents[:, 4])
with open(s.neighborResultsPath() , 'r') as resultsFile:
contents = np.loadtxt(resultsFile)
s.neighbors = map(int, contents)
Expand All @@ -470,6 +475,7 @@ def plot():
plotMessageCounts()
plotNeighborCounts()
plotDiscoveryRate()
plotBoundaryHits()

pylab.show()

Expand All @@ -496,15 +502,15 @@ def duplicateScenariosForBoundary():
if __name__ == '__main__':
#evaluations = {4:10, 8:10, 12: 10, 16:10, 20:10}
#evaluations = {8:10, 12: 10, 16:10, 20:10, 24:10, 28:10}
#evaluations = {2:10, 4:10, 8:10, 12: 10, 16:10}
evaluations = {8:3, 12: 3}
evaluations = {2:10, 4:10, 8:10, 12: 10, 16:10, 20:10}
#evaluations = {2:3, 4: 3}

# init with only scenarios with disabled boundary (they enbaled counterparts will be created automatically after the generation step)
for nodeCnt in evaluations.keys():
scenarios.append(Scenario(nodeCnt, nodeCnt/2, evaluations[nodeCnt], False, 'complex'))
duplicateScenariosForBoundary()

generate()
simulate()
#generate()
#simulate()
analyze()
plot()

0 comments on commit 461f1b4

Please sign in to comment.