SM Interface Sample#
We start by importing the corresponding module :
[1]:
import pyscheduling.SMSP.interface as sm
We create an instance of Problem class :
[2]:
problem = sm.Problem()
We add constraints :
[3]:
problem.add_constraints([sm.Constraints.W,sm.Constraints.D])
We select an objective :
[4]:
problem.set_objective(sm.Objective.wiTi)
We either create an instance of the corresponding problem or randomly generate it :
[5]:
problem.generate_random(jobs_number=20,Wmax=10)
Finally, we use one of the implemented methods which are found in either Heuristics or Metaheuristics classes as following :
[6]:
solution = problem.solve(problem.heuristics["ACT"])
print(solution)
Search stopped with status : FEASIBLE
Solution is :
Objective : 4361
Job_schedule (job_id , start_time , completion_time) | objective
(8, 0, 9) : (16, 9, 18) : (1, 18, 25) : (5, 25, 34) : (11, 34, 63) : (12, 63, 75) : (6, 75, 98) : (14, 98, 110) : (17, 110, 152) : (13, 152, 160) : (18, 160, 177) : (10, 177, 230) : (7, 230, 272) : (3, 272, 294) : (0, 294, 318) : (2, 318, 331) : (19, 331, 380) : (4, 380, 403) : (15, 403, 438) : (9, 438, 482) | 4361
Runtime is : 0.00017630000002100132s
time to best is : -1s