コード例 #1
0
ファイル: skyline.py プロジェクト: pplong/undergrate
def adapt_dfs_search(self,end_list,node_map):
	global count
	if len(self.pro_route) == 9:#登龙门,还有一步成功

		sers = [i for i in self.last.next if int(i.name) in end_list]#取sers和可取end的交集
		sers.sort(key = lambda service: service.sum)#按Q排列,大的在后
		if sers != []:
			done = route(self.pro_route + [sers[-1]] , self.QoS_sum + sers[-1].sum)
			
			count = count + 1
			#------add--------
			global best
			global best_route
			if done.QoS_sum > best:
				best = done.QoS_sum
				best_route = done
			#-----------------
		else:
			pass

	elif self.last.next != []:#非空,所以这里不可能是最后一个,pro_route长度不会等于10
		sers = skyline_service_select(self.last.next,len(self.pro_route),node_map) #add: skyline algorithm
		if len(self.pro_route) < 8:
			sers = disable(sers)
		for next in sers:
			count = count + 1
			route(self.pro_route + [next] , self.QoS_sum + next.sum).adapt_dfs_search(end_list,node_map)
コード例 #2
0
ファイル: skyline_bure.py プロジェクト: pplong/undergrate
def run(start,end,node_map,workflow,original_best_QoS):
	#print start,end
	global best
	best = 0
	global count
	#count = 0

	global best_route	
	best_route = None

	start = skyline_service_select([workflow[0][i] for i in start],0,node_map) #add: skyline algorithm
	start = disable(start)
	for index in start:
		#print "start from service: ",index.name
		start_service = index
		test = route([start_service],start_service.sum)
		test.adapt_dfs_search(end,node_map)
		#print count

	if best > original_best_QoS:
		pass
		#print best
		#print "start from: ",best_route.pro_route[0].name ," end at: ",best_route.pro_route[-1].name

	else:
		pass
		#print "Nothing good than fixed"
	#------------add-------------
	return best
コード例 #3
0
ファイル: skyline_bure.py プロジェクト: pplong/undergrate
def adapt_dfs_search_kai(self,end_list,node_map,start,start_strong,start_weak,end,end_strong,end_weak):

	global count
	if len(self.pro_route) == 9:#登龙门,还有一步成功

		sers_kai = []
		def takelist(l):
			sers = [i for i in self.last.next if int(i.name) in l]#取sers和可取end的交集
			sers.sort(key = lambda service: service.sum)#按Q排列,大的在后
			if sers != []:
				sers_kai.append(sers[-1])
		takelist(end)
		takelist(end_strong)
		takelist(end_weak)
		#-----------------
		#保证endfsw至少有一个
		
		#-----------------
		for ser in sers_kai:
			done = route(self.pro_route + [ser] , self.QoS_sum + ser.sum)
			
			count = count + 1

			#------add--------
			global version4_ans
			put_in(done.QoS_sum,int(done.pro_route[0].name),int(done.pro_route[-1].name),start,start_strong,start_weak,end,end_strong,end_weak)
			#-----------------

		else:
			pass

	elif self.last.next != []:#非空,所以这里不可能是最后一个,pro_route长度不会等于10
		sers = skyline_service_select(self.last.next,len(self.pro_route),node_map) #add: skyline algorithm
		if len(self.pro_route) < 8:
			sers = disable(sers)
		for next in sers:
			count = count + 1  #add
			route(self.pro_route + [next] , self.QoS_sum + next.sum).adapt_dfs_search(end_list,node_map,start,start_strong,start_weak,end,end_strong,end_weak)
コード例 #4
0
ファイル: skyline_bure.py プロジェクト: pplong/undergrate
def run_kai(start,start_strong,start_weak,end,end_strong,end_weak,node_map,workflow):

	#-----------------------
	#保证startfsw的必有一个

	#-----------------------
	def sers_to_number(sers):
		ans = []
		for ser in sers:
			ans.append(int(ser.name))
		return ans
	def number_to_sers(number):
		ans = []
		for num in number:
			ans.append(workflow[0][num])
		return ans

	start1 = disable(skyline_service_select([workflow[0][i] for i in start],0,node_map))
	start_strong1 = disable(skyline_service_select([workflow[0][i] for i in start_strong],0,node_map))
	start_weak1 = disable(skyline_service_select([workflow[0][i] for i in start_weak],0,node_map))

	union_start = union3(start1,start_strong1,start_weak1)
	#print union_start
	union_start = unique_kai(union_start)
	#union_start = disable(union_start)
	union_end  = union3(end,end_strong,end_weak)
		
	#print union_start,union_end
	global best
	best = 0
	global count
	count = 0

	global best_route
	best_route = None

	global version4_ans
	version4_ans = [0] * 9

	#union_start = skyline_service_select([workflow[0][i] for i in union_start],0,node_map) #add: skyline algorithm

	for index in union_start:
		#print "start from service: ",index.name
		start_service = index
		test = route([start_service],start_service.sum)
		test.adapt_dfs_search(union_end,node_map,start,start_strong,start_weak,end,end_strong,end_weak)  ###modify
コード例 #5
0
ファイル: skyline.py プロジェクト: pplong/undergrate
			ser_task_down = []
			for pp in fin: #pp is node
				if issub(ser.next_number , pp.next_number):#计算从属关系
					ser_task_down.append(pp)
			fin = fin + [node(sers,ser_task_down,str(len(fin)))]

	return fin

if __name__ == "__main__":
	workflow = gen()
#-----------add-------------
	node_map = map(lambda x: gen_node_list(x),workflow)
#---------------------------
	start = sorted(random_choice(range(10)))
	end = sorted(random_choice(range(10)))
	print start,end


	for index in start:
		start_service = workflow[0][index]
		test = route([start_service],start_service.sum)
		test.adapt_dfs_search(end,node_map)
		print count

	print best
	if best_route != None: 
		best_route.printf()