discrete_optimization.salbp package

Subpackages

Submodules

discrete_optimization.salbp.parser module

discrete_optimization.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.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.salbp.parser.remove_artifacts(text: str) str[source]

discrete_optimization.salbp.problem module

class discrete_optimization.salbp.problem.SalbpProblem(number_of_tasks: int, cycle_time: int, task_times: Dict[int, int], precedence: List[Tuple[int, int]])[source]

Bases: SchedulingProblem[int], AllocationProblem[int, int]

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

Evaluate the solution. Objective: Minimize the number of stations. Constraint Penalties: Over-cycle time, Precedence violations.

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_last_tasks() list[int][source]

Get a sublist of tasks that are candidate to be the last one scheduled.

Default to all tasks.

get_makespan_upper_bound() int[source]

Get a upper bound on global makespan.

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.

property tasks_list: list[int]

List of all tasks to schedule or allocate to.

property unary_resources_list: list[UnaryResource]

Available unary resources.

It can correspond to employees (rcpsp-multiskill), teams (workforce-scheduling), or a mix of several types.

class discrete_optimization.salbp.problem.SalbpProblem_1_2(number_of_tasks: int, task_times: Dict[int, int], precedence: List[Tuple[int, int]])[source]

Bases: SalbpProblem

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

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

static from_salbp1(problem: SalbpProblem)[source]
get_objective_register() ObjectiveRegister[source]

Defines the default objective to minimize.

satisfy(variable: SalbpSolution) bool[source]

Strict check for validity.

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

Bases: SchedulingSolution[int], AllocationSolution[int, int]

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]
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.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