JobShop sample#

We start by importing the corresponding jobshop problem module as following :

[31]:
%load_ext autoreload
%autoreload 2
import pyscheduling.JS.JmCmax as js
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

This is an example of instance to test on :

[37]:
f = open("deleteMe.txt",'w')
f.write("3 4\n0\t10\t1\t8\t2\t4\n1\t8\t0\t3\t3\t5\t2\t6\n0\t4\t1\t7\t3\t3")
f.close()

Next, we have to read the instance from the text file created above as follows in the next code cell.

We obviously can randomly generate the instance as well.

[38]:
instance = js.JmCmax_Instance.read_txt("deleteMe.txt")
print(instance.P)

[[(0, 10), (1, 8), (2, 4)], [(1, 8), (0, 3), (3, 5), (2, 6)], [(0, 4), (1, 7), (3, 3)]]

Finally, we use one of the implemented methods which are found in either Heuristics or Metaheuristics classes as following :

[39]:
solution = js.Heuristics.shifting_bottleneck(instance)
print(solution)
Objective : 28
Machine_ID | Job_schedule (job_id , start_time , completion_time) | Completion_time
1 | (0, 0, 10) : (1, 10, 13) : (2, 13, 17) | 17
2 | (1, 0, 8) : (0, 10, 18) : (2, 18, 25) | 25
3 | (0, 18, 22) : (1, 22, 28) | 28
4 | (1, 13, 18) : (2, 25, 28) | 28