job_shop_lib.generation¶
Package for generating job shop instances.
- class InstanceGenerator(num_jobs=(10, 20), num_machines=(5, 10), duration_range=(1, 99), name_suffix='generated_instance', seed=None, iteration_limit=None)[source]¶
Bases:
ABC
Common interface for all generators.
The class supports both single instance generation and iteration over multiple instances, controlled by the iteration_limit parameter. It implements the iterator protocol, allowing it to be used in a for loop.
Note
When used as an iterator, the generator will produce instances until it reaches the specified iteration_limit. If iteration_limit is None, it will continue indefinitely.
- Parameters:
num_jobs (int | tuple[int, int])
num_machines (int | tuple[int, int])
duration_range (tuple[int, int])
name_suffix (str)
seed (int | None)
iteration_limit (int | None)
- num_jobs_range¶
The range of the number of jobs to generate. If a single int is provided, it is used as both the minimum and maximum.
- duration_range¶
The range of durations for each operation.
- num_machines_range¶
The range of the number of machines available. If a single int is provided, it is used as both the minimum and maximum.
- name_suffix¶
A suffix to append to each instance's name for identification.
- seed¶
Seed for the random number generator to ensure reproducibility.
- __init__(num_jobs=(10, 20), num_machines=(5, 10), duration_range=(1, 99), name_suffix='generated_instance', seed=None, iteration_limit=None)[source]¶
Initializes the instance generator with the given parameters.
- Parameters:
num_jobs (int | tuple[int, int]) -- The range of the number of jobs to generate.
num_machines (int | tuple[int, int]) -- The range of the number of machines available.
duration_range (tuple[int, int]) -- The range of durations for each operation.
name_suffix (str) -- Suffix for instance names.
seed (int | None) -- Seed for the random number generator.
iteration_limit (int | None) -- Maximum number of instances to generate in iteration mode.
- abstract generate(num_jobs=None, num_machines=None)[source]¶
Generates a single job shop instance
- Parameters:
num_jobs (int | None) -- The number of jobs to generate. If None, a random value within the specified range will be used.
num_machines (int | None) -- The number of machines to generate. If None, a random value within the specified range will be used.
- Return type:
- property max_num_jobs: int¶
Returns the maximum number of jobs that can be generated.
- property min_num_jobs: int¶
Returns the minimum number of jobs that can be generated.
- property max_num_machines: int¶
Returns the maximum number of machines that can be generated.
- property min_num_machines: int¶
Returns the minimum number of machines that can be generated.
- class GeneralInstanceGenerator(num_jobs=(10, 20), num_machines=(5, 10), duration_range=(1, 99), allow_less_jobs_than_machines=True, allow_recirculation=False, machines_per_operation=1, name_suffix='classic_generated_instance', seed=None, iteration_limit=None)[source]¶
Bases:
InstanceGenerator
Generates instances for job shop problems.
This class is designed to be versatile, enabling the creation of various job shop instances without the need for multiple dedicated classes.
It supports customization of the number of jobs, machines, operation durations, and more.
The class supports both single instance generation and iteration over multiple instances, controlled by the iteration_limit parameter. It implements the iterator protocol, allowing it to be used in a for loop.
Note
When used as an iterator, the generator will produce instances until it reaches the specified iteration_limit. If iteration_limit is None, it will continue indefinitely.
- Parameters:
num_jobs (int | tuple[int, int])
num_machines (int | tuple[int, int])
duration_range (tuple[int, int])
allow_less_jobs_than_machines (bool)
allow_recirculation (bool)
machines_per_operation (int | tuple[int, int])
name_suffix (str)
seed (int | None)
iteration_limit (int | None)
- num_jobs_range¶
The range of the number of jobs to generate. If a single int is provided, it is used as both the minimum and maximum.
- duration_range¶
The range of durations for each operation.
- num_machines_range¶
The range of the number of machines available. If a single int is provided, it is used as both the minimum and maximum.
- machines_per_operation¶
Specifies how many machines each operation can be assigned to. If a single int is provided, it is used for all operations.
- allow_less_jobs_than_machines¶
If True, allows generating instances where the number of jobs is less than the number of machines.
- allow_recirculation¶
If True, a job can visit the same machine more than once.
- name_suffix¶
A suffix to append to each instance's name for identification.
- seed¶
Seed for the random number generator to ensure reproducibility.
- __init__(num_jobs=(10, 20), num_machines=(5, 10), duration_range=(1, 99), allow_less_jobs_than_machines=True, allow_recirculation=False, machines_per_operation=1, name_suffix='classic_generated_instance', seed=None, iteration_limit=None)[source]¶
Initializes the instance generator with the given parameters.
- Parameters:
num_jobs (int | tuple[int, int]) -- The range of the number of jobs to generate.
num_machines (int | tuple[int, int]) -- The range of the number of machines available.
duration_range (tuple[int, int]) -- The range of durations for each operation.
allow_less_jobs_than_machines (bool) -- Allows instances with fewer jobs than machines.
allow_recirculation (bool) -- Allows jobs to visit the same machine multiple times.
machines_per_operation (int | tuple[int, int]) -- Specifies how many machines each operation can be assigned to. If a single int is provided, it is used for all operations.
name_suffix (str) -- Suffix for instance names.
seed (int | None) -- Seed for the random number generator.
iteration_limit (int | None) -- Maximum number of instances to generate in iteration mode.
- generate(num_jobs=None, num_machines=None)[source]¶
Generates a single job shop instance
- Parameters:
num_jobs (int | None) -- The number of jobs to generate. If None, a random value within the specified range will be used.
num_machines (int | None) -- The number of machines to generate. If None, a random value within the specified range will be used.
- Return type: