Utilities (JEvolution)
Date: 2013-03-21

evSOLve.JEvolution.misc

## Class Utilities

- java.lang.Object
- - evSOLve.JEvolution.misc.Utilities

-     public class Utilities
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.text.DecimalFormat` | `fixedPoint` For numbers with four fraction digits.
    `static java.text.DecimalFormat` | `scientific` For numbers in a power format.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Utilities()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.util.BitSet` | `createBitSet(java.lang.String b)` Creates a BitSet from the given bit string.
    `static java.lang.String` | `cutTailAtLast(java.lang.String terms, char c)` Eliminates the substring after the last occurrence of 'c' including 'c'.
    `static int` | `express(java.util.BitSet gene, int from, int length)` Converts a bit gene in a positive integer value.
    `static double` | `express(java.util.BitSet gene, int from, int length, double low, double high)` Converts a bit gene in a scaled double value.
    `static java.lang.String` | `getClassName(java.lang.Object o)` Returns the unqualified class name, i.e., with all package names dropped.
    `static java.lang.String` | `getFullClassName(java.lang.Object o)` Returns the qualified class name, i.e., with all package names.
    `static java.util.List` | `getList()` Returns the utility list.
    `static java.lang.String` | `getParentheses(int count)` Returns 'count' opening = '(' or closing = ')' parentheses.
    `static java.lang.Object` | `instantiateByClassName(java.lang.String className, java.lang.String[] constructorClassNames, java.lang.Object[] constructorParameters)` Instantiates an Object by passing the name of the Class in a String.
    `static int` | `nextIntegerInRange(int low, int high)` Return a random integer within 'low' and 'high'.
    `static double` | `nextReal()` Return a random double within the unit interval'.
    `static double` | `nextRealInRange(double low, double high)` Return a random double within 'low' and 'high'.
    `static double` | `normalNoise(double mu, double sigma)` Normal noise with specified mean and standard deviation.
    `static void` | `setRandomSeed(long seed)` Sets the random seed of the random number generator.
    `static void` | `swap(java.util.List v, int a, int b)` Exchanges two elements in a List.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### fixedPoint

          public static java.text.DecimalFormat fixedPoint

      For numbers with four fraction digits.

    - #### scientific

          public static java.text.DecimalFormat scientific

      For numbers in a power format.

  - ### Constructor Detail

    - #### Utilities

          public Utilities()

  - ### Method Detail

    - #### setRandomSeed

          public static final void setRandomSeed(long seed)

      Sets the random seed of the random number generator.
      Parameters:
        `seed` - the seed

    - #### nextIntegerInRange

          public static final int nextIntegerInRange(int low,
                               int high)

      Return a random integer within 'low' and 'high'.
      Parameters:
        `low` - The lower bound.
        `high` - The higher bound.
      Returns:
        random An integer between these bounds, it can also take on the boundary values.

    - #### nextReal

          public static final double nextReal()

      Return a random double within the unit interval'.
      Returns:
        random a double in the unit interval, 0.0 is included, 1.0 is excluded

    - #### nextRealInRange

          public static final double nextRealInRange(double low,
                               double high)

      Return a random double within 'low' and 'high'.
      Parameters:
        `low` - The lower bound.
        `high` - The higher bound.
      Returns:
        random A double between these bounds, the lower bound is included, the upper bound is excluded

    - #### normalNoise

          public static final double normalNoise(double mu,
                           double sigma)

      Normal noise with specified mean and standard deviation.
      Parameters:
        `mu` - mean
        `sigma` - standard deviation
      Returns:
        random A random number from the specified normal distribution.

    - #### express

          public static double express(java.util.BitSet gene,
                       int from,
                       int length,
                       double low,
                       double high)

      Converts a bit gene in a scaled double value. WARNING: this method only works up to a length of 31 (due to the size of int), could be improved to 63 by using long.
      Parameters:
        `gene` - the bit gene
        `from` - the first position to decode
        `length` - the number of bits to decode
        `low` - the lower bound of the value to be expressed
        `high` - the upper bound of the value to be expressed
      Returns:
        the expressed double value scaled to [low, high]

    - #### express

          public static int express(java.util.BitSet gene,
                    int from,
                    int length)

      Converts a bit gene in a positive integer value. WARNING: this method only works up to a length of 31 (due to the size of int), could be improved to 63 by using long.
      Parameters:
        `gene` - the bit gene
        `from` - the first position to decode
        `length` - the number of bits to decode
      Returns:
        the expressed integer (is negative, if length = 32)

    - #### createBitSet

          public static java.util.BitSet createBitSet(java.lang.String b)

      Creates a BitSet from the given bit string. Note that we do not check, if the String really contains only '0' and '1' characters. If a '1' is encountered, the bit is set to 1 in the BitSet. A String of e.g., "abc1" would produce a BitSet of 0001.
      Parameters:
        `b` - a bit string
      Returns:
        the corresponding BitSet

    - #### swap

          public static void swap(java.util.List v,
                  int a,
                  int b)

      Exchanges two elements in a List.
      Parameters:
        `v` - the list
        `a` - first index
        `b` - second idex

    - #### getFullClassName

          public static java.lang.String getFullClassName(java.lang.Object o)

      Returns the qualified class name, i.e., with all package names.
      Returns:
        the full class name, null, if object is null

    - #### getClassName

          public static java.lang.String getClassName(java.lang.Object o)

      Returns the unqualified class name, i.e., with all package names dropped.
      Returns:
        the plain class name, null, if object is null

    - #### instantiateByClassName

          public static java.lang.Object instantiateByClassName(java.lang.String className,
                                                java.lang.String[] constructorClassNames,
                                                java.lang.Object[] constructorParameters)

      Instantiates an Object by passing the name of the Class in a String. The 'constructorClassNames' must contain the names of the Classes passed to the desired constructor of the Object. If the profile is null, the no-arg constructor is used. The parameters passed to the constructor must be in 'constructorParameters'.
      Parameters:
        `className` - the name of the Class to instantiate
        `constructorClassNames` - the names of the Classes of the parameters (may be null)
        `constructorParameters` - the actual parameters to the constructor (may be null)
      Returns:
        a new Object (null, if problems occurred)

    - #### getParentheses

          public static java.lang.String getParentheses(int count)

      Returns 'count' opening = '(' or closing = ')' parentheses.
      Parameters:
        `count` - if positive opening else closing
      Returns:
        a String with a number of opening or closing parentheses

    - #### cutTailAtLast

          public static java.lang.String cutTailAtLast(java.lang.String terms,
                                       char c)

      Eliminates the substring after the last occurrence of 'c' including 'c'.
      Parameters:
        `terms` - a String
        `c` - the delimiting character
      Returns:
        a new cut String

    - #### getList

          public static java.util.List getList()

      Returns the utility list.
      Returns:
        a multi-purpose list