#! /usr/bin/env python import sys import getopt from SchedulingAlgorithms import simanneal as sim <<<<<<< HEAD ======= from Output import output as o >>>>>>> origin/devel def usage(): s= """ Command line options: -h show this help -p activate pretty output (requires tkinter) -l assume that a file contains multiple problems, default is only 1 -i index of the problem you want solved. has no effect without l Invocation: python [-hlp] file """ return s def main(): js1 = False plot = False try: opts, args = getopt.getopt(sys.argv[1:], 'hpli:') except getoptGetoptError as err: print(err) sys.exit() if ('-h', '') in opts: print(usage()) if ('-p', '') in opts: print("Plotting enabled.") from Output import output as o plot = True if('-l', '') in opts: js1 = True idx = [int(x[1]) for x in opts if x[0]=='-i'] idx = idx[0] if idx else -1 if not args: print("No file given.") sys.exit() else: infile = args[0] if js1: from Parser import js1_style as parser else: from Parser import js2_style as parser print("Parsing file: " + infile) problem = parser.parse_file(infile) if js1: print("File contains " + str(len(problem)) + " problems.") if idx == -1: idx = int(input("Which problem do you want so solve? [0-" + str(len(problem)-1) + "] ")) problem = problem[idx] print(problem) sim.init(problem) solution = sim.anneal() print(solution) print(sim.rate(solution)) if plot: o.create_plot(problem, solution) if __name__ == "__main__": main()