ml4co_kit.task.routing.tsp.pctsp

Prize Collecting Traveling Salesman Problem (PCTSP).

The PCTSP requires finding a tour that minimizes the total travel distance plus the penalty for unvisited nodes, while collecting at least a minimum required prize.

Classes

PCTSPTask(distance_type, round_type, ...)

class ml4co_kit.task.routing.tsp.pctsp.PCTSPTask(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 = 1e-05)[source]

Bases: RoutingTaskBase

check_constraints(sol: ndarray) floating[source]

Check if the solution is valid.

evaluate(sol: ndarray, check_constr: bool = True) float[source]

Evaluate the total cost of the PCTSP solution.

from_data(depots: ndarray | None = None, points: ndarray | None = None, penalties: ndarray | None = None, prizes: ndarray | None = None, required_prize: float | None = None, sol: ndarray | None = None, ref: bool = False, normalize: bool = False, name: str | None = None)[source]

Create a problem instance from raw data. To be implemented by subclasses.

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]

Render the PCTSP problem instance with or without solution.