Class MT19937

java.lang.Object
jline.opt.solver.de.MT19937

public class MT19937 extends Object
Bit-exact reimplementation of numpy's legacy MT19937 core, matching the generator underlying numpy.random.RandomState.

This reproduces the exact 32-bit output stream numpy produces so that NumpyRandomState and the differential-evolution optimizer generate identical draws to the native-Python line-opt implementation for a given seed. Seeding follows numpy's _legacy_seeding: a scalar seed that fits in 32 bits uses init_genrand; otherwise the seed words are fed to init_by_array.

Java 8 compatible. Unsigned 32-bit words are held as int; callers that need the unsigned value use & 0xFFFFFFFFL.

  • Constructor Summary

    Constructors
    Constructor
    Description
    MT19937(long seed)
    Seed with a single non-negative integer, matching RandomState(int).
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Current position into the 624-word key (numpy get_state pos).
    int[]
    Copy of the internal 624-word key (for state validation/tests).
    void
    initByArray(long[] initKey)
    numpy/Matsumoto init_by_array (used for seeds > 32 bits).
    void
    initGenrand(long s)
    numpy/Matsumoto init_genrand.
    long
    Draw the next tempered 32-bit word as an unsigned value in [0, 2^32).
    void
    seed(long seed)
    Seed matching numpy legacy behavior for a scalar integer seed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MT19937

      public MT19937(long seed)
      Seed with a single non-negative integer, matching RandomState(int).
  • Method Details

    • seed

      public void seed(long seed)
      Seed matching numpy legacy behavior for a scalar integer seed.
    • initGenrand

      public void initGenrand(long s)
      numpy/Matsumoto init_genrand.
    • initByArray

      public void initByArray(long[] initKey)
      numpy/Matsumoto init_by_array (used for seeds > 32 bits).
    • nextUint32

      public long nextUint32()
      Draw the next tempered 32-bit word as an unsigned value in [0, 2^32).
    • getStateKey

      public int[] getStateKey()
      Copy of the internal 624-word key (for state validation/tests).
    • getPos

      public int getPos()
      Current position into the 624-word key (numpy get_state pos).