discrete_optimization.workforce.allocation.transformations package
Submodules
discrete_optimization.workforce.allocation.transformations.to_coloring module
Transformation from Workforce Allocation to Graph Coloring (composed transformation).
This module implements WorkforceAllocationToColoringTransformation as a composition of: 1. WorkforceAllocationToListColoringTransformation (direct encoding) 2. ListColoringToColoringTransformation (dummy nodes encoding)
This avoids code duplication and leverages both transformation implementations.
- class discrete_optimization.workforce.allocation.transformations.to_coloring.WorkforceAllocationToColoringTransformation[source]
Bases:
ProblemTransformation[TeamAllocationProblem,TeamAllocationSolution,ColoringProblem,ColoringSolution]Transform Workforce Allocation to Graph Coloring (composed transformation).
This transformation is a COMPOSITION of: 1. WorkforceAllocationToListColoringTransformation (direct encoding) 2. ListColoringToColoringTransformation (dummy nodes encoding)
Mapping (via composition): - Allocation → ListColoring: Tasks → Nodes, Teams → Colors, allowed teams → allowed_colors - ListColoring → Coloring: Add dummy team nodes, edges for forbidden colors
Final encoding: - Tasks → Original nodes in coloring graph - Teams → Dummy nodes (one per team), forming a complete clique - Dummy node k fixed to color k - Forbidden allocations → Edges to dummy team nodes - subset_nodes focuses optimization on tasks only
This is LOSSY (calendar & same_allocation constraints lost) but EXACT for supported constraints.
- back_transform_solution(solution: ColoringSolution, source_problem: TeamAllocationProblem) TeamAllocationSolution[source]
Transform Coloring solution back to Workforce Allocation solution.
- Parameters:
solution – Coloring solution (with dummy nodes)
source_problem – Original TeamAllocationProblem
- Returns:
Equivalent TeamAllocationSolution
- forward_transform_solution(solution: TeamAllocationSolution, target_problem: ColoringProblem) ColoringSolution | None[source]
Transform Allocation solution to Coloring solution (for warmstart).
- Parameters:
solution – TeamAllocationSolution
target_problem – Target Coloring problem (with dummy nodes)
- Returns:
Equivalent ColoringSolution
- get_forward_metadata() TransformationMetadata[source]
Metadata for forward problem transformation (Allocation → Coloring).
This is the composition of two transformations, inheriting losses from step1.
- transform_problem(source_problem: TeamAllocationProblem) ColoringProblem[source]
Transform Workforce Allocation to Coloring via composition.
- Parameters:
source_problem – TeamAllocationProblem instance
- Returns:
ColoringProblem with dummy nodes
discrete_optimization.workforce.allocation.transformations.to_list_coloring module
Transformation from Workforce Allocation to List Coloring (direct approach).
- class discrete_optimization.workforce.allocation.transformations.to_list_coloring.WorkforceAllocationToListColoringTransformation[source]
Bases:
ProblemTransformation[TeamAllocationProblem,TeamAllocationSolution,ListColoringProblem,ColoringSolution]Transform Workforce Allocation to List Coloring (direct approach).
Mapping: - Tasks → Nodes - Teams → Colors (0, 1, 2, …, nb_teams-1) - all_diff_allocation → Edges between tasks - Available teams per task → allowed_colors[task] - Minimize number of teams → Minimize number of colors
This is the cleaner approach using ListColoringProblem directly, without dummy nodes.
This transformation is LOSSY: - Forward (problem): LOSSY - calendar and same_allocation constraints lost - Backward (solution): EXACT - color assignments = team assignments
- back_transform_solution(solution: ColoringSolution, source_problem: TeamAllocationProblem) TeamAllocationSolution[source]
Transform List Coloring solution back to Workforce Allocation solution.
- Parameters:
solution – List Coloring solution
source_problem – Original TeamAllocationProblem
- Returns:
Equivalent TeamAllocationSolution
- forward_transform_solution(solution: TeamAllocationSolution, target_problem: ListColoringProblem) ColoringSolution | None[source]
Transform Allocation solution to List Coloring solution (for warmstart).
- Parameters:
solution – TeamAllocationSolution
target_problem – Target ListColoringProblem
- Returns:
Equivalent ColoringSolution
- get_forward_metadata() TransformationMetadata[source]
Metadata for forward problem transformation (Allocation → ListColoring).
This direction is LOSSY but cleaner than the dummy node approach.
- transform_problem(source_problem: TeamAllocationProblem) ListColoringProblem[source]
Transform Workforce Allocation to List Coloring.
- Parameters:
source_problem – TeamAllocationProblem instance
- Returns:
Equivalent ListColoringProblem
Module contents
Transformations from Workforce Allocation to other problems.
- class discrete_optimization.workforce.allocation.transformations.WorkforceAllocationToColoringTransformation[source]
Bases:
ProblemTransformation[TeamAllocationProblem,TeamAllocationSolution,ColoringProblem,ColoringSolution]Transform Workforce Allocation to Graph Coloring (composed transformation).
This transformation is a COMPOSITION of: 1. WorkforceAllocationToListColoringTransformation (direct encoding) 2. ListColoringToColoringTransformation (dummy nodes encoding)
Mapping (via composition): - Allocation → ListColoring: Tasks → Nodes, Teams → Colors, allowed teams → allowed_colors - ListColoring → Coloring: Add dummy team nodes, edges for forbidden colors
Final encoding: - Tasks → Original nodes in coloring graph - Teams → Dummy nodes (one per team), forming a complete clique - Dummy node k fixed to color k - Forbidden allocations → Edges to dummy team nodes - subset_nodes focuses optimization on tasks only
This is LOSSY (calendar & same_allocation constraints lost) but EXACT for supported constraints.
- back_transform_solution(solution: ColoringSolution, source_problem: TeamAllocationProblem) TeamAllocationSolution[source]
Transform Coloring solution back to Workforce Allocation solution.
- Parameters:
solution – Coloring solution (with dummy nodes)
source_problem – Original TeamAllocationProblem
- Returns:
Equivalent TeamAllocationSolution
- forward_transform_solution(solution: TeamAllocationSolution, target_problem: ColoringProblem) ColoringSolution | None[source]
Transform Allocation solution to Coloring solution (for warmstart).
- Parameters:
solution – TeamAllocationSolution
target_problem – Target Coloring problem (with dummy nodes)
- Returns:
Equivalent ColoringSolution
- get_forward_metadata() TransformationMetadata[source]
Metadata for forward problem transformation (Allocation → Coloring).
This is the composition of two transformations, inheriting losses from step1.
- transform_problem(source_problem: TeamAllocationProblem) ColoringProblem[source]
Transform Workforce Allocation to Coloring via composition.
- Parameters:
source_problem – TeamAllocationProblem instance
- Returns:
ColoringProblem with dummy nodes
- class discrete_optimization.workforce.allocation.transformations.WorkforceAllocationToListColoringTransformation[source]
Bases:
ProblemTransformation[TeamAllocationProblem,TeamAllocationSolution,ListColoringProblem,ColoringSolution]Transform Workforce Allocation to List Coloring (direct approach).
Mapping: - Tasks → Nodes - Teams → Colors (0, 1, 2, …, nb_teams-1) - all_diff_allocation → Edges between tasks - Available teams per task → allowed_colors[task] - Minimize number of teams → Minimize number of colors
This is the cleaner approach using ListColoringProblem directly, without dummy nodes.
This transformation is LOSSY: - Forward (problem): LOSSY - calendar and same_allocation constraints lost - Backward (solution): EXACT - color assignments = team assignments
- back_transform_solution(solution: ColoringSolution, source_problem: TeamAllocationProblem) TeamAllocationSolution[source]
Transform List Coloring solution back to Workforce Allocation solution.
- Parameters:
solution – List Coloring solution
source_problem – Original TeamAllocationProblem
- Returns:
Equivalent TeamAllocationSolution
- forward_transform_solution(solution: TeamAllocationSolution, target_problem: ListColoringProblem) ColoringSolution | None[source]
Transform Allocation solution to List Coloring solution (for warmstart).
- Parameters:
solution – TeamAllocationSolution
target_problem – Target ListColoringProblem
- Returns:
Equivalent ColoringSolution
- get_forward_metadata() TransformationMetadata[source]
Metadata for forward problem transformation (Allocation → ListColoring).
This direction is LOSSY but cleaner than the dummy node approach.
- transform_problem(source_problem: TeamAllocationProblem) ListColoringProblem[source]
Transform Workforce Allocation to List Coloring.
- Parameters:
source_problem – TeamAllocationProblem instance
- Returns:
Equivalent ListColoringProblem