pysolvegn.build_batch_absolute_regularization#

build_batch_absolute_regularization(means, stds, *, weight=1.0, epsilon=0.001)[source]#

Build a batched absolute value (L1) regularization term (batched counterpart of build_absolute_regularization()).

For each problem \(k\) of the batch, the cost of the term is:

\[C_{\mathrm{reg},k} = w_k \sum_i \left( \sqrt{z_{k,i}^2 + \varepsilon^2} - \varepsilon \right) \quad \text{with} \quad z_{k,i} = \frac{p_{k,i} - \mu_{k,i}}{\sigma_{k,i}}\]

The resulting BatchTerm can be directly passed to pysolvegn.solve_batch().

Parameters:
  • means (ArrayLike) – Center of the regularization, with shape (n,) (shared by all the problems) or (k, n).

  • stds (ArrayLike) – Scale of the regularization, with shape (n,) or (k, n). All values must be strictly positive.

  • weight (Union[Real, ArrayLike] (default=1.0)) – Weight \(w\) of the L1 penalty: a scalar or one weight per problem with shape (k,).

  • epsilon (Real (default=1e-3)) – Width \(\varepsilon\) of the smooth quadratic zone, in the unit of \(z_{k,i}\) (number of stds). Must be strictly positive.

Returns:

A BatchTerm representing the absolute value regularization.

Return type:

BatchTerm