Weights helpers

Utilities related to weight vectors.

morl_baselines.common.weights.equally_spaced_weights(dim: int, n: int, seed: int = 42) List[ndarray]

Generate weight vectors that are equally spaced in the weight simplex.

It uses the Riesz s-Energy method from pymoo: https://pymoo.org/misc/reference_directions.html

Parameters:
  • dim – size of the weight vector

  • n – number of weight vectors to generate

  • seed – random seed

morl_baselines.common.weights.extrema_weights(dim: int) List[ndarray]

Generate weight vectors in the extrema of the weight simplex. That is, one element is 1 and the rest are 0.

Parameters:

dim – size of the weight vector

morl_baselines.common.weights.random_weights(dim: int, n: int = 1, dist: str = 'dirichlet', seed: int | None = None, rng: Generator | None = None) ndarray

Generate random normalized weight vectors from a Gaussian or Dirichlet distribution alpha=1.

Parameters:
  • dim – size of the weight vector

  • n – number of weight vectors to generate

  • dist – distribution to use, either ‘gaussian’ or ‘dirichlet’. Default is ‘dirichlet’ as it is equivalent to sampling uniformly from the weight simplex.

  • seed – random seed

  • rng – random number generator