def main(): # Getting input from user input_class = Input() input_class.get_input() # Solving the system of linear equations got from the user solve = Solve(input_class.coefficient_matrix, input_class.rhs_vector) solve.solve() print("\nThe solution array is: {}".format(solve.solution_matrix[:,0]))
print("|-----------|-----------|-----------|") print(f"| {' | '.join([str(i) if i != 0 else ' ' for i in row])} |") print("|-----------|-----------|-----------|") print(""" The Game """) for row in suduku.game_grid: print("|-----------|-----------|-----------|") print(f"| {' | '.join([str(i) if i != 0 else ' ' for i in row])} |") print("|-----------|-----------|-----------|") solver = Solve(suduku.game_grid) result = solver.solve() print(f""" Solved? {result} """) for row in solver.grid: print("|-----------|-----------|-----------|") print(f"| {' | '.join([str(i) if i != 0 else ' ' for i in row])} |") print("|-----------|-----------|-----------|") # for r,c in solver.choices: # print(f"({r},{c}): {solver.choices[(r,c)]}")
# makes sure that the colors file (colors1.txt or colors2.txt) is specified if (not len(sys.argv) == 2): print "Must specify the \'colors\' file name as an argument." sys.exit(0) # extracts the name of the colors file from the command line argument colorsFile = str(sys.argv[1]) # read the set of allowed colors from the colors file specified on the command line colors = [line.strip() for line in open(colorsFile)] # read the graph to color from "graph.txt" file g = Graph("graph.txt") # initialize the solver (with graph and the set of colors as input) solver = Solve(g, colors) # compute a graph coloring, which is an assignment of colors to nodes in the graph # if there is no feasible coloring solution, the output is an empty list (assignment = []) assignment = solver.solve() # if assignment is an empty list, output "Infeasible\n" to the result.txt file # otherwise (if there is a feasible assignment), output "Feasible\n" to the result.txt f = open('result.txt', 'w') if not assignment: f.write("Infeasible\n") else: f.write("Feasible\n")
from solve import Solve import argparse def parse_arguments(): parser = argparse.ArgumentParser() # Instances parameters parser.add_argument('--n_generator', type=int, default=25) parser.add_argument('--n_device', type=int, default=100) parser.add_argument('--seed', type=int, default=1) return parser.parse_args() if __name__ == '__main__': args = parse_arguments() print("***********************************************************") print("[INFO] EVALUATING THE GENERATOR PROBLEM") print("[INFO] n_generator: %d" % args.n_generator) print("[INFO] n_device': %d" % args.n_device) print("[INFO] seed: %s" % args.seed) print("***********************************************************") solveur = Solve(args.n_generator, args.n_device, args.seed) # solveur.solve_naive() solveur.solve()