예제 #1
0
def testAvroraCandidate(nescDir, query, outputPath, numNodes, duration,
                        schemaPath, aqRate, deliveryTime, actualBFactor):

    #Compile the nesC
    exitVal = AvroraLib.compileNesCCode(nescDir)
    if (exitVal != 0):
        return
    AvroraLib.generateODs(nescDir)

    for i in range(0, optNumAvroraRuns):
        if optNumAvroraRuns > 1:
            report("Avrora simulation run #%d for candidate %s\n" %
                   (i, outputPath))

        #run avrora simulation
        (avroraOutputFile,
         traceFilePath) = AvroraLib.runSimulation(nescDir,
                                                  outputPath,
                                                  query,
                                                  numNodes,
                                                  simulationDuration=duration,
                                                  networkFilePath=None)

        #check all tuples present
        queryPlanSummaryFile = "%s/%s/query-plan/query-plan-summary.txt" % (
            outputPath, query)
        checkTupleCount.checkResults(query, traceFilePath, schemaPath, aqRate,
                                     actualBFactor, duration)

        #add points to graph here
        #TODO: exp dependent - deliveryTime
        if (optXValType == 'acq'):
            addtoEnergyGraphs(query, aqRate, outputPath, duration, query)
        elif (optXValType == 'del'):
            addtoEnergyGraphs(query, deliveryTime, outputPath, duration, query)
예제 #2
0
def testTossimCandidate(nescDir, traceFilePath, query, numNodes, duration, outputPath, schemaPath, aqRate):

	#compile the nesc
	exitVal = TossimLib.compileNesCCode(nescDir)
	if (exitVal != 0):
		return;		

	#run tossim simulation		
	exitVal = TossimLib.runSimulation(nescDir, traceFilePath, query, numNodes, simulationDuration = (duration + optTossimSyncTime))
	if (exitVal != 0):
		return;

	#check all tuples present in Tossim simulation
	queryPlanSummaryFile = "%s/%s/query-plan/query-plan-summary.txt" % (outputPath, query)
	actualBFactor = SneeqlLib.getBufferingFactor(queryPlanSummaryFile)
	checkTupleCount.checkResults(query, traceFilePath, schemaPath, aqRate, actualBFactor, duration)
예제 #3
0
def testAvroraCandidate(nescDir, query, outputPath, numNodes, duration,
                        schemaPath, aqRate, avroraNetFile, rtscore_lifetime):

    #Compile the nesC
    exitVal = AvroraLib.compileNesCCode(nescDir)
    if (exitVal != 0):
        return
    AvroraLib.generateODs(nescDir)

    for i in range(0, optNumAvroraRuns):
        if optNumAvroraRuns > 1:
            report("Avrora simulation run #%d for candidate %s\n" %
                   (i, outputPath))

        #run avrora simulation
        (avroraOutputFile, traceFilePath) = AvroraLib.runSimulation(
            nescDir,
            outputPath,
            query,
            numNodes,
            simulationDuration=duration,
            networkFilePath=avroraNetFile)

        #check all tuples present
        queryPlanSummaryFile = "%s/%s/query-plan/query-plan-summary.txt" % (
            outputPath, query)
        actualBFactor = SneeqlLib.getBufferingFactor(queryPlanSummaryFile)
        checkTupleCount.checkResults(query, traceFilePath, schemaPath, aqRate,
                                     actualBFactor, duration)

        #Report total energy consumption
        siteLifetimeRankFile = "%s/site-lifetime-rank.csv" % nescDir
        (sumEnergy, maxEnergy, averageEnergy, radioEnergy, cpu_cycleEnergy,
         sensorEnergy, otherEnergy,
         networkLifetime) = AvroraLib.computeEnergyValues(
             nescDir,
             duration,
             inputFile="avrora-out.txt",
             ignoreLedEnergy=True,
             siteLifetimeRankFile=siteLifetimeRankFile)
        report("The total energy consumption is %f" % (sumEnergy))
        report("The lifetime for this network is %f" % (networkLifetime))

        (agendaName, rtName, score) = getRTScore(nescDir, query, outputPath)
        agendaID = agendaName.split("-")[2]
        rtscore_lifetime.add(1, sumEnergy, agendaID)
예제 #4
0
def testAvroraCandidate(nescDir, query, outputPath, numNodes, duration, schemaPath, aqRate, avroraNetFile):

	#Compile the nesC
	exitVal = AvroraLib.compileNesCCode(nescDir)
	if (exitVal != 0):
		return;		
	AvroraLib.generateODs(nescDir)

	for i in range(0, optNumAvroraRuns):
		if optNumAvroraRuns > 1:
			report("Avrora simulation run #%d for candidate %s\n" % (i, outputPath))
	
		#run avrora simulation
		(avroraOutputFile, traceFilePath) = AvroraLib.runSimulation(nescDir, outputPath, query, numNodes, simulationDuration = duration, networkFilePath = avroraNetFile)

		#check all tuples present
		queryPlanSummaryFile = "%s/%s/query-plan/query-plan-summary.txt" % (outputPath, query)
		actualBFactor = SneeqlLib.getBufferingFactor(queryPlanSummaryFile)
		checkTupleCount.checkResults(query, traceFilePath, schemaPath, aqRate, actualBFactor, duration)	
