ml4co_kit.task.routing.vrp.cvrpb

Capacitated Vehicle Routing Problem with Backhauls (CVRPB).

Linehaul customers have demands > 0 (delivery from depot); backhaul customers have demands < 0 (pickup to depot). On each route, all linehaul visits precede all backhaul visits. Linehaul load must not exceed capacity; backhaul load must not exceed the remaining capacity (capacity - linehaul_load).

Classes

CVRPBTask(cvrp_open, mixed_backhaul, ...)

class ml4co_kit.task.routing.vrp.cvrpb.CVRPBTask(cvrp_open: bool = False, mixed_backhaul: bool = False, distance_type: ~ml4co_kit.task.routing.base.DISTANCE_TYPE = DISTANCE_TYPE.EUC_2D, round_type: ~ml4co_kit.task.routing.base.ROUND_TYPE = ROUND_TYPE.NO, precision: ~numpy.float32 | ~numpy.float64 = <class 'numpy.float32'>, threshold: float = 0.0001)[source]

Bases: CVRPTask

check_constraints(sol: ndarray) bool[source]

Check if the solution is valid for backhauls.

render(save_path: Path, with_sol: bool = True, figsize: tuple = (5, 5), node_color: str = 'darkblue', edge_color: str = 'darkblue', node_size: int = 50)[source]

Save a matplotlib figure of the instance (and optional solution).

Parameters

save_pathpathlib.Path

Output image path (.png, etc.).

with_solbool, optional

Draw self.sol routes when True; instance only when False.

figsizetuple, optional

Figure size in inches.

node_color, edge_colorstr, optional

Plot colors (used when applicable).

node_sizeint, optional

Scatter marker size for customers.