ml4co_kit.task.routing.base
Base task classes for routing problems (TSP, VRP, etc.).
Provides distance metrics (DISTANCE_TYPE, ROUND_TYPE,
DistanceEvaluator) and RoutingTaskBase, which extends
TaskBase with a distance evaluator.
Classes
|
Define the distance types as an enumeration. |
|
Distance evaluator for different distance types. |
|
Define the rounding types as an enumeration. |
|
Base class for routing tasks defined on node coordinates. |
- class ml4co_kit.task.routing.base.DISTANCE_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
str,EnumDefine the distance types as an enumeration.
- ATT = 'ATT'
- EUC_2D = 'EUC_2D'
- EUC_3D = 'EUC_3D'
- GEO = 'GEO'
- MAN_2D = 'MAN_2D'
- MAN_3D = 'MAN_3D'
- MAX_2D = 'MAX_2D'
- MAX_3D = 'MAX_3D'
- class ml4co_kit.task.routing.base.DistanceEvaluator(distance_type: DISTANCE_TYPE, round_type: ROUND_TYPE, geo_radius: float = 6371.393)[source]
Bases:
objectDistance evaluator for different distance types.
- static att(start: ndarray, end: ndarray)[source]
Return the Att distance between start and end points.
- cal_dist_matrix(coords: ndarray) ndarray[source]
Calculate the distance matrix for the given coordinates.
- cal_distance(start: ndarray, end: ndarray) float[source]
Return the distance based on the specified distance type.
- static euclidean(start: ndarray, end: ndarray)[source]
Return the Euclidean distance between start and end points.
- geographical(start: ndarray, end: ndarray)[source]
Return the Geographical distance between start and end points.
- static manhattan(start: ndarray, end: ndarray)[source]
Return the Manhattan distance between start and end points.
- class ml4co_kit.task.routing.base.ROUND_TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
str,EnumDefine the rounding types as an enumeration.
- CEIL = 'ceil'
- FLOOR = 'floor'
- NO = 'no'
- ROUND = 'round'
- class ml4co_kit.task.routing.base.RoutingTaskBase(task_type: ~ml4co_kit.task.base.TASK_TYPE, minimize: bool, distance_type: ~ml4co_kit.task.routing.base.DISTANCE_TYPE, round_type: ~ml4co_kit.task.routing.base.ROUND_TYPE, precision: ~numpy.float32 | ~numpy.float64 = <class 'numpy.float32'>)[source]
Bases:
TaskBaseBase class for routing tasks defined on node coordinates.
Parameters
- task_typeTASK_TYPE
Routing problem type.
- minimizebool
Whether route cost is minimized.
- distance_typeDISTANCE_TYPE
Edge weight metric (e.g.
EUC_2D).- round_typeROUND_TYPE
Rounding applied to computed distances.
- precisionnp.float32 or np.float64, optional
Floating dtype. Default is
np.float32.
Attributes
- distance_typeDISTANCE_TYPE
Selected distance metric.
- dist_evalDistanceEvaluator
Callable distance engine shared by subclasses.