discrete_optimization.alb.salbp package

Subpackages

Submodules

discrete_optimization.alb.salbp.parser module

discrete_optimization.alb.salbp.parser.get_data_available(data_folder: str | None = None, data_home: str | None = None) list[str][source]

Get datasets available for tsp.

Params:
data_folder: folder where datasets for weighted tardiness problem should be found.

If None, we look in “wt” subdirectory of data_home.

data_home: root directory for all datasets. Is None, set by

default to “~/discrete_optimization_data “

discrete_optimization.alb.salbp.parser.parse_alb_file(file_path: str) SalbpProblem[source]

Parses a .alb file using string splitting and tokenization. No Regular Expressions used.

discrete_optimization.alb.salbp.parser.remove_artifacts(text: str) str[source]

discrete_optimization.alb.salbp.problem module

class discrete_optimization.alb.salbp.problem.SalbpProblem(tasks_data: List[TaskData], cycle_time: int, precedences: List[Tuple[int, int]], number_of_stations: int = None)[source]

Bases: BaseALBProblem[int, int]

Simple Assembly Line Balancing Problem.

Extends BaseALBProblem with cycle time constraints. Uses PrecedenceProblem mixin for precedence graph handling.

cycle_time

Maximum allowed time per station

number_of_tasks

Total number of tasks (for compatibility)

tasks_to_index

Mapping from task_id to index

evaluate(variable: SalbpSolution) Dict[str, float][source]

Evaluate the solution.

Objective: Minimize the number of stations. Constraints: - Cycle time: Each station’s workload must not exceed cycle_time - Precedence: Handled by base class using absolute times

Returns:

  • nb_stations: Number of used stations (objective)

  • penalty_overtime: Sum of time exceeding cycle_time per station

  • penalty_undertime: Sum of idle time per station

  • penalty_precedence: Number of precedence violations (from base)

Return type:

Dictionary with

get_attribute_register() EncodingRegister[source]

Register for standard encoding (optional, but good for GA/CP solvers). We define the solution as a list of integers (station assignments).

get_graph_precedence() Graph[source]

Get precedence graph.

Uses the PrecedenceProblem mixin’s get_precedence_graph() method.

get_objective_register() ObjectiveRegister[source]

Defines the default objective to minimize.

get_solution_type() type[Solution][source]

Returns the class implementation of a Solution.

Returns (class): class object of the given Problem.

get_solution_type_member() SalbpSolution[source]
satisfy(variable: SalbpSolution) bool[source]

Strict check for validity.

class discrete_optimization.alb.salbp.problem.SalbpProblem_1_2(tasks_data: List[TaskData], precedences: List[Tuple[int, int]], number_of_stations: int = None)[source]

Bases: SalbpProblem

Generalisation of SALBP-(1,2) problem.

In this variant, both cycle time and number of stations can be optimized.

evaluate(variable: SalbpSolution) Dict[str, float][source]

Evaluate the solution. Objective: Minimize the number of stations and cycle time

static from_salbp1(problem: SalbpProblem) SalbpProblem_1_2[source]

Create SALBP-1,2 problem from SALBP-1 problem.

get_objective_register() ObjectiveRegister[source]

Defines the default objective to minimize.

satisfy(variable: SalbpSolution) bool[source]

Strict check for validity.

class discrete_optimization.alb.salbp.problem.SalbpSolution(problem: SalbpProblem, allocation_to_station: list[int])[source]

Bases: BaseALBSolution[int, int]

Solution for SALBP problem.

SALBP only assigns tasks to stations without explicit scheduling. Scheduling is computed on-demand using greedy sequential scheduling.

change_problem(new_problem: Problem) Solution[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() SalbpSolution[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.

get_end_time(task: int) int[source]
get_start_time(task: int) int[source]
get_start_time_in_cycle(task: int) int[source]

Get start time within cycle using greedy scheduling.

Since SALBP doesn’t have explicit scheduling, we compute it on-demand and cache the result.

get_station_index(task: int) int[source]

Get the index of the station where task is assigned.

is_allocated(task: int, unary_resource: UnaryResource) bool[source]

Return the usage of the unary resource for the given task.

Parameters:
  • task

  • unary_resource

Returns:

problem: SalbpProblem
discrete_optimization.alb.salbp.problem.calculate_salbp_lower_bounds(problem: SalbpProblem) int[source]

Calculates lower bounds for the SALBP-1 problem. Inspired by: https://github.com/domain-independent-dp/didp-rs

Module contents