mcbo: Median Constrained Bucket Order (MCBO)

View source: R/mcbo.R

mcboR Documentation

Median Constrained Bucket Order (MCBO)

Description

Find the median ranking constrained to exactly b buckets (tied groups) according to Kemeny's axiomatic approach. This implements the algorithms described in D'Ambrosio et al. (2019) for rank aggregation with fixed bucket constraints.

Usage

mcbo(
  X = NULL,
  nbuckets = NULL,
  wk = NULL,
  ps = TRUE,
  algorithm = "BB",
  itermax = 10,
  np = 10,
  gl = 100,
  ff = 0.4,
  cr = 0.8,
  use_cpp = TRUE,
  maxjudges = Inf,
  cij = NULL,
  nj = NULL,
  bucketsizes = NULL
)

Arguments

X

A N by M data matrix, in which there are N judges and M objects to be judged. Either X or cij must be given. Each row is a ranking of the objects which are represented by the columns. If X contains the rankings observed only once, the argument wk can be used

nbuckets

Integer. The number of buckets (tied groups) the consensus ranking must contain. Must be between 2 and M (where M is the number of objects); with M buckets the solution is a full ranking and the result is the one of consrank(..., full = TRUE) with the same algorithm. Give either nbuckets or bucketsizes, not both

wk

Optional: the frequency of each ranking in the data

ps

Logical. If TRUE, displays progress information on screen. Default TRUE

algorithm

Character string specifying the algorithm to use. One of:

  • "BB" - Branch-and-Bound (exact, default). Best for M <= 15

  • "quick" - Quick algorithm (deterministic heuristic, see Details). Best for 15 < M <= 50

  • "decor" - Differential Evolution (metaheuristic). Best for M > 50

  • "BOLT" - BOLT adapted to the bucket constraint (deterministic heuristic, see Details). Works with a very large number of objects

The name of the algorithm is matched ignoring the case

itermax

Integer. For "quick": maximum number of insertion passes (the algorithm stops earlier when a pass does not improve the solution). For "decor": number of runs of the algorithm. Default 10

np

Integer. Number of population individuals for "decor" algorithm. Default 10

gl

Integer. Generations limit for "decor": maximum number of consecutive generations without improvement. Default 100

ff

Numeric. Scaling rate for mutation in "decor". Must be in [0,1]. Default 0.4

cr

Numeric. Crossover range for "decor". Must be in [0,1]. Default 0.8

use_cpp

Logical. If TRUE (default), use optimized C++ implementations for core functions (combinpmatr, scorematrix, PenaltyBB2, etc.). Ignored with algorithm = "BOLT", which is implemented in C++ only. With algorithm = "quick", the optimal tie partitioning step (taken from BOLT) is always computed in C++.

maxjudges

For "BOLT" only: maximum number of distinct rankings of the judges used as starting solutions, the most frequent first. Default Inf (all of them); 0 uses only the starting solutions computed from the combined input matrix

cij

The combined input matrix (M by M, see combinpmatr), to be given instead of X. With cij, the argument wk is ignored and the rankings of the judges are not used as starting solutions by "BOLT"

nj

The number of judges (the sum of the weights, if any) that produced cij. Required when cij is given: it is used to compute the averaged TauX

bucketsizes

Optional pattern of bucket sizes, one element per bucket: a whole number greater than zero prescribes the size of that bucket, NA leaves it free. If the sizes given do not use all the objects and no NA is present, one free bucket is added at the end, so that with ten objects bucketsizes = c(1, 1, 1) means three buckets of one object and a fourth one with the remaining seven, that is a top-3 list; in the same way, with any number of objects, bucketsizes = rep(1, 10) is the top-10 list, with all the other objects tied in the last position. To fix the number of buckets of a pattern, use NA for the buckets of free size: for instance bucketsizes = c(1, 1, NA, NA, NA) gives five buckets, the first two with one object each. A pattern of ones is a full ranking, a pattern of NAs is the plain constrained bucket order of nbuckets buckets, and a single bucket is the solution with all the objects tied. Available with algorithm = "BOLT" only, which is used by default when bucketsizes is given

Details

The median constrained bucket order problem finds the ranking that minimizes the sum of Kemeny distances to the input rankings, subject to the constraint that the solution must have exactly nbuckets groups of tied items.

