Skip to main content

sparsemap

pub fn sparsemap<F>(
    scores: &[F],
    config: &SparsemapConfig,
) -> OptimizeResult<SparsemapResult<F>>
where F: Float + FromPrimitive + Debug + Clone,
Expand description

Solve SparseMAP via projected gradient descent on the regularised QP.

For StructureType::Simplex this is equivalent to computing the Euclidean projection of scores onto the probability simplex, which has a closed-form O(n log n) solution. For other structures, it falls back to iterative projected gradient.

§Arguments

  • scores – score vector θ ∈ ℝ^d.
  • config – solver configuration.

§Returns

SparsemapResult containing the sparse distribution, active support, dual variables, and iteration count.