pympcc.autoscale_comp_pairs

pympcc.autoscale_comp_pairs(problem, *, threshold=1000.0, n_probes=5, seed=0, floor=1e-12, perturb_scale=0.1)[source]

Return per-pair diagonal scales that equilibrate the comp block.

Parameters:
  • problem (MPCCProblem) – Source problem. Must expose comp_G, comp_H, x0, and n_comp. xl / xu are honoured when probing perturbations.

  • threshold (float, optional) – A pair is rescaled only when max(|G|, |H|) / min(|G|, |H|) — evaluated on per-pair medians across the probe set — exceeds this ratio. Default 1e3.

  • n_probes (int, optional) – Number of random perturbations of x0 evaluated in addition to x0 itself. Default 5 (six samples total).

  • seed (int, optional) – Seed for the perturbation RNG. Default 0.

  • floor (float, optional) – Lower clip on per-pair median magnitudes before division. Default 1e-12.

  • perturb_scale (float, optional) – Standard deviation of the random perturbation, expressed as a fraction of max(|x0|, 1) per coordinate. Default 0.1.

Return type:

tuple[ndarray, ndarray]

Returns:

  • s_G (ndarray, shape (n_comp,))

  • s_H (ndarray, shape (n_comp,)) – Strictly positive scales. 1.0 for well-conditioned pairs; 1 / median(|·|) for imbalanced pairs (clipped at floor).