예제 #5
0
def testTossimCandidate(nescDir, traceFilePath, query, numNodes, duration, outputPath, schemaPath, aqRate):

	#compile the nesc
	exitVal = TossimLib.compileNesCCode(nescDir)
	if (exitVal != 0):
		return;		

	#run tossim simulation		
	exitVal = TossimLib.runSimulation(nescDir, traceFilePath, query, numNodes, simulationDuration = (duration + optTossimSyncTime))
	if (exitVal != 0):
		return;

	#check all tuples present in Tossim simulation
	queryPlanSummaryFile = "%s/%s/query-plan/query-plan-summary.csv" % (outputPath, query)
	
	candidateInfo = getCandidateSummaryInformation(nescDir, query, outputPath)
	alpha = int(candidateInfo['alpha-ms'])
	bufferingFactor = int(candidateInfo['beta'])
	checkTupleCount.checkResults(query, traceFilePath, schemaPath, alpha, bufferingFactor, duration)
예제 #6
0
def testAvroraCandidate(nescDir, query, outputPath, numNodes, duration, schemaPath, aqRate, avroraNetFile, alphaGraph, deltaGraph, epsilonGraph, lambdaGraph):

	#Compile the nesC
	exitVal = AvroraLib.compileNesCCode(nescDir)
	if (exitVal != 0):
		return;		
	AvroraLib.generateODs(nescDir)

	candidateInfo = getCandidateSummaryInformation(nescDir, query, outputPath)
	candidateInfo['total-energy'] = []
	candidateInfo['network-lifetime'] = []
	alpha = int(candidateInfo['alpha-ms'])
	bufferingFactor = int(candidateInfo['beta'])
	duration = int((float(optNumAgendaEvals) * float(alpha) * float(bufferingFactor)) / 1000.0)
	
	for i in range(0, optNumAvroraRuns):
		if optNumAvroraRuns > 1:
			report("Avrora simulation run #%d for candidate %s\n" % (i, outputPath))
	
		#run avrora simulation
		(avroraOutputFile, traceFilePath) = AvroraLib.runSimulation(nescDir, outputPath, query, numNodes, simulationDuration = duration, networkFilePath = avroraNetFile)

		#check all tuples present
		queryPlanSummaryFile = "%s/%s/query-plan/query-plan-summary.txt" % (outputPath, query)
		checkTupleCount.checkResults(query, traceFilePath, schemaPath, alpha, bufferingFactor, duration)	

		#Report total energy consumption
		siteLifetimeRankFile = "%s/site-lifetime-rank.csv" % nescDir
		(sumEnergy, maxEnergy, averageEnergy, radioEnergy, cpu_cycleEnergy, sensorEnergy, otherEnergy, networkLifetime) = AvroraLib.computeEnergyValues(nescDir, duration, inputFile = "avrora-out.txt", ignoreLedEnergy = True, siteLifetimeRankFile = siteLifetimeRankFile)

		lifetimeDays = UtilLib.secondsToDays(networkLifetime) #Put this into avrora lib so rank file has it too
		
		report ("The total energy consumption is %f" % (sumEnergy))
		normSumEnergy = (float(sumEnergy) / float(duration)) * float(optQueryDuration) #to do: use new function (below)
		report ("The normalized total energy consumption is %f" % (normSumEnergy))
		report ("The lifetime for this network is %f" % (lifetimeDays))

		candidateInfo['total-energy'].append(float(normSumEnergy))
		candidateInfo['network-lifetime'].append(float(lifetimeDays))

	print "DEBUG: testAvroraCandidate.candidateInfo = " + str(candidateInfo)
	return candidateInfo
