def compareInviteNeighbor(): s = Simulator() random.seed(125) s.setupSimulation(strategy="neighbors", workMeasurement="one", numNodes=1000, numTasks=100000, churnRate=0) loads1, medians1, means1, maxs1, devs1 = s.simulateLoad() random.seed(125) s = Simulator() s.setupSimulation(strategy="invite", workMeasurement="one", numNodes=1000, numTasks=100000, churnRate=0) loads2 = s.simulateLoad()[0] for i in range(0, len(loads1), 5): x1 = loads1[i] x2 = loads2[i] colors = ["k", "w"] labels = ["Neighbors", "Invitation"] plt.hist([x1, x2], 25, normed=1, color=colors, label=labels) plt.legend(loc=0) plt.title('Invitation vs Smart Neighbors at Tick ' + str(i)) plt.xlabel('Tasks Per Node') plt.ylabel('Fraction of the Network') #plt.ylim(0, 0.05) plt.show()
def compareChurnInjection(): s = Simulator() random.seed(125) s.setupSimulation(strategy="churn", workMeasurement="one", numNodes=1000, numTasks=100000, churnRate=0.01) loads1, medians1, means1, maxs1, devs1 = s.simulateLoad() random.seed(125) s = Simulator() s.setupSimulation(strategy='randomInjection', workMeasurement="one", numNodes=1000, numTasks=100000, churnRate=0) loads2 = s.simulateLoad()[0] for i in range(0, len(loads1), 5): x1 = loads1[i] x2 = loads2[i] colors = ["r", "b"] labels = ["Churn", "Random Injection"] plt.hist([x1, x2], 25, normed=1, color=colors, label=labels) plt.legend(loc=0) plt.title('Churn vs Random Injection at Tick ' + str(i)) plt.xlabel('Tasks Per Node') plt.ylabel('Fraction of the Network') #plt.ylim(0, 0.05) plt.show()
def compareInjectionStable(): s = Simulator() random.seed(125) s.setupSimulation(strategy="churn", homogeneity="equal", workMeasurement="one", numNodes=1000, numTasks=100000, churnRate=0) loads1, medians1, means1, maxs1, devs1 = s.simulateLoad() random.seed(125) s = Simulator() s.setupSimulation(strategy="randomInjection", homogeneity="perStrength", workMeasurement="one", numNodes=1000, numTasks=100000, churnRate=0) loads2 = s.simulateLoad()[0] for i in range(0, len(loads1), 5): x1 = loads1[i] x2 = loads2[i] colors = ["k", "w"] labels = ["No Strategy", "Random Injection"] plt.hist([x1, x2], 25, normed=1, color=colors, label=labels) plt.legend(loc=0) plt.title('Random Injection in a Heterogeneous Network at Tick ' + str(i)) plt.xlabel('Tasks Per Node') plt.ylabel('Fraction of the Network') #plt.ylim(0, 0.05) plt.show()
def testChurnSteps(): s = Simulator() s.setupSimulation(strategy='churn', workMeasurement="one", numNodes=1000, numTask=100000, churnRate=0.001) loads, medians, means, maxs, devs = s.simulateLoad() print(medians) print(devs)
def testInjectionSteps(): s = Simulator() s.setupSimulation(strategy = 'randomInjections',workMeasurement="one", numNodes=1000, numTasks=100000) loads, medians, means, maxs, devs = s.simulateLoad() for i in range(0,len(loads), 5): x = loads[i] plt.hist(x, 100, normed =1 ) plt.xlabel('Tasks Per Node') plt.ylabel('Probability') plt.axvline(medians[i], color='r', linestyle='--') plt.axvline(means[i], color='k', linestyle='--') #plt.ylim(0, 0.05) plt.show()
def compareChurnStable(): s = Simulator() random.seed(125) s.setupSimulation(strategy= "churn", workMeasurement= "one", numNodes= 1000, numTasks = 100000, churnRate =0) loads1, medians1, means1, maxs1, devs1 = s.simulateLoad() random.seed(125) s=Simulator() s.setupSimulation(strategy= "churn", workMeasurement= "one", numNodes= 1000, numTasks = 100000, churnRate =0.1) loads2 = s.simulateLoad()[0] for i in range(0,len(loads1), 5): x1= loads1[i] x2 =loads2[i] colors = ["k", "w"] labels = ["No Strategy","Churn"] plt.hist([x1,x2], 25, normed =1, color=colors, label=labels) plt.legend(loc=0) plt.title('Churn vs No Strategy at Tick ' + str(i)) plt.xlabel('Tasks Per Node') plt.ylabel('Fraction of the Network') #plt.ylim(0, 0.05) plt.show()
def testInjectionSteps(): s = Simulator() s.setupSimulation(strategy='randomInjections', workMeasurement="one", numNodes=1000, numTasks=100000) loads, medians, means, maxs, devs = s.simulateLoad() for i in range(0, len(loads), 5): x = loads[i] plt.hist(x, 100, normed=1) plt.xlabel('Tasks Per Node') plt.ylabel('Probability') plt.axvline(medians[i], color='r', linestyle='--') plt.axvline(means[i], color='k', linestyle='--') #plt.ylim(0, 0.05) plt.show()
def testChurnSteps(): s = Simulator() s.setupSimulation(strategy="churn", workMeasurement="one", numNodes=1000, numTask=100000, churnRate=0.001) loads, medians, means, maxs, devs = s.simulateLoad() print(medians) print(devs)