default='fixed_atoms.txt', type=str, help='Manual specify fixed atom index (start from 0)', required=False) parser.add_argument('-generations', default=1, type=int, help='The network generation index', required=False) args = parser.parse_args() # Read input file input_file = path.abspath(args.file) ard_path = path.dirname(path.abspath(args.file)) reactant_file = path.abspath(args.reactant) kwargs = readInput(input_file) if kwargs['fixed_atoms'] == '1': index = extract_fixed_atoms_index(args.fixed_atoms) kwargs['fixed_atoms'] = index else: kwargs['fixed_atoms'] = None # Manual set up bonds if kwargs['manual_bonds'] == '1': bonds = extract_bonds(args.bonds) kwargs['bonds'] = bonds else: if kwargs['manual_cluster_bond'] == '1': bonds = extract_bonds(args.bonds) kwargs['manual_cluster_bond'] = bonds
print("Unallowed move submitted: "+mov) # Exit otherwise print("Exiting...\n") sys.exit(1) print(gameBoard) if gameBoard.isSolved(): print("The solution is correct!") return gameBoard if __name__ == '__main__': # Reads the board and the solution to verify print("Inserting the board\n") board = Board(*main.readInput()) solution = input("Insert the solution to test\n") # The program is now listening for commands, as specified in helpstr print(helpstr) while True: command = input(">>>(Type 'exit' to terminate) ").split() if command[0] == "exec": verify(board,solution) # Executes the whole solution string elif command[0] == "step": board=verify(board,solution[:1]) # Executes only the next move in solution solution = solution[1:] # The solution string moves ahead by one elif command[0] == "jump": jump = int(command[1]) board=verify(board,solution[:jump]) # Executes the next "jump" moves solution = solution[jump:] # The solution string moves ahead by "jump"
############################################################################### if __name__ == '__main__': import argparse from main import readInput # Set up parser for reading the input filename from the command line parser = argparse.ArgumentParser(description='A freezing string method transition state search') parser.add_argument('-n', '--nproc', default=1, type=int, metavar='N', help='number of processors') parser.add_argument('-m', '--mem', default=2000, type=int, metavar='M', help='memory requirement') parser.add_argument('file', type=str, metavar='infile', help='an input file describing the FSM job options') args = parser.parse_args() # Read input file input_file = os.path.abspath(args.file) options = readInput(input_file) # Set output directory output_dir = os.path.abspath(os.path.dirname(input_file)) options['output_dir'] = output_dir # Set number of processors options['nproc'] = args.nproc options['mem'] = str(args.mem) + 'mb' # Execute job fsm = FSM(**options) fsm.execute()
#!/usr/bin/env python """ 1. Reads the input from an array/text 2. Counts the number of comparison depending on pivot selected 3. """ from main import readInput test, n = readInput("QuickSort.txt") #add m - 1 where m is length of subarray def sortThis(A): n = len(A) - 1 quickSort(A, 0, n) def quickSort(A, start, n): #Partition A around pivot if n > start: pivot_index = partition(A, start, n) #recursively sort 1st part quickSort(A, start, pivot_index - 1) quickSort(A, pivot_index + 1, n) return A def get_pivot(A, low, hi): mid = (hi - low) / 2
# #print "len(sortedA): " + lenA.__str__() # #print "len(sortedB): " + lenB.__str__() # while i < lenA or j < lenB: # k = min(sortedA[i],sortedB[j]) # print "min k: " + k.__str__() # C.append(k) # print "C: " + C.__str__() # if k == sortedB[j]: # j += 1 # inversionCount += lenA - i # else: # i += 1 # #print inversionCount.__str__() # #print C # return C, inversionCount def Solution(A): sortedC, invCount = inversionSortCount(A) return "inversion Count: " + invCount.__str__() # TESTS original, n1 = readInput("testInv1.txt") test = [1, 3, 5, 2, 4, 6] test2 = [1, 3, 4, 2] n2 = len(test) # inversionSortCount(original, n1) print Solution(original)