discrete_optimization.lotsizing.capacitatedmultiitem package

Subpackages

Submodules

discrete_optimization.lotsizing.capacitatedmultiitem.parser module

Parser for capacitated multi-item lot sizing problem instances.

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

Get datasets available for lot sizing.

Parameters:
  • data_folder – folder where datasets for lot sizing should be found. If None, we look in “lotsizing” subdirectory of data_home.

  • data_home – root directory for all datasets. If None, set by default to “~/discrete_optimization_data”

Returns:

List of available instance file paths

discrete_optimization.lotsizing.capacitatedmultiitem.parser.parse_dzn_file(file_path: str) CapacitatedMultiItemLSP[source]

Parse lot sizing problem from .dzn MiniZinc data file.

Expected format:

Periods = <int>; Items = <int>; Demands = [|...|]; % Items x Periods matrix StockingCosts = [<int>, …]; % per item SetupCosts = [|...|]; % Items x Items matrix (changeover costs)

Parameters:

file_path – Path to .dzn file

Returns:

CapacitatedMultiItemLSP instance

discrete_optimization.lotsizing.capacitatedmultiitem.parser.parse_file(file_path: str) CapacitatedMultiItemLSP[source]

Parse lot sizing problem from file.

Automatically detects file format based on extension: - .txt: plain text format - .dzn: MiniZinc data format

Parameters:

file_path – Path to problem file

Returns:

CapacitatedMultiItemLSP instance

discrete_optimization.lotsizing.capacitatedmultiitem.parser.parse_input_data(input_data: str) CapacitatedMultiItemLSP[source]

Parse lot sizing problem from string data (txt format).

Format:

nbPeriods nbItems demands (nbItems lines of nbPeriods boolean integers) stocking cost h [empty line] transition costs (nbItems lines of nbItems integers) [empty line] optimal cost (or bounds)

Parameters:

input_data – String containing the problem data

Returns:

CapacitatedMultiItemLSP instance

discrete_optimization.lotsizing.capacitatedmultiitem.problem module

Capacitated multi-item lot sizing problem with changeover costs.

This problem considers: - Multiple item types - Production capacity constraints - Changeover costs when switching between items - Inventory holding costs - No backlog allowed (hard constraint) - No setup costs, production costs, or setup times

class discrete_optimization.lotsizing.capacitatedmultiitem.problem.CapacitatedMultiItemLSP(nb_items: int, horizon: int, demands: ndarray[tuple[Any, ...], dtype[int64]] | list[list[int]], capacity_machine: int, changeover_costs: ndarray[tuple[Any, ...], dtype[int64]] | list[list[int]], stock_cost_per_type: ndarray[tuple[Any, ...], dtype[float64]] | list[float], stock_capacity: int | None = None, allow_delays: bool = True, delay_cost_per_type: ndarray[tuple[Any, ...], dtype[float64]] | list[float] | None = None, **kwargs: Any)[source]

Bases: WithoutSetupCostsProblem[int], WithoutProductionCostsProblem[int], WithoutSetupTimesProblem[int], WithoutParallelProductionProblem[int], GenericLotSizingProblem[int]

Capacitated multi-item lot sizing problem with changeover costs.

This is the classic lot sizing problem from CSPLib Problem 058: https://www.csplib.org/Problems/prob058/

Features: - Multiple item types (Item = int, item indices) - Production capacity per period (often 1 for binary problems) - Changeover costs when switching between items - Inventory holding costs - Optional backlog/delays (configurable) - No setup costs (no cost to start production) - No production costs (only capacity limits, not per-unit costs) - No setup times (changeovers are instantaneous)

This class composes GenericLotSizingProblem with specific feature mixins. Note: We DON’T inherit from SetupCostsProblem or ProductionCostsProblem because this problem variant doesn’t have those costs.

property allow_backlog: bool

Whether backlog/delays are allowed.

allows_lost_demand() bool[source]
property capacity_machine: int

Production capacity per period.

get_attribute_register() EncodingRegister[source]

