Example #1
0
	def prepareOperand(self,operand,inputLeadDataDict,executionStack):
		from Utils.Log import Log
		from Utils.TriumphKey import TriumphKey
		if len(executionStack) > 0:
			currentAgentDataDict=executionStack[-1].currentIterationData
		else:
			currentAgentDataDict=None
		if operand.opType == TriumphKey.OperandType.LITERAL:
			return operand.opTag
		elif operand.opType == TriumphKey.OperandType.FEATURE:
			if inputLeadDataDict.has_key(operand.opTag) is True:
				return inputLeadDataDict[operand.opTag]					
			elif currentAgentDataDict is not None:
				#check for data in current execution stack
				Log.d(Allocation.TAG,currentAgentDataDict)
				if currentAgentDataDict.has_key(operand.opTag) is True:
					return currentAgentDataDict[operand.opTag]
				return None
			else:
				#TODO: Ideally allocation type of feature should be handled here
				Log.log(Allocation.TAG,'Could not find data for this feature'+str(operand.opTag))
				return None
		elif operand.opType == TriumphKey.OperandType.OPERATION:
			subRule=operand.subRule[0]
			subRuleName=subRule.operands[0].opTag
			subWorkflow=self.workflowManager.getWorkflow(subRuleName,'tech',0,'sanket')
			if subWorkflow is not None:
				return self.runWorkflow(subWorkflow,inputLeadDataDict,executionStack)
		elif operand.opType == TriumphKey.OperandType.VAR:
			if operand.opTag=='agents':
				agentDataList=[]
				for key,agentData in self.inputAgentsData.iteritems():
					agentDataList.append(agentData)
				return agentDataList
Example #2
0
	def allocate(self):
		from Utils.Log import Log
		from AllocationService import AllocationService
		from Operation import Operation
		# Save rules in a dictionary with key being the index
		#Log.log(Allocation.TAG, 'Input leads data is '+str(self.inputLeadsData))
		for key,value in self.inputLeadsData.iteritems():
			Log.log(Allocation.TAG,'Running loop for '+str(key))
			self.workflowManager=AllocationService.getWorkflowManager()
		 	workflow=self.workflowManager.getWorkflow(self.workflowName,'tech',0,'sanket')
			self.runWorkflow(workflow,value,[])
Example #3
0
	def createExecutionContext(self):			
		from Utils.Log import Log
		from mongoengine import connect
                MONGO_DATABASE_NAME='testdb'
                MONGO_HOST='127.0.0.1'
                MONGO_PORT=27017
                connect('testdb',host=MONGO_HOST,port=MONGO_PORT)
		self.workflowName='termAllocation'
		bu='tech'
		version=0
		developer='sanket'		
                from Executor.ExecutionContext import ExecutionContext
                self.executionContext=ExecutionContext(self.workflowName,bu,version,developer)
                self.executionContext.prepareDB()
                self.executionContext.populateFeatureListObj(self.executionContext.workflow)
		Log.log(Allocation.TAG,'Feature list is '+str(self.executionContext.featureList))
		self.fetchLeadsAndAgentsData()
		self.executionContext.fetchFeatureValueForLeads(self.inputLeadsData,self.inputAgentsData)
Example #4
0
	def fetchLeadsAndAgentsData(self):
		from Utils.Log import Log
		import sys
		this_function_name = sys._getframe().f_code.co_name	
		Log.log(Allocation.TAG,this_function_name)
		from Executor.InputDataExtracter import InputDataExtracter 
		inputDataExtracter=InputDataExtracter()
		inputDataExtracter.setInputLeadsQuery(None)
		inputDataExtracter.setInputAgentsQuery(None)
		self.inputLeadsData=inputDataExtracter.fetchInputLeads()
		self.inputAgentsData=inputDataExtracter.fetchInputAgents()
		self.leadAssignmentData=[] # Contains pair of lead against Agent
		
		if self.inputLeadsData is not None:
			for leadIdKey in self.inputLeadsData.keys():
				self.leadsList.append(leadIdKey)
		else:
			Log.log(Allocation.TAG,'Input leads data is None')
		if self.inputAgentsData is not None:
			for key in self.inputAgentsData.keys():
				pass
Example #5
0
solutions = []
iterationNumber = 0

print("Starting...")

Net = Network(folderName="Topologia1")
allPossibilities = list(map(list, product(range(minimumValue, maximumValue + 1), repeat=sizeOfLinkBundles)))

for individual in allPossibilities:
    print("Iteration Number: " + str(iterationNumber) + "\tpercentage: " + str(round(float(iterationNumber/len(allPossibilities) * 100), 2)))

    result = evaluateNetwork(Net, individual)
    if not result[1] >= 1.1:

        ResultLog.log(result)
    iterationNumber += 1

ResultLog.save()

stopTime = timeit.default_timer()

print('Execution Time:', stopTime - startTime)

with open(fileName + '.txt') as f:
    lines = f.readlines()

solution_list = []
count = 0
for line in lines:
    print('loading file, percentage: \t' + str(round(float(count/len(lines) * 100), 2)))
Example #6
0
                       crossover=IntegerSBXCrossover(probability=0.3,
                                                     distribution_index=20),
                       termination_criterion=StoppingByEvaluationsCustom(
                           max_evaluations=max_evaluations,
                           reference_point=[5000, 2.1],
                           AlgorithmName='Reference')
                       # termination_criterion=stopCriterion
                       )

    progress_bar = ProgressBarObserver(max=max_evaluations)
    algorithm.observable.register(progress_bar)

    algorithm.run()
    solutions = algorithm.get_result()

    for solution in solutions:
        if not solution.objectives[1] >= 1.3:
            solutionsResult.append(solution)

    if executions == (timesToRun - 1):
        frontResult = get_non_dominated_solutions(solutionsResult)
        for sol in frontResult:
            log_front.log(
                str(sol.objectives[0]) + " " + str(sol.objectives[1]))
log_front.save()
plot_front = Plot(title='Pareto front approximation',
                  axis_labels=['Interfaces', 'TIRF'])
plot_front.plot(frontResult, label='NSGAII-OTN')

stopTime = timeit.default_timer()
print('Execution Time:', stopTime - startTime)