| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectlio.util.Utils
public class Utils
This class contain some useful methods
| Field Summary | |
|---|---|
static double | 
log2
The natural logarithm of 2.  | 
| Constructor Summary | |
|---|---|
Utils()
 | 
|
| Method Summary | |
|---|---|
static double | 
binaryToDouble(int[] binChain,
               double lowerLimit,
               double upperLimit)
Returns the double value encoding by the chain of bits passed as parametter given a range of values.  | 
static int[] | 
binaryToGray(int[] binary)
Converts a number in binary code to gray  | 
static boolean | 
comparePopulations(Population first,
                   Population second)
Compares two populations.  | 
static double[] | 
generateVector(int pSize,
               double[] lowerVal,
               double[] higherVal)
Generates a vector of doubles.  | 
static double[] | 
generateVector(int pSize,
               double lowerVal,
               double higherVal)
Generates a vector of doubles.  | 
static boolean | 
getFlag(char flag,
        java.lang.String[] options)
Checks if the given flag is in the String array.  | 
static java.lang.String | 
getOption(java.lang.String flag,
          java.lang.String[] options)
Gets an option indicated by the flag from the given array of strings.  | 
static int[] | 
grayToBinary(int[] gray)
Converts a number in gray code to binary  | 
static double | 
grayToDouble(int[] grayChain,
             double lowerLimit,
             double upperLimit)
Returns the double value encoding in gray by the chain of bits passed as parametter given a range of values.  | 
static int | 
hammingDistance(BitChain firstInd,
                BitChain secondInd)
Returns the hamming distance between two binary individuals.  | 
static double | 
log2(double a)
Returns the logarithm of a for base 2.  | 
static int | 
maxIndex(Population population)
Returns index of maximum element in a given array of doubles.  | 
static int | 
minIndex(double[] doubles)
Returns index of minimum element in a given array of doubles.  | 
static int | 
minIndex(Population population)
Returns index of minimum element in a given array of doubles.  | 
static void | 
nextBinConfiguration(int[] values)
 | 
static int[] | 
randomPermutation(int size)
Returns a random permutation of the specified size.  | 
static int[] | 
sort(double[] array)
Sorts a given array of doubles in ascending order and returns an array of integers with the positions of the elements of the original array in the sorted array.  | 
static int[] | 
sort(int[] array)
Sorts a given array of integers in ascending order and returns an array of integers with the positions of the elements of the original array in the sorted array.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static double log2
| Constructor Detail | 
|---|
public Utils()
| Method Detail | 
|---|
public static boolean getFlag(char flag,
                              java.lang.String[] options)
flag - the character indicating the flag.strings - the array of strings containing all the options.
public static java.lang.String getOption(java.lang.String flag,
                                         java.lang.String[] options)
                                  throws java.lang.Exception
flag - the string indicating the option.options - the array of strings containing all the options.
java.lang.Exception - if the option indicated by the flag can't be foundpublic static int[] sort(double[] array)
array - this array is not changed by the method!
public static int[] sort(int[] array)
array - this array is not changed by the method!
public static int minIndex(double[] doubles)
doubles - the array of doubles
public static int maxIndex(Population population)
doubles - the array of doubles
public static int minIndex(Population population)
doubles - the array of doubles
public static double binaryToDouble(int[] binChain,
                                    double lowerLimit,
                                    double upperLimit)
binChain - chain of bits.lowerLimit - lower value that can take the double (represented by all 0's).upperLimit - highest value that can take the double (represented by all
            1's).
public static double grayToDouble(int[] grayChain,
                                  double lowerLimit,
                                  double upperLimit)
grayChain - chain of bits.lowerLimit - lower value that can take the double (represented by all 0's).upperLimit - highest value that can take the double (represented by all
            1's).
public static int[] grayToBinary(int[] gray)
gray - Array of bits containing the number in gray.
public static int[] binaryToGray(int[] binary)
gray - Array of bits containing the binary number.
public static int[] randomPermutation(int size)
size - Size of the permutation.
public static int hammingDistance(BitChain firstInd,
                                  BitChain secondInd)
firstInd - First individual.secondInd - Second individual.
public static boolean comparePopulations(Population first,
                                         Population second)
public static double[] generateVector(int pSize,
                                      double lowerVal,
                                      double higherVal)
pSize - Size of the vector;lowerVal - Minimum value that can be generated.higherVal - Maximum value that can be generated.     *
public static double[] generateVector(int pSize,
                                      double[] lowerVal,
                                      double[] higherVal)
pSize - Size of the vector;lowerVal - Minimum value that can be generated.higherVal - Maximum value that can be generated.     *
public static void nextBinConfiguration(int[] values)
public static double log2(double a)
a - a double
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||