discrete_optimization.singlebatch package
Subpackages
- discrete_optimization.singlebatch.solvers package
Submodules
discrete_optimization.singlebatch.problem module
- class discrete_optimization.singlebatch.problem.BatchProcessingSolution(problem: SingleBatchProcessingProblem, job_to_batch: list[int], schedule_batch: list[tuple[int, int]] = None)[source]
Bases:
SchedulingSolution[int]A solution mapping jobs to distinct batches.
- change_problem(new_problem: SingleBatchProcessingProblem) None[source]
If relevant to the optimisation problem, change the underlying problem instance for the solution.
This method can be used to evaluate a solution for different instance of problems. It should be implemented in child classes when caching subresults depending on the problem.
- Parameters:
new_problem (Problem) – another problem instance from which the solution can be evaluated
Returns: None
- copy() BatchProcessingSolution[source]
Deep copy of the solution.
The copy() function should return a new object containing the same input as the current object, that respects the following expected behaviour: -y = x.copy() -if do some inplace change of y, the changes are not done in x.
Returns: a new object from which you can manipulate attributes without changing the original object.
- problem: SingleBatchProcessingProblem
- class discrete_optimization.singlebatch.problem.Job(job_id: int, processing_time: int, size: int)[source]
Bases:
objectRepresentation of a single job to be batched.
- class discrete_optimization.singlebatch.problem.SingleBatchProcessingProblem(jobs: list[Job], capacity: int)[source]
Bases:
SchedulingProblem[int]The Single Batch-Processing Machine Scheduling Problem.
- build_schedule_batch(variable: BatchProcessingSolution) list[tuple[int, int]][source]
- compute_batches_violation(variable: BatchProcessingSolution) int[source]
Returns sum of all batch processing violations.
- compute_processing_time_batch(variable: BatchProcessingSolution) dict[int, int][source]
- evaluate(variable: BatchProcessingSolution) dict[str, float][source]
Calculate the Makespan (Cmax) of the current batching solution.
- get_attribute_register() EncodingRegister[source]
Returns how the Solution should be encoded.
Useful to find automatically available mutations for local search. Used by genetic algorithms Ga and Nsga.
This needs only to be implemented in child classes when GA or LS solvers are to be used.
Returns (EncodingRegister): content of the encoding of the solution
- get_dummy_solution() BatchProcessingSolution[source]
Create a trivial valid solution (one job per batch).
- get_objective_register() ObjectiveRegister[source]
Returns the objective definition.
Returns (ObjectiveRegister): object defining the objective criteria.
- get_solution_type() type[Solution][source]
Returns the class implementation of a Solution.
Returns (class): class object of the given Problem.
- satisfy(variable: BatchProcessingSolution) bool[source]
Check if all capacity constraints are respected.
- property tasks_list: list[int]
List of all tasks to schedule or allocate to.
discrete_optimization.singlebatch.utils module
- class discrete_optimization.singlebatch.utils.GenerationMode(*values)[source]
Bases:
EnumModes for generating job sizes and processing times.
- NEGATIVE_CORRELATION = 'negative'
- POSITIVE_CORRELATION = 'positive'
- RANDOM = 'random'
- discrete_optimization.singlebatch.utils.generate_random_batch_problem(nb_jobs: int = 50, capacity: int = 100, size_range: Tuple[int, int] = (10, 50), duration_range: Tuple[int, int] = (5, 100), mode: GenerationMode = GenerationMode.RANDOM, noise_level: float = 0.2, seed: int = 42) SingleBatchProcessingProblem[source]
Generates a SingleBatchProcessingProblem instance.
- Parameters:
nb_jobs – Number of jobs to generate.
capacity – Maximum capacity of the batch processing machine.
size_range – Tuple (min_size, max_size) for jobs.
duration_range – Tuple (min_duration, max_duration) for jobs.
mode – GenerationMode defining the correlation between size and duration.
noise_level – Float between 0 and 1 defining how much randomness to add to correlated modes.
seed – Random seed for reproducibility.
- Returns:
A populated SingleBatchProcessingProblem.