discrete_optimization.gpdp.transformations package

Submodules

discrete_optimization.gpdp.transformations.from_tsp module

Transformation from TSP to GPDP (General Pickup and Delivery Problem).

class discrete_optimization.gpdp.transformations.from_tsp.TspToGpdpTransformation(compute_graph: bool = False)[source]

Bases: ProblemTransformation[Point2DTspProblem, TspSolution, GpdpProblem, GpdpSolution]

Transform TSP to GPDP.

TSP is a special case of GPDP with a single vehicle and no capacity constraints.

back_transform_solution(solution: GpdpSolution, source_problem: Point2DTspProblem) TspSolution[source]

Transform GPDP solution back to TSP solution.

forward_transform_solution(solution: TspSolution, target_problem: GpdpProblem) GpdpSolution | None[source]

Transform TSP solution to GPDP solution.

get_forward_metadata() TransformationMetadata[source]

Get metadata for problem transformation (P1 → P2).

Documents what information is lost when transforming the PROBLEM.

Override this method to provide detailed information about: - Constraints that cannot be represented in target problem - Objectives that are ignored or approximated - Assumptions made during transformation

Returns:

TransformationMetadata documenting losses in problem transformation

Default:

Returns exact_transformation() (no losses documented)

Note

Solutions from the target problem always map back MECHANICALLY via back_transform_solution(), but may not satisfy all constraints from the original source problem if this transformation is lossy.

Example: BinPack → SALBP loses incompatibility constraints.

Solutions from SALBP solvers map back to BinPack allocations, but may violate incompatibility if that constraint was present.

Always verify solutions in the original problem after solving via transformation!

transform_problem(source_problem: Point2DTspProblem) GpdpProblem[source]

Transform TSP to GPDP using the existing ProxyClass implementation.

discrete_optimization.gpdp.transformations.from_vrp module

Transformation from VRP to GPDP (General Pickup and Delivery Problem).

class discrete_optimization.gpdp.transformations.from_vrp.VrpToGpdpTransformation(compute_graph: bool = False)[source]

Bases: ProblemTransformation[Customer2DVrpProblem, VrpSolution, GpdpProblem, GpdpSolution]

Transform VRP to GPDP.

Mapping: - VRP vehicles → GPDP vehicles - VRP customers → GPDP transportation nodes - VRP start/end depots → GPDP origin/target nodes (virtual) - VRP capacity → GPDP resource flow (demand) - VRP distances → GPDP distance matrix

VRP is a special case of GPDP where: - No pickup-delivery pairs - Single resource (demand/capacity) - No time windows (use VRPTW → GPDP for time windows)

back_transform_solution(solution: GpdpSolution, source_problem: Customer2DVrpProblem) VrpSolution[source]

Transform GPDP solution back to VRP solution.

Parameters:
  • solution – GPDP solution

  • source_problem – Original VRP problem

Returns:

Equivalent VRP solution

forward_transform_solution(solution: VrpSolution, target_problem: GpdpProblem) GpdpSolution | None[source]

Transform VRP solution to GPDP solution (for warmstart).

Parameters:
  • solution – VRP solution

  • target_problem – Target GPDP problem

Returns:

Equivalent GPDP solution

get_forward_metadata() TransformationMetadata[source]

Metadata for forward transformation (VRP → GPDP).

transform_problem(source_problem: Customer2DVrpProblem) GpdpProblem[source]

Transform VRP to GPDP.

Parameters:

source_problem – VRP problem instance

Returns:

Equivalent GPDP problem

discrete_optimization.gpdp.transformations.from_vrptw module

Transformation from VRPTW to GPDP (General Pickup and Delivery Problem).

class discrete_optimization.gpdp.transformations.from_vrptw.VrptwToGpdpTransformation(compute_graph: bool = False)[source]

Bases: ProblemTransformation[VRPTWProblem, VRPTWSolution, GpdpProblem, GpdpSolution]

Transform VRPTW to GPDP.

VRPTW is a special case of GPDP with time windows and demand constraints.

back_transform_solution(solution: GpdpSolution, source_problem: VRPTWProblem) VRPTWSolution[source]

Transform GPDP solution back to VRPTW solution.

forward_transform_solution(solution: VRPTWSolution, target_problem: GpdpProblem) GpdpSolution | None[source]

Transform VRPTW solution to GPDP solution.

get_forward_metadata() TransformationMetadata[source]

Get metadata for problem transformation (P1 → P2).

Documents what information is lost when transforming the PROBLEM.

Override this method to provide detailed information about: - Constraints that cannot be represented in target problem - Objectives that are ignored or approximated - Assumptions made during transformation

Returns:

TransformationMetadata documenting losses in problem transformation

Default:

Returns exact_transformation() (no losses documented)

Note

Solutions from the target problem always map back MECHANICALLY via back_transform_solution(), but may not satisfy all constraints from the original source problem if this transformation is lossy.

Example: BinPack → SALBP loses incompatibility constraints.

Solutions from SALBP solvers map back to BinPack allocations, but may violate incompatibility if that constraint was present.

