Skip to content

Commit 60fa8fc

Browse files
committed
Handles genetic solve method
1 parent 1c01549 commit 60fa8fc

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

app.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def jobs_to_gantt_fig(scheduled_jobs, nb_machines, nb_jobs):
4545
Returns:
4646
Plotly.figure: a plotly figure for generated gantt chart
4747
"""
48-
r = lambda: np.random.randint(0,256, dtype=int)
49-
colors = ['#%02X%02X%02X' % (r(),r(),r()) for _ in range(nb_jobs)]
48+
def r(): return np.random.randint(0, 256, dtype=int)
49+
colors = ['#%02X%02X%02X' % (r(), r(), r()) for _ in range(nb_jobs)]
5050

5151
tasks = []
5252
curr_date = datetime.datetime.now()
@@ -136,6 +136,22 @@ def solve():
136136
)
137137
return response
138138

139+
elif pfsp_algorithm == "genetic-algorithm":
140+
seq, jobs, opt_makespan = problem_inst.genetic_algorithm()
141+
print(type(seq))
142+
print(type(seq[0]))
143+
# exit(0)
144+
fig = jobs_to_gantt_fig(jobs, num_machines, num_jobs)
145+
graph_json = ganttfig_to_json(fig)
146+
resp = json.dumps(
147+
{"graph": graph_json, "optim_makespan": opt_makespan, "opt_seq": seq})
148+
response = app.response_class(
149+
response=resp,
150+
status=200,
151+
mimetype="application/json",
152+
)
153+
return response
154+
139155

140156
@app.route('/random', methods=["POST"])
141157
def random():

0 commit comments

Comments
 (0)