Class Subset

java.lang.Object
io.jenetics.internal.math.Subset

public final class Subset extends Object
This class creates random subsets of size k from a set of n elements. Implementation of the RANKSB algorithm described by Albert Nijenhuis and Herbert Wilf in Combinatorial Algorithms for Computers and Calculators

Reference: Albert Nijenhuis, Herbert Wilf, Combinatorial Algorithms for Computers and Calculators, Second Edition, Academic Press, 1978, ISBN: 0-12-519260-6, LC: QA164.N54. Page: 42

Since:
4.0
Version:
7.0
  • Method Details

    • next

      public static int[] next(int n, int k, RandomGenerator rnd)
      Selects a random subset of size k from a set of size n.
      Parameters:
      n - the size of the set.
      k - the size of the subset.
      rnd - the random number generator used.
      Returns:
      the a-set array for the given parameter. The returned sub-set array is sorted in increasing order.
      Throws:
      NullPointerException - if random is null.
      IllegalArgumentException - if n < k, k == 0 or if n*k will cause an integer overflow.
      See Also:
      • next(int, int[], RandomGenerator)