Example #1
0
def paperOneTestDA():
    factory = GridNetworkFactory(makeSimpleNode(),Queues)
    resultBP = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)


    factory = GridNetworkFactory(SPNode,SPQueues)
    resultLQ2 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makeMNode(4),Queues)
    resultLQ3 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    labels = {'aveDelay':'Average end-to-end delay',\
                  'aveDRate':'Delivery rate',\
                  'aveHop':'Average hop count',\
                  'aveBacklog':'Per-node queue lengths'}

    for item in ['aveDelay','aveDRate','aveHop','aveBacklog']:
        
        entry = [resultBP[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-o',label ='bp')
    
        
        entry = [resultLQ2[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-x',label ='K=10')
        
        entry = [resultLQ3[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-p',label ='M=4')

        
        py.xlabel("$\lambda$")
        py.ylabel(labels[item])
        py.grid
        py.legend(loc=0)
        py.savefig('PaperOneTest_differentAlgorithms_other_'+labels[item])
        py.close()
Example #2
0
def Test():
    factory = GridNetworkFactory(makeSimpleNode(),Queues)
    result = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    #print result
    py.plot(gobalRateList,result,'-o',label ='bp')

    #factory = GridNetworkFactory(makeSimpleNode(),ShadowQueues)
    #result = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    #py.plot(gobalRateList,result,'-v',label ='sq')

    #factory = GridNetworkFactory(makeOMNode(1),Queues)
    #result = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    #py.plot(gobalRateList,result,'-+',label ='om')

    #factory = GridNetworkFactory(makeMNode(2),Queues)
    #result = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    #py.plot(gobalRateList,result,'-*',label ='mm=2')
    

    #factory = GridNetworkFactory(makeMNode(4),ShadowQueues)
    #result = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    #py.plot(gobalRateList,result,'-s',label ='ms=4')
    
    py.legend(loc=0)
    py.show()
Example #3
0
def PaperTwoTest_DA():
    factory = GridNetworkFactory(makeSimpleNode(),Queues)
    resultBP = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(SPNode,SPQueues)
    resultLQ = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makePNode(0.5),Queues)
    resultLQ2 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    labels = {'aveDelay':'Average end-to-end delay',\
                  'aveDRate':'Delivery rate',\
                  'aveHop':'Average hop count',\
                  'aveBacklog':'Per-node queue lengths'}
    
    for item in ['aveDelay','aveDRate','aveHop','aveBacklog']:
        
        entry = [resultBP[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-o',label ='bp')
    
        entry = [resultLQ[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-v',label ='K=10')
        
        entry = [resultLQ2[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-x',label ='r=0.5')
        
        py.xlabel("$\lambda$")
        py.ylabel(labels[item])
        py.legend(loc=0)
        py.savefig('PaperTwoTest_DA_'+item)
        py.close()
Example #4
0
def NewQueuesTest():
    factory = GridNetworkFactory(makeSimpleNode(),Queues)
    resultBP = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makeNewNode(1),NewQueues)
    resultLQ = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(SPNode,SPQueues)
    resultLQ2 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makeNewNode(0.8),NewQueues)
    resultLQ3 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    
    for item in ['aveDelay','aveDRate']:
        
        entry = [resultBP[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-o',label ='bp')
    
        entry = [resultLQ[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-v',label ='nq=1')

        entry = [resultLQ3[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-p',label ='nq=0.7')
        
        entry = [resultLQ2[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-x',label ='sp=1')


        
        
        py.legend(loc=0)
        py.savefig('newQueuesTest_'+item)
        py.close()
Example #5
0
def PerodicPossiblityLearningVsPressure():
    factory = GridNetworkFactory(makeSimpleNode(),Queues)
    resultBP = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makePNode(0.9),Queues)
    resultLQ = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makePNode(0.5),Queues)
    resultLQ2 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    
    for item in ['aveDelay','aveDRate']:
        
        entry = [resultBP[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-o',label ='bp')
    
        entry = [resultLQ[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-v',label ='a=0.9')
        
        entry = [resultLQ2[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-x',label ='a=0.5')
        

        py.legend(loc=0)
        py.savefig('PerodicPossiblityLearning_with_redo_add_'+item)
        py.close()
Example #6
0
def onePassLearningVsPressure():
    factory = GridNetworkFactory(makeSimpleNode(),Queues)
    resultBP = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makeCNode(1),Queues)
    resultLQ = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makeCNode(10),Queues)
    resultLQ2 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    
    for item in ['aveDelay','aveDRate']:
        
        entry = [resultBP[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-o',label ='bp')
    
        entry = [resultLQ[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-v',label ='lq=1')
        
        entry = [resultLQ2[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-x',label ='lq=10')
        

        py.legend(loc=0)
        py.savefig('onePassLearning_'+item)
        py.close()
Example #7
0
def oneRoundDelay(step = 10000):
    injectRate = 0.9
    factory = GridNetworkFactory(makeSimpleNode(),Queues)
    factory.constructNetwork(6,6)\
        .setFlow(Flow((0,0),(0,5),injectRate))\
        .setFlow(Flow((5,0),(5,5),injectRate))\
        .setFlow(Flow((2,0),(3,5),injectRate))

    network = factory.getNetwork()

    packetFactory = PacketFactory()
    simulator = \
        Simulator(network,step,ConstLinkRateGenerator(1),packetFactory)
    simulator.run()
    #simulator.printNetwork()
    stat = simulator.getStaticsInfo()
    print stat['aveDelay']
    packetPool = sorted(stat['packetPool'],key=lambda p: p.getID)


    
    py.subplot(211)
    py.vlines([p.getCreateTime() for p in packetPool],[1],[p.getDelay() for p in packetPool],'r')
    py.xlabel('Packet create time(bp with $\lambda$ = 0.9)')
    py.ylabel('delay')
    py.grid(True)




    injectRate = 0.9
    factory = GridNetworkFactory(makeMNode(2),Queues)
    factory.constructNetwork(6,6)\
        .setFlow(Flow((0,0),(0,5),injectRate))\
        .setFlow(Flow((5,0),(5,5),injectRate))\
        .setFlow(Flow((2,0),(3,5),injectRate))

    network = factory.getNetwork()

    packetFactory = PacketFactory()
    simulator = \
        Simulator(network,step,ConstLinkRateGenerator(1),packetFactory)
    simulator.run()
    #simulator.printNetwork()

    stat = simulator.getStaticsInfo()
    print stat['aveDelay']
    packetPool = sorted(stat['packetPool'],key=lambda p: p.getID)

    py.subplot(212)
    py.vlines([p.getCreateTime() for p in packetPool],[1],[p.getDelay() for p in packetPool],'b')
    py.xlabel('Packet create time (m=2 with $\lambda$ = 0.9)')
    py.ylabel('delay')
    py.grid(True)
    py.savefig('packetDelayInOneRound_09')
    py.show()
Example #8
0
def otherTest():
    factory = GridNetworkFactory(makeSimpleNode(),Queues)
    resultBP = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makeNewNode(0.8),NewQueues)
    resultLQ = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makeNewNode(0.8),TestQueues)
    resultLQ2 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makeNewNode(0.8),TestSquareQueues)
    resultLQ3 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    labels = {'aveDelay':'Average end-to-end delay',\
                  'aveDRate':'Delivery rate',\
                  'aveHop':'Average hop count',\
                  'aveBacklog':'Per-node queue lengths'}
    
    for item in ['aveDelay','aveDRate','aveHop','aveBacklog']:
        
        entry = [resultBP[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-o',label ='bp')
    
        entry = [resultLQ[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-v',label ='original')
        
        entry = [resultLQ2[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-x',label ='doubleRule')

        entry = [resultLQ3[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-+',label ='squareRule')
        
        py.xlabel("$\lambda$")
        py.ylabel(labels[item])
        py.grid(True)
        py.legend(loc=0)
        py.savefig('otherTest_'+item)
        py.close()
Example #9
0
def newTest():
    factory = GridNetworkFactory(makeSimpleNode(),Queues)
    resultBP = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makePNode(0.5),Queues)
    resultLQ = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(SPNode,SPQueues)
    resultLQ2 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)

    factory = GridNetworkFactory(makeMNode(2),Queues)
    resultLQ3 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    
    #factory = GridNetworkFactory(makeCNode(1),Queues)
    #resultLQ4 = mainProcessCtrl(factory=factory,rateList=gobalRateList,threadNum=3)
    
    for item in ['aveDelay','aveDRate']:
        
        entry = [resultBP[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-o',label ='bp')
    
        entry = [resultLQ[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-v',label ='pl=0.5')
        
        entry = [resultLQ2[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-x',label ='sp=1')
        
        entry = [resultLQ3[key][item] for key in gobalRateList]
        py.plot(gobalRateList,entry,'-p',label ='mm=2')

        #entry = [resultLQ4[key][item] for key in gobalRateList]
        #py.plot(gobalRateList,entry,'-+',label ='ol=1')
        
        py.legend(loc=0)
        py.savefig('newTest_'+item)
        py.close()