From 3ccbed4d3a876ff93a7d8e7c8ff326ed328c52cf Mon Sep 17 00:00:00 2001 From: Maximilian Schlosser Date: Wed, 12 Jul 2017 18:17:05 +0200 Subject: [PATCH] pretty printing --- src/Output/output.py | 4 ++-- src/main.py | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Output/output.py b/src/Output/output.py index 6f06aed..2eb31ec 100644 --- a/src/Output/output.py +++ b/src/Output/output.py @@ -1,4 +1,4 @@ -import matplotlib.pyplot as plt +from matplotlib import pyplot as plt from matplotlib import colors from matplotlib import patches import numpy as np @@ -27,4 +27,4 @@ def create_plot(problem, solution): labels = ["Job "+str(j) for j in range(0,problem.jobs)] ax.legend(handles, labels) - plt.show() \ No newline at end of file + plt.show() diff --git a/src/main.py b/src/main.py index 68fe28e..ff46783 100644 --- a/src/main.py +++ b/src/main.py @@ -3,14 +3,13 @@ import sys import getopt from SchedulingAlgorithms import simanneal as sim -from Outpout import output as o def usage(): s= """ Command line options: -h show this help - -p activate pretty output (matplotlib) + -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 @@ -32,6 +31,7 @@ def main(): print(usage()) if ('-p', '') in opts: print("Plotting enabled.") + from Output import output as o plot = True if('-l', '') in opts: js1 = True @@ -48,10 +48,11 @@ def main(): from Parser import js2_style as parser print("Parsing file: " + infile) problem = parser.parse_file(infile) - if js1 and idx == -1: + if js1: print("File contains " + str(len(problem)) + " problems.") - idx = int(input("Which problem do you want so solve? [0-" + str(len(problem)-1) + "] ")) - problem = problem[idx] + 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()