Data Generator

Instance Factory

This file provides functions to generate scheduling problem instances.

Using this file requires a data_generation config. For example, it is necessary to specify the type of the scheduling problem.

data_generator.instance_factory.generate_instances_from_config(config: dict, print_info: bool = False) List[List[Task]]

Generates a list of raw scheduling instances according to the console

Parameters
  • config – Data_generation config

  • print_info – True if the created instances should be output to the console

Returns

List of raw scheduling problem instances

data_generator.instance_factory.compute_initial_instance_solution(instances: List[List[Task]], config: dict) List[List[Task]]

Initializes multiple processes (optional) to generate deadlines for the raw scheduling problem instances

Parameters
  • instances – List of raw scheduling problem instances

  • config – Data_generation config

Returns

List of scheduling problems instances with set deadlines

data_generator.instance_factory.generate_deadlines(instances: List[List[Task]], instance_with_dead_lines: List[List[Task]], make_span_list: List[List[int]], config: dict) None

Generates suitable deadlines for the input instances

Parameters
  • instances – List of raw scheduling problem instances

  • instance_with_dead_lines – manager.list() (Only in Multi-process case)

  • make_span_list – manager.list() (Only in Multi-process case)

  • config – Data_generation config

Returns

None

data_generator.instance_factory.main(config_file_name=None, external_config=None)
data_generator.instance_factory.get_parser_args()

Get arguments from command line.

Scheduling Problem Factory

Helper function for the instance generation in instance_factory.py.

class data_generator.sp_factory.SP(value)

Bases: Enum

An enumeration.

jssp = '_generate_instance_jssp'
fjssp = '_generate_instance_fjssp'
classmethod is_sp_type_implemented(sp_type: str = '') bool
classmethod str_list_of_sp_types_implemented() List[str]
class data_generator.sp_factory.SPFactory

Bases: object

classmethod generate_instances(num_jobs: int = 2, num_tasks: int = 2, num_machines: int = 2, num_tools: int = 2, num_instances: int = 2, runtimes: Optional[List[int]] = None, sp_type: str = 'jssp', print_info: bool = False, **kwargs) List[List[Task]]

Creates a list of instances with random values in the range of the input parameters

Parameters
  • num_jobs – number of jobs generated in an instance

  • num_tasks – number of tasks per job generated in an instance

  • num_machines – number of machines available

  • num_tools – number of tools available

  • num_instances – number of instances which are to be generated

  • runtimes – list of possible runtimes for tasks

  • sp_type – Scheduling problem type (e.g. “jssp”)

  • print_info – if True additional info printed to console

Returns

List of list of Task instances which together form an instance

classmethod set_deadlines_to_max_deadline_per_job(instances: List[List[Task]], num_jobs: int)

Equals all Task deadlines from one Job according to the one of the last task in the job

Parameters
  • instances – List of instances

  • num_jobs – Number of jobs in an instance

Returns

List of instances with equaled job deadlines

classmethod compute_and_set_hashes(instances: List[List[Task]])

Task Class

This file provides the Task class.

class data_generator.task.Task(job_index: int, task_index: int, machines: Optional[List[int]] = None, tools: Optional[List[int]] = None, deadline: Optional[int] = None, instance_hash: Optional[int] = None, done: Optional[bool] = None, runtime: Optional[int] = None, started: Optional[int] = None, finished: Optional[int] = None, selected_machine: Optional[int] = None, _n_machines: Optional[int] = None, _n_tools: Optional[int] = None, _feasible_machine_from_instance_init: Optional[int] = None, _feasible_order_index_from_instance_init: Optional[int] = None)

Bases: object

This class can be used to model tasks of a scheduling problem. Multiple tasks can be used to model jobs of a scheduling problem.

Parameters
  • job_index – index of the job to which multiple tasks belong

  • task_index – index of the task within the job (unique within job and gives order of tasks)

  • machines – list of machine indices applicable for the specific task (alternatives - pick one)

  • tools – list of tool indices applicable for the specific task (necessary - pick all)

  • deadline – time of deadline for the task

  • instance_hash – Individual hash to represent the instance

  • done – bool to determine status as done

  • runtime – time left for the task

  • started – time the task started at in the schedule

  • finished – time the task finished at in the schedule

  • selected_machine – selected machine index from the machines list for the specific schedule

  • _n_machines – number of all available machines in the scheduling problem instance

  • _n_tools – number of all available tools in the scheduling problem instance

  • _feasible_machine_from_instance_init – index of machine in the given instance generated by initial environment run to generate deadline time

  • _feasible_order_index_from_instance_init – index of task in the given instance generated by initial environment run to generate deadline time

__init__(job_index: int, task_index: int, machines: Optional[List[int]] = None, tools: Optional[List[int]] = None, deadline: Optional[int] = None, instance_hash: Optional[int] = None, done: Optional[bool] = None, runtime: Optional[int] = None, started: Optional[int] = None, finished: Optional[int] = None, selected_machine: Optional[int] = None, _n_machines: Optional[int] = None, _n_tools: Optional[int] = None, _feasible_machine_from_instance_init: Optional[int] = None, _feasible_order_index_from_instance_init: Optional[int] = None)
str_info() str