discrete_optimization.binpack package

Subpackages

Submodules

discrete_optimization.binpack.parser module

discrete_optimization.binpack.parser.get_data_available_bppc(data_folder: str | None = None, data_home: str | None = None) list[str][source]

Get datasets available for knapsack.

Params:
data_folder: folder where datasets for knapsack whould be find.

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

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

default to “~/discrete_optimization_data “

discrete_optimization.binpack.parser.parse_bin_packing_constraint_file(file_path)[source]

Parses a bin packing instance file with incompatibility constraints. (Bin Packing Problem with Conflicts benchmarks from here : https://site.unibo.it/operations-research/en/research/library-of-codes-and-instances-1)

discrete_optimization.binpack.problem module

class discrete_optimization.binpack.problem.BinPackProblem(list_items: list[ItemBinPack], capacity_bin: int, incompatible_items: set[tuple[int, int]] = None)[source]

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

compute_weights(variable: BinPackSolution) dict[int, float][source]
evaluate(variable: BinPackSolution) dict[str, float][source]

Evaluate a given solution object for the given problem.

This method should return a dictionnary of KPI, that can be then used for mono or multiobjective optimization.

Parameters:

variable (Solution) – the Solution object to evaluate.

Returns: dictionnary of float kpi for the 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_makespan_lower_bound() int[source]

Get a lower bound on global makespan.

Default to 0. But can be overriden for problems with more information.

get_makespan_upper_bound() int[source]

Get a upper bound on global makespan.

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: BinPackSolution) bool[source]

Computes if a solution satisfies or not the constraints of the problem.

Parameters:

variable – the Solution object to check satisfability

Returns (bool): boolean true if the constraints are fulfilled, false elsewhere.

property tasks_list: list[int]

List of all tasks to schedule or allocate to.

property unary_resources_list: list[int]

Available unary resources.

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

class discrete_optimization.binpack.problem.BinPackSolution(problem: BinPackProblem, allocation: list[int])[source]

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

copy() BinPackSolution[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: int) bool[source]

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

Parameters:
  • task

  • unary_resource

Returns:

problem: BinPackProblem
class discrete_optimization.binpack.problem.ItemBinPack(index: 'int', weight: 'float')[source]

Bases: object

index: int
weight: float

Module contents