discrete_optimization.vrptw.transformations package
Submodules
discrete_optimization.vrptw.transformations.to_generic module
Transformation from VrpTw to GenSchedulingImpl
- class discrete_optimization.vrptw.transformations.to_generic.VrpTwToGenericSchedulingTransformation(nb_closest: int = None, use_predecessors: bool = False, use_first_last: bool = False, factor_matrix: int = 100, relax_time_window: bool = False)[source]
Bases:
ProblemTransformation[VRPTWProblem,VRPTWSolution,GenericSchedulingImplProblem,GenericSchedulingImplSolution]- back_transform_solution(solution: GenericSchedulingImplSolution, source_problem: VRPTWProblem) VRPTWSolution[source]
Convert solution from target problem back to source problem.
This is REQUIRED for all transformations.
- Parameters:
solution – Solution in target problem space
source_problem – Original problem (to associate with back-transformed solution)
- Returns:
Corresponding solution in source problem space
- transform_problem(source_problem: VRPTWProblem) GenericSchedulingImplProblem[source]
Transform source problem to target problem.
This method should be deterministic: same source → same target.
- Parameters:
source_problem – The original problem to transform
- Returns:
Transformed problem instance
discrete_optimization.vrptw.transformations.to_vrp module
Transformation from VRPTW to VRP (lossy - drops time windows).
- class discrete_optimization.vrptw.transformations.to_vrp.VrptwToVrpTransformation[source]
Bases:
ProblemTransformation[VRPTWProblem,VRPTWSolution,Customer2DVrpProblem,VrpSolution]Transform VRPTW to VRP (LOSSY transformation).
Mapping: - Vehicle routes with time windows → Vehicle routes (no time constraints) - Customer demands → Customer demands - Vehicle capacities → Vehicle capacities - Time windows → LOST - Service times → LOST
This is a LOSSY transformation because: - Time window constraints are dropped - Service times are ignored - Solutions from VRP may violate time windows in original VRPTW
Use cases: - Get initial solutions from VRP solvers (faster, simpler) - Benchmark VRP solvers on VRPTW instances (ignoring time) - Analyze impact of time windows by comparing with unconstrained VRP
- back_transform_solution(solution: VrpSolution, source_problem: VRPTWProblem) VRPTWSolution[source]
Transform VRP solution back to VRPTW solution.
- Parameters:
solution – VRP solution
source_problem – Original VRPTW problem
- Returns:
VRPTW solution (may violate time windows!)
Warning
The returned solution may not satisfy time window constraints. Use problem.satisfy() to check feasibility.
- forward_transform_solution(solution: VRPTWSolution, target_problem: Customer2DVrpProblem) VrpSolution | None[source]
Transform VRPTW solution to VRP solution (for warmstart).
- Parameters:
solution – VRPTW solution
target_problem – Target VRP problem
- Returns:
Equivalent VRP solution
- get_forward_metadata() TransformationMetadata[source]
Metadata for forward transformation (VRPTW → VRP).
- transform_problem(source_problem: VRPTWProblem) Customer2DVrpProblem[source]
Transform VRPTW to VRP.
- Parameters:
source_problem – VRPTW problem instance
- Returns:
VRP problem (time windows and service times dropped)
Module contents
Transformations from VRPTW to other problems.
- class discrete_optimization.vrptw.transformations.VrptwToVrpTransformation[source]
Bases:
ProblemTransformation[VRPTWProblem,VRPTWSolution,Customer2DVrpProblem,VrpSolution]Transform VRPTW to VRP (LOSSY transformation).
Mapping: - Vehicle routes with time windows → Vehicle routes (no time constraints) - Customer demands → Customer demands - Vehicle capacities → Vehicle capacities - Time windows → LOST - Service times → LOST
This is a LOSSY transformation because: - Time window constraints are dropped - Service times are ignored - Solutions from VRP may violate time windows in original VRPTW
Use cases: - Get initial solutions from VRP solvers (faster, simpler) - Benchmark VRP solvers on VRPTW instances (ignoring time) - Analyze impact of time windows by comparing with unconstrained VRP
- back_transform_solution(solution: VrpSolution, source_problem: VRPTWProblem) VRPTWSolution[source]
Transform VRP solution back to VRPTW solution.
- Parameters:
solution – VRP solution
source_problem – Original VRPTW problem
- Returns:
VRPTW solution (may violate time windows!)
Warning
The returned solution may not satisfy time window constraints. Use problem.satisfy() to check feasibility.
- forward_transform_solution(solution: VRPTWSolution, target_problem: Customer2DVrpProblem) VrpSolution | None[source]
Transform VRPTW solution to VRP solution (for warmstart).
- Parameters:
solution – VRPTW solution
target_problem – Target VRP problem
- Returns:
Equivalent VRP solution
- get_forward_metadata() TransformationMetadata[source]
Metadata for forward transformation (VRPTW → VRP).
- transform_problem(source_problem: VRPTWProblem) Customer2DVrpProblem[source]
Transform VRPTW to VRP.
- Parameters:
source_problem – VRPTW problem instance
- Returns:
VRP problem (time windows and service times dropped)