def __init__(self): cnf = config.CONFIG() # with open(cnf.topologyJson,'r') as json_data: # myjson = json.load(json_data) # json_data.close() # f = open(cnf.topologyJson, 'r') txtjson = f.read() f.close() txtjson = txtjson.replace("Entity.ENTITY_FOG", "\"Entity.ENTITY_FOG\"") txtjson = txtjson.replace("Entity.ENTITY_CLUSTER", "\"Entity.ENTITY_CLUSTER\"") myjson = json.loads(txtjson) print myjson t = Topology() t.load(myjson) devDistanceMatrix = [[0 for j in xrange(len(t.G.nodes))] for i in xrange(len(t.G.nodes))] for i in range(0, len(t.G.nodes)): for j in range(i, len(t.G.nodes)): mylength = nx.shortest_path_length(t.G, source=i, target=j, weight="weight") devDistanceMatrix[i][j] = mylength devDistanceMatrix[j][i] = mylength
def __init__(self, system, populationSeed, evolutionSeed): self.system = system self.cnf = config.CONFIG() self.populationSize = self.cnf.populationSize self.populationPt = pop.POPULATION(self.populationSize) self.mutationProbability = self.cnf.mutationProbability self.rndPOP = random.Random() self.rndEVOL = random.Random() self.rndPOP.seed(populationSeed) self.rndEVOL.seed(evolutionSeed) self.autoAjustedWeight = True self.spreadWeight = 1.0 self.makespanWeight = 1.0 self.spreadMax = 0 self.makespanMin = float('inf') self.TMPspreadMax = 0 self.TMPmakespanMin = float('inf')
#numApps=int(sys.argv[1]) #networkTopology=sys.argv[2] #gatype=sys.argv[3] #executionId=sys.argv[4] #gatype = 'nsga2' numApps = 10 networkTopology = 'scenario/barabasi100.graphml' networkTopology = 'nxgenerated.500' executionId = 'moead500-10' gatype = 'moead' #executionId= datetime.now().strftime('%Y%m%d%H%M%S') file_path = "./" + executionId cnf = config.CONFIG() if cnf.storeData: if not os.path.exists(file_path): os.makedirs(file_path) outputCSV = open(file_path + '/execution_data.csv', 'wb') strTitle = "topology;algorithm;numapss;total;wspr;wmak;wres;spread;makespan;resources" outputCSV.write(strTitle + "\n") f_stdout = open('./log.txt', 'wb') #networkTopologyStr = networkTopology[networkTopology.find("/")+1:networkTopology.find(".")] networkTopologyStr = networkTopology cnf = config.CONFIG() cnf.topologyGraphml = networkTopology cnf.numberOfReplicatedApps = numApps system = systemmodel.SYSTEMMODEL(cnf)
import cv2 import numpy as np import ip_preprocessing as pre import line import CONFIG as cfg import line_to_block as l2b import code_generation as code C = cfg.CONFIG() org, gray = pre.read_img('input/4.png', (0, 3000)) # cut out partial img binary = pre.preprocess(gray, 1) # detect lines lines_h, lines_v = line.detect_line(binary, C.LINE_MIN_LENGTH_HORIZONTAL, C.LINE_MIN_LENGTH_VERTICAL, C.LINE_MAX_THICKNESS, C.LINE_MAX_CROSS_POINT) # divide blocks blocks_h = l2b.divide_blocks_by_lines(lines_h, org.shape[0], C.BLOCK_MIN_HEIGHT) # calculate the hierarchy among blocks hierarchies_h = l2b.hierarchical_blocks(blocks_h) # generate code according to hierarchy html = code.gen_html(blocks_h, hierarchies_h) # save results broad_line = np.zeros(org.shape, dtype=np.uint8) broad_block = np.zeros(org.shape, dtype=np.uint8) line.draw_line(broad_line, lines_h, (0, 255, 0))