예제 #7
0
def mainLoop():
    queryFile = queryMap[optQuery]
    networkFile = networkMap[optNetworkSize]
    heteroNet = (optNetworkType == 'B')
    schemaFile = numSourcesMap[optNetworkSize + '_' + optNumSources]
    qosFile = optGoalMap[optOptGoal]
    overallOutputDir = optOutputRoot + '/' + optQuery + '-' + optNetworkSize + 'n-type' + optNetworkType + '-' + optNumSources + 's-' + optOptGoal

    duration = 100
    #	for nn in range(optMinNN,optMaxNN+1):
    for nn in [0, 1, 3, 5, 10, 15, 20]:
        runOutputDir = overallOutputDir + '/nn' + str(nn)

        invokeQueryOptimizer(runOutputDir, queryFile, networkFile, heteroNet,
                             schemaFile, qosFile, nn)
        summary = parseOutFile(runOutputDir + '/' + optQuery +
                               '/query-plan/matlab/wheresched/out' + str(nn) +
                               '.txt')

        if optOptGoal == 'min_delivery':
            #check all tuples present
            queryPlanSummaryFile = "%s/%s/query-plan/query-plan-summary.txt" % (
                runOutputDir, optQuery)

            deliveryTime = SneeqlLib.getDeliveryTime(queryPlanSummaryFile)
            logToDataFile(overallOutputDir, nn, summary['min_f'],
                          float(deliveryTime), summary['num DAFs considered'])
        else:
            #Compile the nesC
            nescDir = runOutputDir + '/' + optQuery + '/avrora1'
            exitVal = AvroraLib.compileNesCCode(nescDir)
            if (exitVal != 0):
                reportError("Error compiling avrora nesC code")
                return
            AvroraLib.generateODs(nescDir)

            #Invoke Avrora simulation
            avroraNetFile = UtilLib.winpath(
                os.getenv('SNEEQLROOT')) + '\\\\' + networkFile.replace(
                    '.xml', '.top')
            (avroraOutputFile, traceFilePath) = AvroraLib.runSimulation(
                nescDir,
                runOutputDir,
                optQuery,
                int(optNetworkSize),
                simulationDuration=duration,
                networkFilePath=avroraNetFile)

            #Check query results
            schemaPath = os.getenv('SNEEQLROOT') + '/' + schemaFile
            checkTupleCount.checkResults(optQuery, traceFilePath, schemaPath,
                                         10000, 1, duration)

            #Report total energy consumption
            siteLifetimeRankFile = "%s/site-lifetime-rank.csv" % nescDir
            (sumEnergy, maxEnergy, averageEnergy, radioEnergy, cpu_cycleEnergy,
             sensorEnergy, otherEnergy,
             networkLifetime) = AvroraLib.computeEnergyValues(
                 runOutputDir,
                 duration,
                 inputFile="avrora-out.txt",
                 ignoreLedEnergy=True,
                 siteLifetimeRankFile=siteLifetimeRankFile)
            report("The total energy consumption is %f" % (sumEnergy))
            report("The lifetime for this network is %f" %
                   (networkLifetime))  #seems to be in seconds

            if optOptGoal == 'min_energy':
                logToDataFile(overallOutputDir, nn, summary['min_f'],
                              float(sumEnergy), summary['num DAFs considered'])
            else:
                logToDataFile(overallOutputDir, nn, summary['min_f'],
                              float(networkLifetime),
                              summary['num DAFs considered'])
예제 #8
0
def testAvroraCandidate(nescDir, query, outputPath, numNodes, duration,
                        schemaPath, aqRate, avroraNetFile, alphaGraph,
                        deltaGraph, epsilonGraph, lambdaGraph):

    #Compile the nesC
    exitVal = AvroraLib.compileNesCCode(nescDir)
    if (exitVal != 0):
        return
    AvroraLib.generateODs(nescDir)

    for i in range(0, optNumAvroraRuns):
        if optNumAvroraRuns > 1:
            report("Avrora simulation run #%d for candidate %s\n" %
                   (i, outputPath))

        #run avrora simulation
        (avroraOutputFile, traceFilePath) = AvroraLib.runSimulation(
            nescDir,
            outputPath,
            query,
            numNodes,
            simulationDuration=duration,
            networkFilePath=avroraNetFile)

        #check all tuples present
        queryPlanSummaryFile = "%s/%s/query-plan/query-plan-summary.txt" % (
            outputPath, query)
        actualBFactor = SneeqlLib.getBufferingFactor(queryPlanSummaryFile)
        checkTupleCount.checkResults(query, traceFilePath, schemaPath, aqRate,
                                     actualBFactor, duration)

        #Report total energy consumption
        siteLifetimeRankFile = "%s/site-lifetime-rank.csv" % nescDir
        (sumEnergy, maxEnergy, averageEnergy, radioEnergy, cpu_cycleEnergy,
         sensorEnergy, otherEnergy,
         networkLifetime) = AvroraLib.computeEnergyValues(
             nescDir,
             duration,
             inputFile="avrora-out.txt",
             ignoreLedEnergy=True,
             siteLifetimeRankFile=siteLifetimeRankFile)
        report("The total energy consumption is %f" % (sumEnergy))
        report("The lifetime for this network is %f" % (networkLifetime))

        candidateInfo = getCandidateSummaryInformation(nescDir, query,
                                                       outputPath)
        print candidateInfo

        rtID = candidateInfo['rt-id'].split("-")[2]
        #TODO: Cross-candidate comparison: plot acquisition interval score vs min possible acq interval
        alphaGraph.add(float(candidateInfo['rt-alpha-score']),
                       float(candidateInfo['pi-ms']) / 1000.0, rtID)
        #TODO: Cross-candidate comparison: plot delivery time score vs simulated total energy
        deltaGraph.add(float(candidateInfo['rt-delta-score']),
                       float(candidateInfo['delta-ms']) / 1000.0, rtID)
        #TODO: Cross-candidate comparison: plot total energy score vs simulated total energy
        epsilonGraph.add(float(candidateInfo['rt-epsilon-score']),
                         float(sumEnergy), rtID)
        #TODO: Cross-candidate comparison: plot lifetime score vs simulated lifetime
        lambdaGraph.add(float(candidateInfo['rt-lambda-score']),
                        UtilLib.secondsToDays(networkLifetime), rtID)