ml4co_kit.task.routing.tsp.op

Orienteering Problem (OP).

The Orienteering Problem requires finding a path that maximizes the total prize collected while respecting a given time or distance max_length constraint.

Classes

OPTask(distance_type, round_type, precision)

class ml4co_kit.task.routing.tsp.op.OPTask(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

check_constraints(sol: ndarray) bool[source]

Check if the solution is valid.

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

Evaluate the total prize collected by the OP solution.

from_data(depots: ndarray | None = None, points: ndarray | None = None, prizes: ndarray | None = None, max_length: 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 OP problem instance with or without solution.