ml4co_kit.task.routing.tsp.tsp
Traveling Salesman Problem (TSP).
TSP requires finding the shortest tour that visits each vertex of the graph exactly once and returns to the starting node.
Classes
|
- class ml4co_kit.task.routing.tsp.tsp.TSPTask(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'>)[source]
Bases:
RoutingTaskBase- static edges_to_node_pairs(edge_target: ndarray)[source]
Helper function to convert edge matrix into pairs of adjacent nodes.
- evaluate(sol: ndarray, check_constr: bool = True) floating[source]
Evaluate the total distance of the TSP solution.
- from_data(points: ndarray | 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.
- from_tsplib(tsp_file_path: Path | None = None, tour_file_path: Path | None = None, ref: bool = False, normalize: bool = False)[source]
Load TSP data from a TSPLIB file.