Skip to main content

Module reduce

Module reduce 

Source
Expand description

Deterministic per-topology top-K reduction and tie diagnostics.

Behaviorally equivalent to the Python reference in crates/pyxlog/python/pyxlog/ilp/exact_induce.py:

  1. Within each topology, sort scored pairs by lexicographic key (-positives_covered, negatives_covered, left_idx, right_idx).
  2. Filter to pairs with positives_covered > 0, then keep the first k_per_topology.
  3. For each kept pair:
    • local_rank = 0-indexed position within the positive-filtered list.
    • next_positives_covered / next_negatives_covered = the next pair in the positive-filtered list, or (0, 0) if there is none.
    • tie_class_size = count of pairs in the FULL sorted list (including zero-coverage) sharing the same (positives_covered, negatives_covered).
  4. Output groups candidates by Topology::ALL order.

Structs§

ScoredPair
One scored (topology, left, right) triple produced by the scoring stage.

Functions§

reduce_per_topology
Reduce a flat scored-pair list to the final ordered ScoredCandidate list.