Benchmark sample#

We start by importing the benchmark module and the corresponding problem module, in the following we will use the single machine interface :

[4]:
import pyscheduling.SMSP.interface as sm
import pyscheduling.benchmark as benchmark

We then create our instances :

[5]:
problem = sm.Problem()
problem.add_constraints([sm.Constraints.W,sm.Constraints.D])
problem.set_objective(sm.Objective.wiTi)
problem.generate_random(jobs_number=20,Wmax=10,InstanceName="testInstance1")
instance1 = problem.instance
problem.generate_random(jobs_number=20,Wmax=10,InstanceName="testInstance2")
instance2 = problem.instance

We run the benchmark using a list of methods :

[7]:
benchmark.run_solver_instance("benchmark_results",[instance1,instance2],problem.heuristics.values())
[7]:
[{'ACT_objective': 11082,
  'ACT_runtime': 0.00030320000001893277,
  'MS_objective': 27122,
  'MS_runtime': 0.0001490000000217151,
  'WSPT_objective': 18189,
  'WSPT_runtime': 6.270000000085929e-05},
 {'ACT_objective': 713,
  'ACT_runtime': 0.0002741999999784639,
  'MS_objective': 1107,
  'MS_runtime': 0.00012420000001611697,
  'WSPT_objective': 1328,
  'WSPT_runtime': 5.040000002054512e-05}]