Legendary Output, v1.1
This commit is contained in:
parent
be28f9b11f
commit
d88e5d9e91
|
@ -38,7 +38,8 @@ def accept(solution):
|
||||||
Maybe skip this during the first step to generate a more
|
Maybe skip this during the first step to generate a more
|
||||||
random solution.
|
random solution.
|
||||||
"""
|
"""
|
||||||
return tighten(solution)
|
#return tighten(solution)
|
||||||
|
return solution
|
||||||
|
|
||||||
|
|
||||||
def tighten(solution):
|
def tighten(solution):
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
from matplotlib import colors
|
from matplotlib import colors
|
||||||
|
from matplotlib import patches
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from SchedulingAlgorithms.simanneal import rate
|
from SchedulingAlgorithms.simanneal import rate
|
||||||
|
import random
|
||||||
|
|
||||||
def create_plot(problem, solution):
|
def create_plot(problem, solution):
|
||||||
|
|
||||||
|
@ -9,14 +11,20 @@ def create_plot(problem, solution):
|
||||||
|
|
||||||
with plt.xkcd():
|
with plt.xkcd():
|
||||||
fig,ax = plt.subplots()
|
fig,ax = plt.subplots()
|
||||||
|
colorlist = list(colors.XKCD_COLORS.values())
|
||||||
|
random.shuffle(colorlist)
|
||||||
for m in range(0, problem.machines):
|
for m in range(0, problem.machines):
|
||||||
mach_ops = [ x for x in solution if problem.problem_data[x[1][0]][x[1][1]][1] == m ]
|
mach_ops = [ x for x in solution if problem.problem_data[x[1][0]][x[1][1]][1] == m ]
|
||||||
xranges = [ (x[0], problem.problem_data[x[1][0]][x[1][1]][0]) for x in mach_ops ]
|
xranges = [ (x[0], problem.problem_data[x[1][0]][x[1][1]][0]) for x in mach_ops ]
|
||||||
ax.broken_barh(xranges, ((problem.machines - m)*10, 9),
|
ax.broken_barh(xranges, ((problem.machines - m)*10, 9),
|
||||||
facecolors=[list(colors.XKCD_COLORS.values())[x[1][0]] for x in mach_ops])
|
facecolors=[colorlist[x[1][0]] for x in mach_ops])
|
||||||
ax.set_ylim(5, 5 + (problem.machines+1)*10)
|
ax.set_ylim(5, 5 + (problem.machines+1)*10)
|
||||||
ax.set_xlim(0, 1.25 * end)
|
ax.set_xlim(0, 1.25 * end)
|
||||||
ax.set_yticks([15 + m * 10 for m in range(0, problem.machines)])
|
ax.set_yticks([15 + m * 10 for m in range(0, problem.machines)])
|
||||||
ax.set_yticklabels([ problem.machines - 1 - m for m in range(0, problem.machines)] )
|
ax.set_yticklabels([ problem.machines - 1 - m for m in range(0, problem.machines)] )
|
||||||
|
handlecolors = colorlist[0:problem.jobs]
|
||||||
|
handles = [ patches.Patch(color = handlecolors[j], label = "Job "+str(j)) for j in range(0,problem.jobs) ]
|
||||||
|
labels = ["Job "+str(j) for j in range(0,problem.jobs)]
|
||||||
|
ax.legend(handles, labels)
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
|
@ -1,9 +1,10 @@
|
||||||
from Generator import generator as g
|
#import Parser.js1_style as p
|
||||||
|
import Parser.js2_style as p
|
||||||
from SchedulingAlgorithms import simanneal as sim
|
from SchedulingAlgorithms import simanneal as sim
|
||||||
from Output import output as o
|
from Output import output as o
|
||||||
|
|
||||||
g.mock()
|
#problem = p.parse_file("../inputdata/jobshop1.txt")[0]
|
||||||
problem = g.problem
|
problem = p.parse_file("../inputdata/sample")
|
||||||
sim.init(problem)
|
sim.init(problem)
|
||||||
solution = sim.anneal()
|
solution = sim.anneal()
|
||||||
o.create_plot(problem, solution)
|
o.create_plot(problem, solution)
|
Loading…
Reference in a new issue