Return encoding register for metaheuristic solvers.

get_available_production_time(period: int) float[source]

Get available production time in period.

get_backlog_cost_per_unit(item: int, period: int) float[source]

Get backlog penalty cost per unit.

This cost is always present in the objective (acts as penalty). Whether backlog is allowed as hard constraint is controlled by is_backlog_allowed().

get_changeover_array() list[source]

Get changeover costs as a 2D list.

get_changeover_cost(from_item: int, to_item: int) float[source]

Get sequence-dependent changeover cost.

get_demand(item: int, period: int) int[source]

Get demand for item in period.

get_inventory_cost_per_unit(item: int, period: int) float[source]

Get inventory holding cost per unit.

get_objective_register() ObjectiveRegister[source]

Return objective register.

get_overall_stock_limit(period: int) int | float[source]
get_production_time_per_unit(item: int, period: int) float[source]

Get production time per unit (always 1 for this problem).

get_solution_type() type[Solution][source]

Return the solution class for this problem.

get_stock_limit_for_item(item: Item, period: int) int | float[source]

Get maximum inventory/stock limit for item in period.

Parameters:
  • item – Item identifier

  • period – Time period

Returns:

Maximum allowed inventory S_it (non-negative, may be infinite)

property horizon: int

Number of time periods.

is_backlog_allowed() bool[source]

Check if backlog/delays are allowed as hard constraint.

Returns False means backlog is not allowed (constraint violation). However, backlog costs are still used in the objective as penalties.

property items_list: list[int]

List of item indices.

satisfy(solution: CapacitatedMultiItemSolution) bool[source]

Check if solution satisfies all constraints.

Uses the satisfy_partial method from GenericLotSizingProblem to check: - Demand satisfaction - Capacity constraints - Stock capacity - Unique production times (at most one item per period)

Parameters:

solution – Solution to check

Returns:

True if all constraints are satisfied

class discrete_optimization.lotsizing.capacitatedmultiitem.problem.CapacitatedMultiItemSolution(problem: CapacitatedMultiItemLSP, productions: list[ProductionDecision] | None = None, list_item_per_time: list[int] | None = None)[source]

Bases: WithoutSetupCostsSolution[int], WithoutProductionCostsSolution[int], ProductionBasedSolution[int], WithoutParallelProductionSolution[int]

Solution for capacitated multi-item lot sizing problem.

Inherits from: - ProductionBasedSolution: Automatically computes inventory, deliveries, backlog from productions

(which itself inherits from GenericLotSizingSolution, providing all mixin methods)

  • WithoutSetupCostsSolution: No setup costs in this problem variant

  • WithoutProductionCostsSolution: No per-unit production costs in this problem variant

Features: - Backlog/delays: May be allowed or not (controlled by problem.allow_delays) - Changeover costs: Always present - Inventory costs: Always present - Capacity constraints: Always present

Adds: - list_item_per_time: Alternative representation for binary problems

(for each period, which item type to produce, or nb_items for idle)

copy() Solution[source]

Create a deep copy of the solution.

problem: CapacitatedMultiItemLSP

Module contents

Capacitated multi-item lot sizing problem.

This module implements the capacitated lot sizing problem with multiple items, changeover costs, and inventory constraints.

class discrete_optimization.lotsizing.capacitatedmultiitem.CapacitatedMultiItemLSP(nb_items: int, horizon: int, demands: ndarray[tuple[Any, ...], dtype[int64]] | list[list[int]], capacity_machine: int, changeover_costs: ndarray[tuple[Any, ...], dtype[int64]] | list[list[int]], stock_cost_per_type: ndarray[tuple[Any, ...], dtype[float64]] | list[float], stock_capacity: int | None = None, allow_delays: bool = True, delay_cost_per_type: ndarray[tuple[Any, ...], dtype[float64]] | list[float] | None = None, **kwargs: Any)[source]

Bases: WithoutSetupCostsProblem[int], WithoutProductionCostsProblem[int], WithoutSetupTimesProblem[int], WithoutParallelProductionProblem[int], GenericLotSizingProblem[int]

