Skip to content

Start using scheptk

Jose M Framiñán edited this page Nov 25, 2023 · 21 revisions

Installation

scheptk can be installed using PIP. Copy and paste the command to install it from here, or type in the console

pip install scheptk

If you have scheptk already installed, make sure to have the latest version by typing

pip install --upgrade scheptk

The installed version of scheptk can be checked by typing

pip show scheptk

Overview

scheptk contains two main modules:

  • scheptk where the main scheduling classes and their methods are included.
  • util contains a number of functions, some employed by the classes internally.

A typical program runs like this:

from scheptk.scheptk import *
from scheptk.util import *

instance = SingleMachine('test_single.txt')
sequence = sorted_index_asc(instance.dd)
print('EDD sequence for the instance is: ', end='')
print(sequence)
completion_time = instance.SumCj(sequence)
print('The total completion time of the sequence is {}'.format(completion_time))

The program starts by instantiating one of the scheduling layout classes (i.e. SingleMachine, ParallelMachines,UnrelatedMachines, FlowShop, JobShop or OpenShop).Each one of these classes contains all the data that describe a scheduling instance of the corresponding type (such as jobs, processing times, due dates, etc). These data are typically loaded from a text file where they are contained in tags. Here is the content of such text file for a SingleMachine instance:

[JOBS=3]
[PT=10,15,6]
[DD=50,65,60]

In this example, it is defined an instance of a single machine scheduling problem with 3 jobs, each one with the processing times 10,15 and 6, and the due dates 50,65 and 60.

Some of these data (such as the number of jobs and the processing times) are mandatory while others (such as the due dates) are optional. The full list of data for each type of instance is provided here.

Once the data have been loaded into an object, they are accessible as attributes of the class:

print('The number of jobs is {}'.format(instance.jobs))

The full list of attributes for each type of layout can be found here.

A solution for the instance can be entered or computed using some algorithm. This solution can be evaluated regarding the most common scheduling criteria. The list of scheduling criteria supported can be found here

from scheptk.scheptk import *

instance = SingleMachine('test_single.txt')
solution = [1,0,2]
print('The maximum tardiness of the solution is {}'.format(instance.Tmax(solution)))

The first line of the previous example loads the instance of the single machine scheduling problem. The second defines a solution for the problem, in this case a sequence that specifies that job 1 is scheduled first, then job 0 and finally job 2. The third line simply print the maximum tardiness (Tmax) corresponding to the solution.

Obtaining schedules

The corresponding no-idle schedule of the solution of an instance can be obtained using print_schedule(solution). Optionally, this schedule can be printed into a .png or .jpg file as print_schedule(solution, file). The following code:

from scheptk.scheptk import OpenShop

instance = OpenShop('test_openshop.txt')
sol = [7,5,4,0,1,6,3,2,8]
instance.print_schedule(sol)

produces the following schedule:

The manipulation of the schedules and Gantt charts is discussed here.