moocore.

generate_ndset#

moocore.generate_ndset(n, d, /, method, *, seed=None, integer=False)[source]#

Generate a random set of n mutually nondominated points of dimension d with the shape defined by method.

When integer=False (the default), the points are generated within the hypercube \((0,1)^d\) and can be scaled to another range using normalise(). Otherwise, points are scaled to a non-negative integer range that keeps the points mutually nondominated.

Parameters:
  • n (int) – Number of rows in the output.

  • d (int) – Number of columns in the output.

  • method (str) – Method used to generate the random nondominated set. See the Notes below for more details.

  • seed (int | Generator | None, default: None) – Either an integer to seed numpy.random.default_rng(), Numpy default random number generator (RNG) or an instance of a Numpy-compatible RNG. None uses the equivalent of a random seed (see numpy.random.default_rng()).

  • integer (default: False) – If True, return integer-valued points.

Returns:

ndarray – A numeric matrix of size \(n \times d\) containing nondominated points.

Notes

The available methods are:

  • "simplex", "linear" or "L": Uniformly samples points on the standard simplex.

  • "concave-sphere", "sphere" or "C": Uniformly samples points on the positive orthant of the hyper-sphere (concave for minimisation).

  • "convex-simplex": Equivalent to generate_ndset(..., method="simplex") ** 2, which is convex for minimisation problems. Such a set cannot be obtained by any affine transformation of a subset of the hyper-sphere. This sampling is not uniform.

  • "convex-sphere" or "X": Equivalent to 1 - generate_ndset(..., method="concave-sphere"), which is convex for minimisation problems. This shape has also been called inverted convex [1]. This sampling is uniform.

  • "inverted-simplex" or "inverted-linear": Equivalent to 1 - generate_ndset(..., method="simplex"). This sampling is uniform.

  • "concave-simplex": Equivalent to 1 - generate_ndset(..., method="convex-simplex"), which is concave for minimisation problems. This shape has also been called inverted concave [1]. This sampling is not uniform because method="convex-simplex" is also not uniform.

Method "simplex" uniformly samples points on the standard \((d-1)\)-simplex defined by \(\{\vec{x}\in \mathbb{R}_+^d : \sum_{i=1}^d x_i = 1\}\). This shape of nondominated set is also called "linear" in the literature [2]. Each point \(\vec{z} \in (0,1)^d \subset \mathbb{R}^d\) is generated by sampling \(d\) independent and identically distributed values \((x_1,x_2, \dots, x_d)\) from the exponential distribution, then dividing each value by the l1-norm of the vector, \(z_i = x_i / \sum_{i=1}^d x_i\) [3]. Values sampled from the exponential distribution are guaranteed to be positive. Sampling from either the standard normal distribution [4] or the uniform distribution [2] does not produce a uniform distribution when projected onto the simplex.

Method "concave-sphere" uniformly samples points on the positive orthant of the hyper-sphere, which is concave when all objectives are minimised. Each point \(\vec{z} \in (0,1)^d \subset \mathbb{R}^d\) is generated by sampling \(d\) independent and identically distributed values \(\vec{x}=(x_1,x_2, \dots, x_d)\) from the standard normal distribution, then dividing each value by the l2-norm of the vector, \(z_i = \frac{|x_i|}{\|\vec{x}\|_2}\) [5]. The absolute value in the numerator ensures that points are sampled on the positive orthant of the hyper-sphere. Sampling from the uniform distribution [2] would not result in a uniform sampling when projected onto the surface of the hyper-sphere.

Method "convex-simplex" is equivalent to generate_ndset(..., method="simplex")**2, which is convex for minimisation problems. The corresponding surface is equivalent to a simplex curved towards the origin. Although the sampling on the simplex is uniform, the transformed points are not.

Method "convex-sphere" is equivalent to 1 - generate_ndset(..., method="concave-sphere"), which is convex for minimisation problems. It corresponds to translating points from the negative orthant of the hyper-sphere to the positive orthant. Thus, the sampling remains uniform.

Methods "inverted-simplex" and "concave-simplex" are similar translations of "simplex" and "convex-simplex", respectively. These translations have been called inverted shapes in the literature and have different properties than their regular counterparts [1].

References

Examples

>>> moocore.generate_ndset(5, 3, "simplex", seed=42)
array([[0.33742524, 0.32787894, 0.33469582],
       [0.15382676, 0.047522  , 0.79865124],
       [0.30561291, 0.67719985, 0.01718724],
       [0.47441115, 0.03192912, 0.49365973],
       [0.51684378, 0.11549762, 0.3676586 ]])
>>> moocore.generate_ndset(5, 3, "simplex", seed=42, integer=True)
array([[21, 20, 21],
       [ 9,  3, 51],
       [19, 43,  1],
       [30,  2, 31],
       [33,  7, 23]])
>>> rng = np.random.default_rng(42)
>>> moocore.generate_ndset(4, 2, "sphere", seed=rng)
array([[0.28118049, 0.9596549 ],
       [0.62368072, 0.78167919],
       [0.83175713, 0.5551397 ],
       [0.37478326, 0.92711246]])
>>> moocore.generate_ndset(3, 5, "convex-sphere", seed=rng)
array([[0.98843533, 0.41282763, 0.39468745, 0.46462554, 0.95454935],
       [0.37787475, 0.74198125, 0.52575586, 0.79648617, 0.47079199],
       [0.47186748, 0.96998408, 0.88885902, 0.5906188 , 0.26499673]])
>>> moocore.generate_ndset(4, 4, "convex-simplex", seed=rng)
array([[0.19863075, 0.05673281, 0.02294823, 0.02710852],
       [0.00335494, 0.01822224, 0.26522868, 0.08531355],
       [0.22390087, 0.07032143, 0.00793081, 0.02978433],
       [0.08611603, 0.02473488, 0.02168134, 0.16162454]])