This is useful in applications where the output must conform to predetermined categories, such as:

  • Wine quality classifications (e.g., 5 fixed tiers)

  • Medical triage systems (fixed severity codes)

  • Educational grading (fixed letter grades: A, B, C, D, F)

The search space is restricted to Z^{n/b}, which contains

\sum_{b=1}^{n} b! S(n,b)

rankings, where S(n,b) is the Stirling number of the second kind.

Algorithm Selection Guidelines:

  • BB: Exact solution, guaranteed optimal. Use for M <= 15 items

  • quick: Fast heuristic, near-optimal. Use for 15 < M <= 50 items

  • decor: Best for large problems. Use for M > 50 items

The "decor" algorithm is stochastic: it is run several times (controlled by itermax) to avoid local optima. Since version 3.1, a good candidate (the order of the starting point of the branch-and-bound algorithm, cut into exactly nbuckets buckets by the optimal partition described below for "BOLT") is inserted in the initial population, a child with a wrong number of buckets is brought back to nbuckets buckets by the optimal partition of its order (instead of being replaced by a random individual), and the final solution is refined by the optimal partition of its order.

The "quick" algorithm is deterministic (since version 3.1). The starting solution is the order given by the starting point of the branch-and-bound algorithm, cut into exactly nbuckets buckets by the optimal partition described below for "BOLT". Then the insertion passes of the Quick algorithm are repeated until no improvement: a candidate solution with a number of buckets different from nbuckets is brought back to nbuckets buckets by the optimal partition of its order, and each solution is refined in the same way.

The "BOLT" algorithm adapts the procedure of bolt to the bucket constraint. For a fixed order of the objects, the best partition into exactly nbuckets groups of consecutive objects is computed exactly by dynamic programming in O(nbuckets M^2) time. From each starting solution (the same as in bolt), the order is first improved by an insertion local search without ties; then the optimal partition into nbuckets buckets and a local search that keeps the number of buckets (an object alone in its bucket is moved to another position, an object of a larger bucket is moved into another bucket; then two objects of different buckets exchange their buckets) are alternated until no improvement. With bucketsizes, the local search keeps the size of every bucket: an object moves to another bucket and one object crosses each boundary in between, and two objects of different buckets exchange their buckets. The procedure is deterministic: repeated runs return the same solution(s), and the argument itermax is not used.

Value

A list containing the following components:

Consensus The consensus ranking with exactly nbuckets buckets
Tau Averaged TauX rank correlation coefficient
Eltime Elapsed time in seconds

Author(s)

Antonio D'Ambrosio antdambr@unina.it

References

D'Ambrosio, A., Iorio, C., Staiano, M., and Siciliano, R. (2019). Median constrained bucket order rank aggregation. Computational Statistics, 34(2), 787-802. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s00180-018-0858-z")}

Romano, M., D'Ambrosio, A., and Conversano, C. A deterministic and scalable heuristic for median ranking detection: tie-aware local search with optimal tie partitioning on the combined input matrix. Manuscript under review.

See Also

consrank for unconstrained consensus ranking

bolt for the BOLT algorithm

combinpmatr for computing the combined input matrix

scorematrix for computing score matrices

tau_x for TauX correlation coefficient

kemenyd for Kemeny distance

stirling2 for Stirling numbers (bucket combinatorics)

Examples

# Deterministic BOLT algorithm
data(EMD)
CR_bolt <- mcbo(EMD[,1:15], nbuckets = 5, wk = EMD[,16], algorithm = "BOLT")
CR_bolt$Tau

## Not run: 
# Simple example with 98 judges ranking 5 items into 3 buckets
data(Idea)
RevIdea <- 6 - Idea  # Reverse ranking
CR <- mcbo(RevIdea, nbuckets = 3, algorithm = "BB")
print(CR$Consensus)
print(CR$Tau)

# Large dataset with Quick algorithm
data(EMD)
CR_quick <- mcbo(EMD[,1:15], nbuckets = 5, wk = EMD[,16], 
                 algorithm = "quick", itermax = 20)

## End(Not run)


ConsRank documentation built on Nov. 24, 2026, 5:08 p.m.