Capacitated multi-item lot sizing problem with changeover costs.

This is the classic lot sizing problem from CSPLib Problem 058: https://www.csplib.org/Problems/prob058/

Features: - Multiple item types (Item = int, item indices) - Production capacity per period (often 1 for binary problems) - Changeover costs when switching between items - Inventory holding costs - Optional backlog/delays (configurable) - No setup costs (no cost to start production) - No production costs (only capacity limits, not per-unit costs) - No setup times (changeovers are instantaneous)

This class composes GenericLotSizingProblem with specific feature mixins. Note: We DON’T inherit from SetupCostsProblem or ProductionCostsProblem because this problem variant doesn’t have those costs.

property allow_backlog: bool

Whether backlog/delays are allowed.

allows_lost_demand() bool[source]
property capacity_machine: int

Production capacity per period.

get_attribute_register() EncodingRegister[source]

Return encoding register for metaheuristic solvers.

get_available_production_time(period: int) float[source]

Get available production time in period.

get_backlog_cost_per_unit(item: int, period: int) float[source]

Get backlog penalty cost per unit.

This cost is always present in the objective (acts as penalty). Whether backlog is allowed as hard constraint is controlled by is_backlog_allowed().

get_changeover_array() list[source]

Get changeover costs as a 2D list.

get_changeover_cost(from_item: int, to_item: int) float[source]

Get sequence-dependent changeover cost.

get_demand(item: int, period: int) int[source]

Get demand for item in period.

get_inventory_cost_per_unit(item: int, period: int) float[source]

Get inventory holding cost per unit.

get_objective_register() ObjectiveRegister[source]

Return objective register.

get_overall_stock_limit(period: int) int | float[source]
get_production_time_per_unit(item: int, period: int) float[source]

Get production time per unit (always 1 for this problem).

get_solution_type() type[Solution][source]

Return the solution class for this problem.

get_stock_limit_for_item(item: Item, period: int) int | float[source]

Get maximum inventory/stock limit for item in period.

Parameters:
  • item – Item identifier

  • period – Time period

Returns:

Maximum allowed inventory S_it (non-negative, may be infinite)

property horizon: int

Number of time periods.

is_backlog_allowed() bool[source]

Check if backlog/delays are allowed as hard constraint.

Returns False means backlog is not allowed (constraint violation). However, backlog costs are still used in the objective as penalties.

property items_list: list[int]

List of item indices.

satisfy(solution: CapacitatedMultiItemSolution) bool[source]

Check if solution satisfies all constraints.

Uses the satisfy_partial method from GenericLotSizingProblem to check: - Demand satisfaction - Capacity constraints - Stock capacity - Unique production times (at most one item per period)

Parameters:

solution – Solution to check

Returns:

True if all constraints are satisfied

class discrete_optimization.lotsizing.capacitatedmultiitem.CapacitatedMultiItemSolution(problem: CapacitatedMultiItemLSP, productions: list[ProductionDecision] | None = None, list_item_per_time: list[int] | None = None)[source]

Bases: WithoutSetupCostsSolution[int], WithoutProductionCostsSolution[int], ProductionBasedSolution[int], WithoutParallelProductionSolution[int]

Solution for capacitated multi-item lot sizing problem.

Inherits from: - ProductionBasedSolution: Automatically computes inventory, deliveries, backlog from productions

(which itself inherits from GenericLotSizingSolution, providing all mixin methods)

  • WithoutSetupCostsSolution: No setup costs in this problem variant

  • WithoutProductionCostsSolution: No per-unit production costs in this problem variant

Features: - Backlog/delays: May be allowed or not (controlled by problem.allow_delays) - Changeover costs: Always present - Inventory costs: Always present - Capacity constraints: Always present

Adds: - list_item_per_time: Alternative representation for binary problems

(for each period, which item type to produce, or nb_items for idle)

copy() Solution[source]

Create a deep copy of the solution.

problem: CapacitatedMultiItemLSP