def main(nodes, numberOfTests): for k in range(0, numberOfTests): gen = GraphGen(nodes) g = gen.randomMaxDeg4Graph() partition = Alg.localCutAlg(g) result = Verifier.partitionCheck(g, partition) if len(result[1]) > 1: Verifier.graphDisplay(g, partition, result[1])
def checkNewG(newG, g): localMaxima = bruteForceLocalMaxCut(g).findLocalMinima() verifier = Verifier(newG) for partition in localMaxima: result, nodeSet = verifier.partitionCheck(partition) if result == False: return False return True
def main(): init() for i in range(10): data_quantifier.split_categorical_data(0.4) transformer.transform_secondary_structure() Verifier.verify_validity("conversion") data_quantifier.quantify_data() SVM.create_and_store_svm() Prediction.predict_and_test()
def findLocalMinima(self): n = self.g.order() verifier = Verifier(self.g) localMaxList = [] pset = powerset(n) print(powerset) for subset in pset: result, nodeSet = verifier.partitionCheck(list(subset)) if result == True: localMaxList.append(subset) return(localMaxList) #return list of subsets that are local max
def execute_algorithm(generations,population_size,vector_functions,vector_variables,available_expressions,decimal_precision, community_class,algorithm_class,algorithm_options,representation_class,representation_options, fitness_class,fitness_options,shared_fitness_class,shared_fitness_options,selection_class,selection_options, crossover_class,crossover_options,mutation_class,mutation_options,elitism_amount): result_instances = vr.verify_algorithm_settings(generations,population_size,decimal_precision,community_class,algorithm_class,representation_class, fitness_class,shared_fitness_class,selection_class,crossover_class,mutation_class,elitism_amount) results = [] if "ERROR" in result_instances: for element in algorithm_instances: if "ERROR" not in element: result_instances.remove(perro) results = result_instances else: community_instance = result_instances[0] algorithm_instance = result_instances[1] representation_instance = result_instances[2] fitness_instance = result_instances[3] shared_fitness_instance = result_instances[4] selection_instance = result_instances[5] crossover_instance = result_instances[6] mutation_instance = result_instances[7] results = getattr(algorithm_instance,"execute_moea")(generations,population_size,vector_functions,vector_variables,available_expressions, decimal_precision,community_instance,algorithm_options,representation_instance,representation_options, fitness_instance,fitness_options,shared_fitness_instance,shared_fitness_options, selection_instance,selection_options,crossover_instance,crossover_options, mutation_instance,mutation_options,elitism_amount) return results
def save_features(features_filename,category_location,technique_name,technique_class,technique_method): data = load_features(features_filename) verifier_code = vr.verify_write_xml_features(data,category_location,technique_name,technique_class,technique_method) if verifier_code == "OK": pr.write_xml_features(features_filename,category_location,technique_name,technique_class,technique_method) return verifier_code
def load_features(features_filename): data = None try: data = pr.load_xml_features(features_filename) except: data = "ERROR" return vr.verify_load_xml_features(data)
class Voter(): __v_server = Verifier() __c_server = Counter() def cast_vote(self, vote): yes, no = self.__v_server.genrate_vote() print("User input {0}").format(vote) if vote == 1: self.__c_server.add_vote(yes, 1, self.__v_server) elif vote == 0: self.__c_server.add_vote(no, 0, self.__v_server) else: print "Invalid Input"
def main(): #Se genera el deck prophets_number=2 prophet_turn=1 deck = Deck.generate_deck() board = [] no_world = [] #Se reparten 5 cartas a cada jugador #Primer jugador deck_player = [] for i in range (12): index = random.randint(0,len(deck)-1) deck_player.append(deck[index]) deck.pop(index) player1 = Player(1,deck_player) #Segundo jugador deck_player = [] for i in range (12): index = random.randint(0,len(deck)-1) deck_player.append(deck[index]) deck.pop(index) player2 = Player(1,deck_player) #Se declara al tercer jugador como "dios" player3 = Player(0,None) rule=[] guessed_rule=[] answer = input("Desea poner una regla de colores 1. si 2. no\n") if (answer == 1): rule.append("0") answer = input("Elija una de reglas existentes con colores: \n" +"1. Los colores que elija no estaran permitidos\n" +"2. Un orden de color que usted desea\n") if (answer==1): color_rule = raw_input("Ingrese hasta tres colores que desee prohibir\nY= yellow\nR= red\nB= blue\nG= green\n") rule.append("0") rule.append(color_rule.upper()) else: color_rule = raw_input("Ingrese el orden que desee (si no usa todos los colores, no estaran permitidos)\nY= yellow\nR= red\nB= blue\nG= green\n") rule.append("1") rule.append(color_rule.upper()) else: rule.append(1) answer = input("Elija una de reglas existentes con numeros: \n1. multiplos del numero que usted elija\n2. mayor al numero que usted elija\n3. menor al numero que usted desee\n4. prohibir un numero\n") if (answer==1): number_rule = input("Ingrese el numero que desee menor o igual a 13: ") rule.append("0") rule.append(number_rule) elif (answer == 2): number_rule = input("Ingrese el numero que desee menor o igual a 13: ") rule.append("1") rule.append(number_rule) elif (answer ==3): number_rule = input("Ingrese el numero que desee menor o igual a 13:") rule.append("2") rule.append(number_rule) else: number_rule = input("Ingrese el numero que desea prohibir") rule.append("3") rule.append(number_rule) #Se empieza el juego print ("\n\n----------------------------------------------------------------------------------------") print (" INICIA EL JUEGO") print ("----------------------------------------------------------------------------------------\n\n") #Se coloca la primera carta en el tablero first_card_validity = False while not(first_card_validity): if rule[0] == "0": index = random.randint(0,len(deck)-1) card = deck[index] card_letter = card[len(card)-1] first_card_validity = Verifier.verifyFirstCard(rule,card_letter) else: index = random.randint(0,len(deck)-1) card = deck[index] card_number = card[:len(card)-1] first_card_validity = Verifier.verifyFirstCard(rule,card_number) deck.pop(index) board.append(card) print ("La primera carta es : " + card) print("\n JUGADOR 1, TU TURNO") #Entra en un ciclo, hasta que uno de los jugadores terminen sus cartas o descubran la regla seguiran jugando rule_discovered = False while (player1.getLenCards() > 0) and (player2.getLenCards() > 0) and not(rule_discovered): if prophet_turn == 1: cards_player = player1.getCards() print ("Sus cartas son: ", cards_player) answer = input("\nDesea...\n1. Colocar una carta \n2. Decir que no tiene carta para poner\n") if (answer == 1): valid_card = False while not(valid_card): answer = raw_input("Escriba su carta") letter_answer = answer[len(answer)-1] number_answer = answer[:len(answer)-1] letter_answer = letter_answer.upper() answer= number_answer + letter_answer if answer not in (cards_player): print ("elija una de sus cartas") print (cards_player) else: i=0 for x in cards_player: if x == answer: break i=i+1 valid_card=not(valid_card) if (Verifier.verify_Card(rule,board[len(board)-1],cards_player[i])): print ("Correcto") board.append(cards_player[i]) cards_player.pop(i) player1.setCards(cards_player) answer else: no_world.append((board[len(board)-1]," y ",cards_player[i]," no siguen la regla\n ")) cards_player.pop(i) cards_player.append(deck[random.randint(0,len(deck)-1)]) player1.setCards(cards_player) print("No puedes jugar esa carta, se va al no mundo") prophet_turn2 = 2 print("") print ("El tablero esta de esta forma: ", board) print ("El no mundo es el siguiente: ", no_world) print("") print(" JUGADOR 2, TU TURNO") if prophet_turn2 == 2: cards_player = player2.getCards() print ("Sus cartas son: ", cards_player) answer = input("\nDesea...\n1. Colocar una carta \n2. Decir que no tiene carta para poner\n") if (answer == 1): valid_card = False while not(valid_card): answer = raw_input("Escriba su carta") letter_answer = answer[len(answer)-1] number_answer = answer[:len(answer)-1] letter_answer = letter_answer.upper() answer= number_answer + letter_answer if answer not in (cards_player): print ("elija una de sus cartas") print (cards_player) else: i=0 for x in cards_player: if x == answer: break i=i+1 valid_card=not(valid_card) #Verifica si la carta que selecciono el jugador es correcta if (Verifier.verify_Card(rule,board[len(board)-1],cards_player[i])): print ("Correcto") board.append(cards_player[i]) cards_player.pop(i) player2.setCards(cards_player) else: no_world.append((board[len(board)-1]," y ",cards_player[i]," no siguen la regla\n ")) cards_player.pop(i) cards_player.append(deck[random.randint(0,len(deck)-1)]) player2.setCards(cards_player) print("No puedes jugar esa carta, se va al no mundo") print("") print ("El tablero esta de esta forma: ", board) print ("El no mundo es el siguiente: ", no_world) print("") print(" JUGADOR 1, TU TURNO") prophet_turn2 = 1
def init(): creator.create_training_data() Verifier.verify_validity("extraction") purifier.purify_data() Verifier.verify_validity("purification")
import Verifier as verifier verifier.init()
class Master: io = IO() combinator = Combinator() verifier = Verifier() bs = None interesting = None interactive = None query = os.getcwd().replace("\\", "/")+"/tmp/TWES.q" # Todo: make this adjustable def open_file(self, file): success, self.bs, self.interesting = self.io.open_file(file) if success: self.interactive = self.retrieve_interactive() else: self.interactive = None return success def close_file(self): self.io.close_file() def get_parameters(self): return self.interesting def retrieve_interactive(self): interactive = [] for interest in self.interesting: interactive.append(interest) return interactive def get_interactive(self): return self.interactive def get_bs(self): return self.bs def add_sweep(self, i, begin, end, step): self.combinator.add_sweep(i, begin, end, step) def execute(self): result = {} combinations = self.combinator.get_combinations() # print(combinations) file = None for comb in combinations: # print('interactive = ' + str(self.interactive)) i, val = comb[0], comb[1] param = self.interactive[i] # print('interesting[param] = ' + self.interesting[param]) print('val = ' + str(val)) # print('index = ' + str(i)) # print('param = ' + param) if self.interesting[param] == 'declaration': changer = param[:].split('=') changer[-1] = "= " + str(val) changer = ''.join(changer) # print('changer = ' + changer) file = self.io.create_combination(param, changer) with open(self.query, 'r') as f: print(f.read()) mean = self.verifier.verify(file, self.query) result[str(val)] = mean return result def get_sweeps(self): return self.combinator.get_sweeps() def simulate(self, query): print('simulating!!') result = {} combinations = self.combinator.get_combinations() # print(combinations) file = None for comb in combinations: # print('interactive = ' + str(self.interactive)) i, val = comb[0], comb[1] param = self.interactive[i] # print('interesting[param] = ' + self.interesting[param]) print('val = ' + str(val)) # print('index = ' + str(i)) # print('param = ' + param) if self.interesting[param] == 'declaration': changer = param[:].split('=') changer[-1] = "= " + str(val) changer = ''.join(changer) # print('changer = ' + changer) file = self.io.create_combination(param, changer) # with open(self.query, 'r') as f: # print(f.read()) # q = 'simulate %s [<=50] {%s}' % (str(amount), query) #Todo: Fix hardcode final time res = self.verifier.simulate(file, query) # print('\n\n') # print(res) # print('\n') # print(val) result[val] = res return result
blockchain = blockchain.Blockchain() # the blockchain used in this test # create a test record for a patient patient_test_vc = [ "Administration Date: MAY-01-2021 10:00 AM", "Patient ID: 10132", "Patient Name: John Doe", "Patient Address: 10 Example St. NE", "Administered by: Dr. Jill Fakeington" ] # additional info is non-personally identifying info stored with transaction additional_data = ["Vaccine Type: Pfizer", "Vaccine ID: 1234"] # create the provider provider = Provider.Provider(provider_key) # create the patient patient = Patient.Patient(patient_key) # create the third party verifier verifier = Verifier.Verifier(verifier_key, blockchain) # generate patient vaccine card provider.generate_card(patient_test_vc) # provider posts the transaction to the blockchain provider.post_transaction(blockchain, patient_key.public_key(), additional_data) # a new block is created blockchain.new_block() # provider sends encrypted vaccine care to the patient provider.send_patient_info(patient) # Patient sends encrypted record to the verifier to prove his vaccination patient.send_records(verifier, verifier.get_pub_key()) # verifier verifies the record is in the blockchain verifier.verify_record(blockchain)