def set_host_bucket(self, host, rate, burst): """set limit of given host""" if host in self.hosts: self.hosts[host].rate = rate self.hosts[host].burst = burst else: self.hosts[host] = domain.Domain(rate=rate, burst=burst)
def get_domains(self): """Get a list of Domains controlled by this Organization. :return: list of :class:`domains <tracker_client.domain.Domain>` controlled by this Organization. :rtype: List[Domain] """ params = {"orgSlug": slugify(self.name), "after": ""} has_next = True domain_list = [] # The maximum number of domains that can be requested at once is 100 # This loop gets 100 domains, checks if there are more, and if there are # it gets another 100 starting after the last domain it got while has_next: result = self.client.execute_query(queries.GET_ORG_DOMAINS, params) if "error" in result: print("Server error: ", result) raise ValueError("Unable to get domains for " + self.name) for edge in result["findOrganizationBySlug"]["domains"]["edges"]: domain_list.append(dom.Domain(self.client, **edge["node"])) has_next = result["findOrganizationBySlug"]["domains"]["pageInfo"][ "hasNextPage"] params["after"] = result["findOrganizationBySlug"]["domains"][ "pageInfo"]["endCursor"] return domain_list
def action_generate_profile(profile_id): with open('/etc/ansible/default_settings.json', 'r') as f: config = json.load(f) dbfile = config['django']['db'] try: conn = sqlite3.connect(dbfile) c = conn.cursor() c.execute("SELECT slug,dyndomain FROM vpn_vpnprofile WHERE id=?",(profile_id,)) data = c.fetchone() if not data: #invalid profile id print 'profile id does not exist in database' return 21 slug = data[0] dyndomain = data[1] if not check_domain(dyndomain): return 24 dyndomain = domain.Domain(data[1]).get_match() filename = os.path.basename(slug) rc = subprocess.call(['/usr/bin/openssl', 'req', '-newkey', 'rsa:2048', '-nodes', '-subj', "/C=AT/ST=Austria/L=Vienna/O=Usable Privacy Box/OU=VPN/CN=%s" % filename, '-keyout', '/etc/openvpn/ca/%sKey.pem' % filename, '-out', '/etc/openvpn/ca/%sReq.pem' % filename]) if rc != 0: print "error while creating client certificate reques" return 23 subprocess.call(['/usr/bin/openssl', 'ca', '-in', '/etc/openvpn/ca/%sReq.pem' % filename, '-days', '730', '-batch', '-out', '/etc/openvpn/ca/%sCert.pem' % filename, '-notext', '-cert', '/etc/openvpn/ca/caCert.pem', '-keyfile', '/etc/openvpn/ca/caKey.pem']) if rc != 0: print "error while creating client certificate" return 23 os.remove('/etc/openvpn/ca/%sReq.pem' % filename) if os.path.isfile(CLIENT_TEMPLATE): with open(CLIENT_TEMPLATE, 'r') as template, open('/etc/openvpn/ca/%sKey.pem' % filename, 'r') as client_key, open('/etc/openvpn/ca/%sCert.pem' % filename, 'r') as client_cert: temp = template.read() temp = temp.replace("#CLIENT_KEY", client_key.read()) temp = temp.replace("#CLIENT_CERT", client_cert.read()) temp = temp.replace("<IP-ADRESS>", dyndomain) c.execute("UPDATE vpn_vpnprofile SET config=? where id=?", (temp, profile_id)) conn.commit() else: print "client template is missing" return 22 conn.close() except Exception as e: print "failed to write to database" print str(e) return 16 return 0
def main(): sender = snd.Sender("http://127.0.0.1") database = dtb.Database() domain = dmn.Domain(sender, database) camera = cmr.Camera(domain) camera.start() camera.close_camera()
def test7(algn, comp): trk = algn.create_track("Binding proteins") trk.place_domain(domain.Domain("SIGMA", type = "MOLECULE"), 50) cdom1 = domain.ConditionalDomain("TSS") cdom1.add_condition( domain.Condition(-40, 0, includes = [domain.Domain("SIGMA")])) rr1 = core.SecondOrderInteraction(cdom1, domain.Domain("RNAP"), None, 1.0) cdom1 = domain.ConditionalDomain("SFBS") cdom1.add_condition( domain.Condition( 0, +29, excludes = [domain.Domain(type = "MOLECULE")])) rr2 = core.SecondOrderInteraction(cdom1, domain.Domain("SIGMA"), None, 1.0) for rr in (rr1, rr2, ): r1, r2 = rr.reactants() print r1.find(algn), comp.num_molecules(r2)
def test5(filename): pool = core.CompartmentSpace(1e-18) print pool.volume() pool.add_molecules(domain.Domain("A"), 10) pool.add_molecules(domain.Domain("B"), 30) print pool.list_domains() print pool.num_molecules(domain.Domain("A")) print pool.num_molecules(domain.Domain("B")) pool.remove_molecules(domain.Domain("B"), 15) pool.remove_molecules(domain.Domain("A"), 10) print pool.list_domains() print pool.num_molecules(domain.Domain("A")) print pool.num_molecules(domain.Domain("B"))
def check_domain(arg): domain_value = domain.Domain(arg) if not domain_value.is_valid(): if not domain_value.has_allowed_length(): print 'the password can only contain up to 255 characters' if not domain_value.has_only_allowed_chars(): print 'the domain must only contain following special characters: %s' % domain_value.get_allowed_chars() return False else: return True
def testSamples_single_eqdst(self): bandstr = mst.MdimStruct([[0.0, 40.0]], [(0, 0)]) dmA = dm.Domain(self.gdS, self.gdB, None, None, True, bandstr) self.assertAlmostEqual(dmA.sample_at([1])[0], 15.0) self.assertAlmostEqual(dmA.measure_at([0]), 10.0) self.assertAlmostEqual(dmA.measure_at([3]), 10.0) return
def testSamples_prod_eqdst(self): bandstr = mst.MdimStruct([[0.0, 40.0]], [(0, 0)]) dmA = dm.Domain(self.gdS, self.gdB, None, None, True, bandstr) dmP = dmA.prod(dmA) self.assertAlmostEqual(dmP.sample_at([1, 1])[0], 15.0) self.assertAlmostEqual(dmP.sample_at([1, 1])[1], 15.0) self.assertAlmostEqual(dmP.measure_at([0, 1]), 100.0) self.assertAlmostEqual(dmP.measure_at([3, 3]), 100.0)
def __init__(self, domain_path, problem_path, solver, print_progress=True, debug=False, profiling=False): # debug = False debug = debug profiling = profiling domain_file = open(domain_path, 'r') problem_file = open(problem_path, 'r') #dom24.print_room() try: domain = dom.Domain(domain_file) init_state = st.State(domainclass=domain, problem_file=problem_file) start_time = time.time() if debug: self.debug(domain, init_state) if profiling: pr = cProfile.Profile() pr.enable() #Solve the problem self.solution = self.solve(init_state, solver, print_progress) if profiling: pr.disable() s = StringIO.StringIO() sortby = 'cumulative' ps = pstats.Stats(pr, stream=s).sort_stats(sortby) ps.print_stats() print s.getvalue() if print_progress: print("--- %s seconds ---" % (time.time() - start_time)) except ValueError as err: print '------------------' for arg in err.args: print arg print '------------------'
def _check_request(self): """Check new task queue""" tasks = {} while len(tasks) < (self.LOOP_LIMIT - 1): try: task = self.newtask_queue.get_nowait() except Queue.Empty: break if isinstance(task, list): _tasks = task else: _tasks = (task, ) for task in _tasks: if not self.task_verify(task): continue if task['taskid'] in self.task_queue[task['project']]: if not task.get('schedule', {}).get('force_update', False): logger.debug( 'ignore newtask %(project)s:%(taskid)s %(url)s', task) continue if task['taskid'] in tasks: if not task.get('schedule', {}).get('force_update', False): continue tasks[task['taskid']] = task for task in itervalues(tasks): if self.INQUEUE_LIMIT and len( self.task_queue[task['project']]) >= self.INQUEUE_LIMIT: logger.debug('overflow task %(project)s:%(taskid)s %(url)s', task) continue _host = task.get('host', '') if _host and _host not in self.hosts: self.hosts[_host] = domain.Domain() oldtask = self.taskdb.get_task(task['project'], task['taskid'], fields=self.merge_task_fields) if oldtask: task = self.on_old_request(task, oldtask) else: task = self.on_new_request(task) return len(tasks)
def __init__(self, possible_Values, row, col, block): global STATIC_NAMING_COUNTER self.name = "v" + str(STATIC_NAMING_COUNTER) STATIC_NAMING_COUNTER += 1 self.domain = domain.Domain(possible_Values) self.row = row self.col = col self.block = block if self.size() == 1: self.modified = True self.unchangeable = True else: self.modified = False self.unchangeable = False self.oldSize = self.size() self.trailOfVariable = trail.masterTrailVariable
def init_instances(): global domain_instance global user_instance global storage_instance global server_instance if domain_instance is None: domain_instance = domain.Domain() if user_instance is None: user_instance = user.User() if storage_instance is None: storage_instance = storage.Storage() if server_instance is None: server_instance = server.Server()
def solveLevel(self, level): """ Solver Level @param level How deep the solver is in its recursion. @throws VariableSelectionException contains some comments that can be uncommented for more in depth analysis """ if self.hassolution: return v = self.selectNextVariable() if (v is None): for var in self.network.variables: if not var.isAssigned(): raise ValueError( "Something happened with the \ variable selection heuristic") self.success() return for i in self.getNextValues(v): self.trail.placeTrailMarker() v.updateDomain(domain.Domain(i)) self.numAssignments += 1 if self.checkConsistency() and self.checkHeuristics(): self.solveLevel(level + 1) if not self.hassolution: for i in self.trail.trailStack: pass self.trail.undo() self.numBacktracks += 1 for i in self.trail.trailStack: pass else: return
def p_domain(p): '''domain : LPAREN DEFINE_KEY domain_structure_def_lst RPAREN''' name = str() requirements, predicates, actions = (), (), () derived_predicates = [] types, constants = {}, {} for d in p[3]: if 'DOMAIN_KEY' in d: name = d[1] elif 'REQUIREMENTS_KEY' in d: requirements = d[1] elif 'TYPES_KEY' in d: types = d[1] elif 'CONSTANTS_KEY' in d: constants = d[1] elif 'PREDICATES_KEY' in d: predicates = d[1] elif 'DERIVED_KEY' in d: derived_predicates.append(d[1]) else: actions = d p[0] = domain.Domain(name, requirements, types, constants, predicates, derived_predicates, actions)
def test3(filename): algn = core.Alignment( sequence_utils.read_sequence(filename), name = "pTAK117", type = "PLASMID") trk = core.Track(algn.size(), algn.is_cyclic()) trk.place_domain(domain.Domain("A"), 1) trk.place_domain(domain.Domain("B"), 2) trk.place_domain(domain.Domain("A"), 3) print trk.list_domains() print trk.states()[: 10] print "removed", trk.remove_domain(1) print trk.list_domains() print trk.states()[: 10] print "removed", trk.remove_domain(2) print trk.list_domains() print trk.states()[: 10] trk.place_domain(domain.Domain("C"), 1) trk.place_domain(domain.Domain("C"), 2) print trk.list_domains() print trk.states()[: 10] print trk.query_domains_by_region(1, 2, +1) print trk.query_domains_by_region(1, 3, +1) trk.place_domain(domain.Domain("D"), 4, 8, +1) print trk.states()[: 10], trk.list_domains()
def feature_hmd(): print("\t提取正规域名的特征值...") #数字占比 file = open(parent_path + '/analysis/all.txt', "r") lines = 0 domains = {} for line in file: lines += 1 part = line.split('.', 2) domain11 = part[1] if domain11 in domains.keys(): domains[domain11] += 1 else: domains[domain11] = 1 file.close() file = open("bmd3.txt", "r") for line in file: line1 = line.split('.')[0] do = domain.Domain(line, 'False') DGA_classifier = DGAClassifier_bmd(do) distance = DGA_classifier.classify() #数字占比 dig_sum = 0 for num in line1: if num.isdigit(): dig_sum += 1 num_ratio = 1.0 * dig_sum / (len(line1)) #不同字母占比 alp_num = 0 alp = [] for num in line1: if num.isalpha() and num not in alp: alp.append(num) alp_num += 1 alp_ratio = 1.0 * alp_num / (len(line1)) #不同数字占比 num_num = 0 dig = [] for num in line1: if num.isdigit() and num not in dig: dig.append(num) num_num += 1 num_ratios = 1.0 * num_num / (len(line1)) #长度 lenth = len(line1) #元音对辅音的比例 vowel = 0 cons = 0 vow = ['a', 'e', 'i', 'o', 'u'] for num in line1: if num.isalpha(): if num in vow: vowel += 1 else: cons += 1 ratio = 1.0 * vowel / (len(line1) + 1) #新特征值 value = 0 alp_flag = 1 num_flag = 1 part = list(line1) for i in range(0, len(part)): if part[i].isdigit() and alp_flag == 0: value += 1 num_flag = 0 alp_flag = 1 elif part[i].isalpha() and num_flag == 0: value += 1 alp_flag = 0 num_flag = 1 elif part[i].isdigit(): alp_flag = 1 num_flag = 0 elif part[i].isalpha(): num_flag = 1 alp_flag = 0 else: continue f = open(parent_path + "/trails/result_bmd.csv", "a") f.write(str(num_ratio)) #shuzi f.write('\t') f.write(str(alp_ratio)) #butong zimu f.write('\t') f.write(str(num_ratios)) #butong shuzi f.write('\t') f.write(str(lenth)) #changdu f.write('\t') f.write(str(ratio)) #yuanyin f.write('\t') f.write(str(value)) #xintezhengzhi f.write('\t' + '1') f.write('\n') f.close() print("\t提取完毕!\n")
def __init__(self, domain = None, symb = None, words = None, rls = None, codmgens = None, dmgens = None, depr = False): if not symb is None: self.core_symb = symb else: self.core_symb = mst.MdimStruct( ['t'], [ (0,0) ] ) if not words is None: self.core_words = words else: self.core_words = cp.deepcopy(self.core_symb) if not domain is None: self.core_dm = domain else: self.core_dm = dm.Domain() if not rls is None: self.rls = cp.deepcopy(rls) else: self.rls = mst.MdimStruct( [ {'t' : {'t' : None, 'f' : get_XX_rule('t', 'f'), 'n': get_Xn_rule('t') }, 'f' : {'t' : get_XX_rule('f', 't'), 'f' : None, 'n': get_Xn_rule('f') }, 'n' : {'t' : get_nX_rule('t'), 'f' : get_nX_rule('f'), 'n': None } } ], [ (0,0) ] ) #Base function codomain generators if not ( codmgens is None ): self.gens = cp.deepcopy(codmgens) else: self.gens = mst.MdimStruct( [ {'t' : {'t' : sgg.get_codm_gen('t', 't'), 'f' : sgg.get_codm_gen('f','t') }, 'f' : {'t' : sgg.get_codm_gen('t', 'f'), 'f' : sgg.get_codm_gen('f', 'f') } } ], [ (0,0) ] ) #Base function domain generators if not dmgens is None: self.dmgens = dmgens else: self.dmgens = mst.MdimStruct( [ {'t' : {'t' : None, 'f' : get_cartes_gen('t', 'f') }, 'f' : {'t' : get_cartes_gen('f', 't'), 'f' : None } } ], [ (0,0) ] ) cards = cp.deepcopy(self.core_dm.ns) self.bsubsp_labels = None for card in cards: new_labels = ls.LabelSet(mst.MdimStruct( [ card[1] ], [ (0,0) ] ) ) if self.bsubsp_labels is None: self.bsubsp_labels = new_labels else: self.bsubsp_labels = self.bsubsp_labels.prod(new_labels) #TODO: remove this deprecated member, as soon as tests will be adapted #to new class structure. if depr: dmgen = self.dmgens.get_obj((0,0))['t']['f'] self.domains = {'t' : self.core_dm, 'f' : dmgen(self.core_dm) } return
import pandas as pd import domain import numpy from scipy.spatial.distance import mahalanobis from linguistic_classifier import * df = pd.read_csv('top1M.txt', engine='python', header=None) df.columns = ['index', 'domain'] list = [] dict = {} linguistic_normality = LinguisticNormality() for do in df['domain']: print '**********now initialize*********', do do = domain.Domain(do, 'False') print '*********complated initialize***********' print '-----------set linguisticfeature_set-----------' features_set = FeatureSet() features_set.set_meaningful_word_ratio( MeaningfulWordsExtractor(do).meaningful_words_ratio()) features_set.set_numerical_characters_ratio( NumericalCharactersExtractor(do).characters_ratio()) features_set.set_character_set(CharacterSetExtractor(do).set()) n_gram_normality_extractor = NGramNormalityExtractor(do) features_set.set_one_gram_normality_score( n_gram_normality_extractor.normality_score(1))
str1 = df.ix[i]['type'] str2 = df.ix[i]['domains'] if str1 in dic1: pass else: dic1[str1] = {} if str1 in dic2: dic2[str1] += 1 else: dic2[str1] = 1 #dic2 store the per type count. try: do = domain.Domain(str2, 'False') except: count4 += 1 DGA_classifier = DGAClassifier(do) distance = DGA_classifier.classify() if dic1[str1].has_key('total_distance'): dic1[str1]['total_distance'] += distance else: dic1[str1]['total_distance'] = distance if distance < 1.99: if dic1[str1].has_key('non_dga_count'): dic1[str1]['non_dga_count'] += 1 else:
str(out_end - out_start) + ' seconds.') def send_class_copy_to_local_node(self): """ send a copy of the class to the global scope. """ return self ray.shutdown() ray.init() o = init.MetaData() o_id = ray.put(o) main = do.Domain(o) #initialization of all fields main.create_var(o.mode_num, 'u', 'v', 'h', 'w', 'vmix_u', 'vmix_v', 'vmix_h', 'nl_u', 'nl_v', 'nl_h', 'gu_nm1', 'gv_nm1', 'gh_nm1', 'gu_nm2', 'gv_nm2', 'gh_nm2') #Simple way to check if domain communication is done right. #Not part of the model. number_grid = False if number_grid: k = 1 for i in range(o.N_y): for j in range(o.N_x): main.vars['u'].write_to_all_modes(np.array(
def solveLevel(self, level): """ Solver Level @param level How deep the solver is in its recursion. @throws VariableSelectionException contains some comments that can be uncommented for more in depth analysis """ # print("=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=") # print("BEFORE ANY SOLVE LEVEL START") # print(self.network) # print("=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=") first = False second = False third = False if self.hassolution: return # Select unassigned variable v = self.selectNextVariable() #print("V SELECTED --> " + str(v)) # check if the assigment is complete if (v == None): # print("!!! GETTING IN V == NONE !!!") for var in self.network.variables: if not var.isAssigned(): raise ValueError( "Something happened with the variable selection heuristic" ) self.success() return # loop through the values of the variable being checked LCV # print("getNextValues(v): " + str(self.getNextValues(v))) for i in self.getNextValues(v): # print("next value to test --> " + str(i)) self.trail.placeTrailMarker() # check a value # print("-->CALL v.updateDomain(domain.Domain(i)) to start to test next value.") v.updateDomain(domain.Domain(i)) self.numAssignments += 1 #print(self.GB()) #if v.name == "v144" and i == 11: # first = True # if input("FIRST Enter to continue") == 'y': # self.step = True #if v.name == "v143" and i == 12: # second = True # if input("SECOND Enter to continue") == 'y': # self.step = True #if v.name == "v142" and i == 10: # third = True # if input("THIRD Enter to continue") == 'y': # self.step = True #if self.step: # input("Enter to continue") # move to the next assignment if self.checkConsistency() and self.checkHeuristics(): self.solveLevel(level + 1) print(self.GB()) # if this assignment failed at any stage, backtrack if not self.hassolution: # print("=======================================") # print("AFTER PROCESSED:") # print(self.network) # print("================ ") # print("self.trail before revert change: ") for i in self.trail.trailStack: pass # print("variable --> " + str(i[0])) # print("domain backup --> " + str(i[1])) # print("================= ") self.trail.undo() self.numBacktracks += 1 # print("REVERT CHANGES:") # print(self.network) # print("================ ") # print("self.trail after revert change: ") for i in self.trail.trailStack: pass # print("variable --> " + str(i[0])) # print("domain backup --> " + str(i[1])) # print("================= ") else: return
def test4(filename): algn = core.Alignment( core.read_sequence(filename), name = "pTAK117", type = "PLASMID") algn.place_domain(domain.Domain("Ptrc", type = "PROMOTER"), 11, 98, +1) algn.place_domain(domain.Domain("PL-s1con", type = "PROMOTER"), 6067, 5496, -1) algn.place_domain(domain.Domain("CI", type = "GENE"), 99, 714, +1) algn.place_domain(domain.Domain("GFP", type = "GENE"), 914, 1630, +1) algn.place_domain(domain.Domain("LacI", type = "GENE"), 5489, 4407, -1) algn.place_domain(domain.Domain("rrn T1", type = "TERMINATOR"), 1846, 1889, +1) algn.place_domain(domain.Domain("rrn T2", type = "TERMINATOR"), 2021, 2048, +1) algn.place_domain(domain.Domain("rrn T1", type = "TERMINATOR"), -1903, -1946, -1) algn.place_domain(domain.Domain("rrn T2", type = "TERMINATOR"), -2078, -2105, -1) algn.place_domain(domain.Domain("TSS", type = "TSS"), 60, 60, +1) # TSS1 algn.place_domain(domain.Domain("TSS", type = "TSS"), -94, -94, -1) # TSS2 algn.place_domain(domain.Domain("Olac", type = "OPERATOR"), 60, 81, +1) algn.place_domain(domain.Domain("OL3", type = "OPERATOR"), 6061, 6045, -1) algn.place_domain(domain.Domain("OL2", type = "OPERATOR"), 6040, 6025, -1) algn.place_domain(domain.Domain("OL1", type = "OPERATOR"), 6016, 6001, -1) algn.place_domain(domain.Domain("SFBS", type = "SFBS"), 24, 53, +1) algn.place_domain(domain.Domain("SFBS", type = "SFBS"), 6027, 5999, -1) print algn.num_domains() doms = algn.query_domains_by_region(-50, 50, +1) print doms print filter(lambda dom: dom.get_attribute("stride") > 0, doms) print filter( lambda dom: dom.get_attribute("type") == "TERMINATOR", algn.query_domains_by_region(-1904, +1847, +1)) return algn
def test6(): volume = 1e-18 comp = core.CompartmentSpace(volume) comp.add_molecules(domain.Domain("RNAP", type = "MOLECULE"), 2000) comp.add_molecules(domain.Domain("SIGMA", type = "MOLECULE"), 1000) return comp
def setUp(self): samp_shf = 0.00 #linear SAMPLE objects ct = 4 lim_t = 31 lbpar_t = cd.LbFixParams( [ct], [lim_t] ) shf_t = samp_shf band_t = 1.0 dt = band_t / ct diff = [dt] shf = [shf_t] band = [band_t] ptpar = cd.PtFixParams(diff, shf, band) lb_t = cd.LbGen(lbpar_t) pt_t = cd.PtGen(ptpar) dim_lb = (0, 0) obj_lb = [lb_t] dims_lb = [dim_lb] mst_lb = mst.MdimStruct(obj_lb, dims_lb) dims_pt = [ (0, 0) ] obj_pt = [pt_t] mst_pt = mst.MdimStruct(obj_pt, dims_pt) genS = gn.Generator(mst_lb, mst_pt) self.gdS = gd.Grid(genS) #BOUNDS diff = [dt] shf = [shf_t - samp_shf] band = [band_t] ptpar = cd.PtFixParams(diff, shf, band) pt_t = cd.PtGen(ptpar) dims_pt = [ (0, 0) ] obj_pt = [pt_t] mst_pt = mst.MdimStruct(obj_pt, dims_pt) genB = gn.Generator(mst_lb, mst_pt) self.gdB = gd.Grid(genB) bandstr = mst.MdimStruct([ [0.0, 1.0] ], [(0,0)]) dmA = dm.Domain(self.gdS, self.gdB, None, None, True, bandstr) self.dmP2d = dmA.prod(dmA) self.dmP3d = self.dmP2d.prod(dmA) #set up codomains T = dmA.bandlims.get_obj((0,0))[1] n = dmA.ns.get_obj((0,0)) dt = T/n shf = 2 phi = 1.0 + 0.0j ampl = 1.0 symb = 't' fcstr = sgl.cyc_stepfc(dt, T, shf, phi, ampl, symb) dims = (0,0) codmstr = mst.MdimStruct( [fcstr], [dims] ) codmA = codm.Codomain(codmstr) shf = 1 fcstr = sgl.cyc_stepfc(dt, T, shf, phi, ampl, symb) dims = (0,0) codmstr = mst.MdimStruct( [fcstr], [dims] ) codmB = codm.Codomain(codmstr) self.codmP2d = codmA.prod(codmB) return
def solveLevel(self, level): """ Solver Level @param level How deep the solver is in its recursion. @throws VariableSelectionException """ # print("=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=") # print("BEFORE ANY SOLVE LEVEL START") # print(self.network) # print("=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=") if self.hassolution: return # Select unassigned variable v = self.selectNextVariable() # print("V SELECTED --> " + str(v)) # check if the assigment is complete if (v == None): # print("!!! GETTING IN V == NONE !!!") for var in self.network.variables: if not var.isAssigned(): raise VariableSelectionException( "Something happened with the variable selection heuristic" ) # print("Something happened with the variable selection heuristic") self.success() return # loop through the values of the variable being checked LCV # print("getNextValues(v): " + str(self.getNextValues(v))) for i in self.getNextValues(v): # print("next value to test --> " + str(i)) self.trail.placeTrailMarker() # check a value # print("-->CALL v.updateDomain(domain.Domain(i)) to start to test next value.") v.updateDomain(domain.Domain(i)) self.numAssignments += 1 # move to the next assignment if self.checkConsistency(): self.solveLevel(level + 1) # if this assignment failed at any stage, backtrack if not self.hassolution: # print("=======================================") # print("AFTER PROCESSED:") # print(self.network) # print("================ ") # print("self.trail before revert change: ") # for i in self.trail.trailStack: # print("variable --> " + str(i[0])) # print("domain backup --> " + str(i[1])) # print("================= ") self.trail.undo() self.numBacktracks += 1 # print("REVERT CHANGES:") # print(self.network) # print("================ ") # print("self.trail after revert change: ") # for i in self.trail.trailStack: # print("variable --> " + str(i[0])) # print("domain backup --> " + str(i[1])) # print("================= ") else: return
def setUp(self): #linear SAMPLE objects ct = 4 lim_t = 31 lbpar_t = cd.LbFixParams( [ct], [lim_t] ) shf_t = 0.0 band_t = 1.0 dt = band_t / ct diff = [dt] shf = [shf_t] band = [band_t] ptpar = cd.PtFixParams(diff, shf, band) lb_t = cd.LbGen(lbpar_t) pt_t = cd.PtGen(ptpar) dim_lb = (0, 0) obj_lb = [lb_t] dims_lb = [dim_lb] mst_lb = mst.MdimStruct(obj_lb, dims_lb) dims_pt = [ (0, 0) ] obj_pt = [pt_t] mst_pt = mst.MdimStruct(obj_pt, dims_pt) genS = gn.Generator(mst_lb, mst_pt) gdS = gd.Grid(genS) #BOUNDS diff = [dt] shf = [shf_t] band = [band_t] ptpar = cd.PtFixParams(diff, shf, band) pt_t = cd.PtGen(ptpar) dims_pt = [ (0, 0) ] obj_pt = [pt_t] mst_pt = mst.MdimStruct(obj_pt, dims_pt) genB = gn.Generator(mst_lb, mst_pt) gdB = gd.Grid(genB) bandstr = mst.MdimStruct( [ [0.0, 1.0] ], [ (0,0) ] ) symb_t = mst.MdimStruct( ['t'], [ (0,0) ] ) dm_t = dm.Domain(gdS, gdB, None, None, True, bandstr) self.table = tb.Table(dm_t, symb_t, None, None, None, None, True) return
df_ConfickerB.columns = ['domains'] df_ConfickerC.columns = ['domains'] df_Torpig.columns = ['domains'] df_Bamital.columns = ['domains'] #################### ConfickerA ########################## count1_A = 0 count1_B = 0 list1_A = [] list1_B = [] for i in range(df_ConfickerA.shape[0]): str1 = df_ConfickerA.ix[i]['domains'] do = domain.Domain(str1,'False') DGA_classifier = DGAClassifier(do) distance = DGA_classifier.classify() print '----------------------distance is ',distance if distance < 1.99: #1.99 count1_A += 1 list1_A.append(str1) # %10 f_ConfickerA.write(str1 + " " + str(distance) + "\n") for i in list1_A: do = domain.Domain(i,'False') DGA_classifier = DGAClassifier(do) distance = DGA_classifier.classify()
import ui as ui import domain as domain import phrasebase as phrasebase import sys, time import parsing as parsing import warnings # stable (gender, age, name) # profile (skills) # context (frustration, attention) # ui = ui.UI() domain = domain.Domain() phrasebase = phrasebase.Phrasebase() parsing = parsing.Parsing() def goodbye(): ui.tell("Goodbye!") sys.exit() def askbreak(): ui.tell("Do you want to continue with this?") answer = ui.listen() if (answer == ""): ui.tell("Do you want to continue? If you don't reply, I have to assume that you are gone...")