Always verify solutions in the original problem after solving via transformation!

transform_problem(source_problem: VRPTWProblem) GpdpProblem[source]

Transform VRPTW to GPDP using the existing ProxyClass implementation.

Module contents

Transformations from routing problems to GPDP (General Pickup and Delivery Problem).

class discrete_optimization.gpdp.transformations.TspToGpdpTransformation(compute_graph: bool = False)[source]

Bases: ProblemTransformation[Point2DTspProblem, TspSolution, GpdpProblem, GpdpSolution]

Transform TSP to GPDP.

TSP is a special case of GPDP with a single vehicle and no capacity constraints.

back_transform_solution(solution: GpdpSolution, source_problem: Point2DTspProblem) TspSolution[source]

Transform GPDP solution back to TSP solution.

forward_transform_solution(solution: TspSolution, target_problem: GpdpProblem) GpdpSolution | None[source]

Transform TSP solution to GPDP solution.

get_forward_metadata() TransformationMetadata[source]

Get metadata for problem transformation (P1 → P2).

Documents what information is lost when transforming the PROBLEM.

Override this method to provide detailed information about: - Constraints that cannot be represented in target problem - Objectives that are ignored or approximated - Assumptions made during transformation

Returns:

TransformationMetadata documenting losses in problem transformation

Default:

Returns exact_transformation() (no losses documented)

Note

Solutions from the target problem always map back MECHANICALLY via back_transform_solution(), but may not satisfy all constraints from the original source problem if this transformation is lossy.

Example: BinPack → SALBP loses incompatibility constraints.

Solutions from SALBP solvers map back to BinPack allocations, but may violate incompatibility if that constraint was present.

Always verify solutions in the original problem after solving via transformation!

transform_problem(source_problem: Point2DTspProblem) GpdpProblem[source]

Transform TSP to GPDP using the existing ProxyClass implementation.

class discrete_optimization.gpdp.transformations.VrpToGpdpTransformation(compute_graph: bool = False)[source]

Bases: ProblemTransformation[Customer2DVrpProblem, VrpSolution, GpdpProblem, GpdpSolution]

Transform VRP to GPDP.

Mapping: - VRP vehicles → GPDP vehicles - VRP customers → GPDP transportation nodes - VRP start/end depots → GPDP origin/target nodes (virtual) - VRP capacity → GPDP resource flow (demand) - VRP distances → GPDP distance matrix

VRP is a special case of GPDP where: - No pickup-delivery pairs - Single resource (demand/capacity) - No time windows (use VRPTW → GPDP for time windows)

back_transform_solution(solution: GpdpSolution, source_problem: Customer2DVrpProblem) VrpSolution[source]

Transform GPDP solution back to VRP solution.

Parameters:
  • solution – GPDP solution

  • source_problem – Original VRP problem

Returns:

Equivalent VRP solution

forward_transform_solution(solution: VrpSolution, target_problem: GpdpProblem) GpdpSolution | None[source]

Transform VRP solution to GPDP solution (for warmstart).

Parameters:
  • solution – VRP solution

  • target_problem – Target GPDP problem

Returns:

Equivalent GPDP solution

get_forward_metadata() TransformationMetadata[source]

Metadata for forward transformation (VRP → GPDP).

transform_problem(source_problem: Customer2DVrpProblem) GpdpProblem[source]

Transform VRP to GPDP.

Parameters:

source_problem – VRP problem instance

Returns:

Equivalent GPDP problem

class discrete_optimization.gpdp.transformations.VrptwToGpdpTransformation(compute_graph: bool = False)[source]

Bases: ProblemTransformation[VRPTWProblem, VRPTWSolution, GpdpProblem, GpdpSolution]

Transform VRPTW to GPDP.

VRPTW is a special case of GPDP with time windows and demand constraints.

back_transform_solution(solution: GpdpSolution, source_problem: VRPTWProblem) VRPTWSolution[source]

Transform GPDP solution back to VRPTW solution.

forward_transform_solution(solution: VRPTWSolution, target_problem: GpdpProblem) GpdpSolution | None[source]

Transform VRPTW solution to GPDP solution.

get_forward_metadata() TransformationMetadata[source]

Get metadata for problem transformation (P1 → P2).

Documents what information is lost when transforming the PROBLEM.

Override this method to provide detailed information about: - Constraints that cannot be represented in target problem - Objectives that are ignored or approximated - Assumptions made during transformation

Returns:

TransformationMetadata documenting losses in problem transformation

Default:

Returns exact_transformation() (no losses documented)

Note

Solutions from the target problem always map back MECHANICALLY via back_transform_solution(), but may not satisfy all constraints from the original source problem if this transformation is lossy.

Example: BinPack → SALBP loses incompatibility constraints.

Solutions from SALBP solvers map back to BinPack allocations, but may violate incompatibility if that constraint was present.

Always verify solutions in the original problem after solving via transformation!

transform_problem(source_problem: VRPTWProblem) GpdpProblem[source]

Transform VRPTW to GPDP using the existing ProxyClass implementation.