Merge branch 'main' of PSSAI_Team/JobShopScheduling into devel

merge
maxschlosser 2017-07-12 17:55:30 +02:00 committed by Gitea
commit a719dd974c
1 changed files with 62 additions and 3 deletions

View File

@ -1,6 +1,65 @@
#! /usr/bin/env python
def main() -> None:
pass
if "__name__" == "__main__":
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)
-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.")
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 and idx == -1:
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]
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()