def r(list_flops): result = [] res = Resource("res_0") for flop, i in zip(list_flops, range(len(list_flops))): node = Node(res.name + "_node_" + str(i), res, [SoftItem.ANY_SOFT]) node.flops = flop result.append(node) res.nodes = result return [res]
def generate_resources(list_flops): result = [] for nodes_list, j in zip(list_flops, range(len(list_flops))): blade = [] res = Resource("res_" + str(j)) for flop, i in zip(nodes_list, range(len(nodes_list))): node = Node(res.name + "_node_" + str(i), res, [SoftItem.ANY_SOFT]) node.flops = flop blade.append(node) res.nodes = blade result.append(res) return result
def as_schedule(dct): if '__cls__' in dct and dct['__cls__'] == 'Node': res = dct['resource'] node = Node(dct['name'], res, dct['soft']) node.flops = dct['flops'] return node if '__cls__' in dct and dct['__cls__'] == 'ScheduleItem': task = task_dict[dct['job']] scItem = ScheduleItem(task, dct['start_time'], dct['end_time']) scItem.state = dct['state'] return scItem if '__cls__' in dct and dct['__cls__'] == 'Schedule': mapping = {node_values['node']: node_values['value'] for node_values in dct['mapping']} schedule = Schedule(mapping) return schedule if '__cls__' in dct and dct['__cls__'] == 'Resource': res = Resource(dct['name']) res.nodes = dct['nodes'] return res if '__cls__' in dct and dct['__cls__'] == 'SaveBundle': all_nodes = set() for res in dct['dedicated_resources']: for node in res.nodes: node.resource = res all_nodes.update(res.nodes) all_nodes = {node.name: node for node in all_nodes} dct['ga_schedule'].mapping = {all_nodes[node_name]: values for (node_name, values) in dct['ga_schedule'].mapping.items()} bundle = SaveBundle(dct['name'], dct['dedicated_resources'], dct['transfer_mx'], dct['ideal_flops'], dct['ga_schedule'], dct['wf_name']) return bundle return dct
def generate(self): random = Random() resCount = self.rand(random, self.min_res_count, self.max_res_count) resources = list() for i in range(0,resCount): res = Resource("res_" + str(i)) resources.append(res) nodeCount = self.rand(random, self.min_node_count, self.max_node_count) for j in range(0, nodeCount): node = Node(res.name + "_node_" + str(j), res, [SoftItem.ANY_SOFT]) ##TODO: repair it later node.flops = self.rand(random, self.min_flops, self.max_flops) #if j == 0: # node.flops = 10 #if j == 1: # node.flops = 15 #if j == 2: # node.flops = 25 #if j == 3: # node.flops = 30 res.nodes.add(node) return resources
def generate_public_resources(self): ## TODO: remake it later #(public_resources, generate_reliability, generate_probability_law_for_(task,node)_pair) = generate public_resource resCount = 3 resources = list() for i in range(0, resCount): res = Resource("public_res_" + str(i)) resources.append(res) nodeCount = None if i == 0: nodeCount = 15 elif i == 1: nodeCount = 12 elif i == 2: nodeCount = 9 for j in range(0, nodeCount): node = Node(res.name + "_node_" + str(j), res, [SoftItem.ANY_SOFT]) # if j == 0: # node.flops = 10 + 5 # if j == 1: # node.flops = 15 + 10#10*3 # if j == 2: # node.flops = 25 + 10#25*3 # if j == 3: # node.flops = 25 + 10#25*3 # if j == 4: # node.flops = 30 + 10#30*3 # if j == 5: # node.flops = 10 + 5 # if j == 6: # node.flops = 15 + 10#10*3 # if j == 7: # node.flops = 25 + 10#25*3 # if j == 8: # node.flops = 25 + 10#25*3 # if j == 9: # node.flops = 30 + 10#30*3 # if j == 10: # node.flops = 10 + 5 # if j == 11: # node.flops = 15 + 10#10*3 # if j == 12: # node.flops = 25 + 10#25*3 # if j == 13: # node.flops = 25 + 10#25*3 # if j == 14: # node.flops = 30 + 10#30*3 if j == 0: node.flops = 10 if j == 1: node.flops = 15#10*3 if j == 2: node.flops = 25#25*3 if j == 3: node.flops = 25#25*3 if j == 4: node.flops = 30#30*3 if j == 5: node.flops = 10 if j == 6: node.flops = 15#10*3 if j == 7: node.flops = 25#25*3 if j == 8: node.flops = 25#25*3 if j == 9: node.flops = 30#30*3 if j == 10: node.flops = 10 if j == 11: node.flops = 15#10*3 if j == 12: node.flops = 25#25*3 if j == 13: node.flops = 25#25*3 if j == 14: node.flops = 30#30*3 res.nodes.add(node) nodes = HeftHelper.to_nodes(resources) reliability_map = {node.name: 0.9 for node in nodes} def probability_estimator(dt, comp_estimation, transfer_estimation): M = comp_estimation + transfer_estimation sigma = 0.1 * M result = 0.5 *(1 + math.erf((dt - M)/sigma)) return result return (resources, reliability_map, probability_estimator)