Computes the Polygon Ranking Method (PRM) distance and score between two
fuzzy numbers whose membership functions are convex polygons (i.e. any
piecewise-linear, unimodal membership function: triangular, trapezoidal,
or general polygonal). This is the workhorse function of the package;
prm_triangle and prm_trapezoid are
convenience wrappers around it for the two most common special cases.
prm_polygon(v1, v2, eps = 1e-06)A named list with components:
D_dir, D_core, D_PRMDirectional, core and
total PRM distances (see Details). NA when both v1
and v2 are crisp (see "Numerical note" below): the
unnormalized distances are a genuine 0/0 form in that limit.
S_dir, S_core, S_PRMThe corresponding
scores, normalized by Area1 + Area2.
Directionsign(D_dir): 1 if v1 tends
to rank below v2, -1 if above, 0 if tied.
DecisionA character string summarizing the ranking:
"x1 < x2", "x1 > x2", or "x1 ~ x2".
Area1, Area2Total area under each membership function.
Core1, Core2The representative ("core") point of each fuzzy number.
CrossingsSorted numeric vector of the abscissae where the two membership functions intersect (possibly empty).
PartitionSorted numeric vector of the breakpoints used
to compute D_core (see sign_partition_polygon).
Two-column numeric matrices (x, mu) giving the
vertices of each fuzzy number's membership function, ordered by
non-decreasing x. mu should rise from 0 to 1 and fall
back to 0 (or more generally describe a convex, unimodal shape); the
first and last row will typically have mu = 0. Validated on
entry: both matrices must have exactly 2 columns, x
non-decreasing, mu in \([0, 1]\), and each must reach
mu = 1 somewhere (prm_polygon assumes normal
convex fuzzy numbers, as does the rest of the package); violations
raise an informative error rather than propagating into a cryptic
failure inside cumfun_polygon.
Numeric, base relative half-width used to regularize
degenerate input (crisp numbers, duplicated abscissae); see
normalize_polygon. The *effective* half-width used
internally is eps scaled up by the magnitude of the input
values (eps * max(1, max(abs(v1[,1]), abs(v2[,1])))), so that
e.g. comparing two crisp numbers around 1000 does not force
interpolation slopes of order 1/eps that would swamp the fixed
tolerances used elsewhere in the computation (see "Numerical note"
below). Default 1e-6 (i.e. a half-width of about one part per
million of the input's magnitude).
comparing crisp (or near-crisp) numbers:
When both v1 and v2 are crisp (each a single,
repeated abscissa), prm_polygon bypasses the generic polygon
machinery entirely and returns the exact closed-form limit derived in
Donze (draft, Section 3): S_core = 0,
S_dir = sign(x2 - x1), S_PRM = abs(S_dir), so that the
PRM ranking coincides exactly with the usual ordering of
\(\mathbb{R}\). In that case D_dir, D_core, D_PRM
are set to NA: the unnormalized distances are a genuine
\(0/0\) form in the true crisp limit (both areas vanish), so only the
normalized scores are mathematically defined; use those.
When only one of v1, v2 is crisp (the other
remains genuinely fuzzy), the generic path below still applies, and the
crisp side is regularized internally as a symmetric triangle of
half-width eps'} (the scaled \code{eps} described above) around
its value. This is mathematically exact in the limit
\code{eps' -> 0, but at fixed finite precision an eps'} that is
tiny relative to the crisp value forces an interpolation slope of order
\code{1/eps' inside cumfun_polygon, and computing areas
from such slopes subtracts two large intermediate quantities to recover
a tiny true answer (catastrophic cancellation). eps = 1e-6 is a
compromise that keeps the regularization tight while keeping this
effect negligible for typical inputs; if you see an out-of-range score
(e.g. a negative S_core) when comparing a crisp number against a
fuzzy one of very large or very small magnitude, try increasing
eps further.
For each fuzzy number, let \(\mu(x)\) be its membership function, \(M(x) = \int_{-\infty}^{x} \mu(t)\,dt\) its cumulative function, and \(A\) the total area under \(\mu\) (\(A = M(\infty)\)). Let \(x^{*}\) be the representative ("core") point of the fuzzy number, computed as the mean of the abscissae where \(\mu = 1\) (a single point for a triangular number, the midpoint of the plateau for a trapezoidal one).
Writing \(G(x) = M_1(x) - M_2(x)\), the PRM distance is split into:
D_dirthe *directional* contribution, \(G(x_1^{*}) + G(x_2^{*}) - (A_1 - A_2)\), which is positive when the first fuzzy number tends to be smaller than the second, negative when it tends to be larger, and (near) zero when they are indifferent.
D_corethe *core* (ambiguity) contribution, the total variation of \(G\) over \([\min(x_1^{*}, x_2^{*}), \max(x_1^{*}, x_2^{*})]\), which grows with how much the two membership functions overlap/cross each other.
with D_PRM = D_dir + D_core. Dividing each distance by
\(A_1 + A_2\) gives the corresponding scores S_dir, S_core,
S_PRM, which are scale-free and comparable across different pairs
of fuzzy numbers, with \(-1 \le S_{dir} \le 1\) and \(-1 \le S_{PRM}
\le 1\); both bounds are attained exactly when v1 and v2
have disjoint supports (Donze, Theorems 2 and 4).
The confidence index \(C = |S_{dir}| / (|S_{dir}| + S_{core})\)
(computed by summary_prm / summary_prm_scores,
not returned here) measures how much of the total distance is
directional rather than ambiguous: \(C\) close to 1 signals a strong,
unambiguous ranking, \(C\) close to 0 a highly ambiguous one.
Donze, L. (2026). Ranking fuzzy numbers with the Polygon Ranking Method (PRM). Working paper, University of Fribourg.
Berkachy, R., Donze, L. (2024). Generalisation of the signed distance. Mathematics, 12(24), 4042. tools:::Rd_expr_doi("10.3390/math12244042")
prm_triangle, prm_trapezoid for
convenience wrappers; summary_prm and
summary_prm_scores to format the result.
# Two triangular fuzzy numbers, built "by hand" as polygons
v1 <- matrix(c(3, 0, 5, 1, 5, 1, 6, 0), ncol = 2, byrow = TRUE)
v2 <- matrix(c(-2, 0, -1, 1, -1, 1, 1, 0), ncol = 2, byrow = TRUE)
res <- prm_polygon(v1, v2)
res$Decision
summary_prm(res)
# Two crisp numbers: exact closed form, coincides with the usual
# ordering of the reals
summary_prm(prm_triangle(c(5, 5, 5), c(8, 8, 8)))
Run the code above in your browser using DataLab