Metrics

This module defines distance metrics used by nearest-neighbor search and roadmap edge weighting. Most sampling-based solvers use a metric object to evaluate distances in configuration space.

Typical usage

from discopygal.solvers_infra.metrics import Metric_Euclidean

metric = Metric_Euclidean()
d = metric.dist(p, q)

See also

class discopygal.solvers_infra.metrics.Metric

Representation of a metric for nearest neighbor search. Should support all kernels/methods for nearest neighbors (like CGAL and sklearn).

static CGALPY_impl()

Return the metric as a CGAL metric object (of the spatial search module)

static dist(p: Point_2 | Point_d, q: Point_2 | Point_d) FT

Return the distance between two points

Parameters:
Returns:

distance between p and q

Return type:

FT

static sklearn_impl()

Return the metric as sklearn metric object

exception discopygal.solvers_infra.metrics.MetricNotImplemented
class discopygal.solvers_infra.metrics.Metric_Euclidean

Implementation of the Euclidean metric for nearest neighbors search

static CGALPY_impl()

Return the metric as a CGAL metric object (of the spatial search module)

static dist(p: Point_2 | Point_d, q: Point_2 | Point_d) FT

Return the distance between two points

Parameters:
Returns:

distance between p and q

Return type:

FT

static sklearn_impl()

Return the metric as sklearn metric object

class discopygal.solvers_infra.metrics.Metric_SumDist

Implementation of metric of sum of distances between each pair of points Suppose p,q are 2*d dimensional points, then there are d 2-D points in each of them, so return the sum of the d distances between each pair of points

static dist(p: Point_2 | Point_d, q: Point_2 | Point_d) FT

Return the distance between two points

Parameters:
Returns:

distance between p and q

Return type:

FT

class discopygal.solvers_infra.metrics.RodDisplacementMetric

Implementation of metric, the average of the Euclidean distances of the tips of rod robot.

static dist(p, q, alpha: float = 2)

Return the distance between two points

Parameters:
Returns:

distance between p and q

Return type:

FT