samples.random
Class RandomListGenerator

java.lang.Object
  extended by samples.random.RandomListGenerator
Direct Known Subclasses:
ProportionRandomListGenerator

public abstract class RandomListGenerator
extends Object

This class allows generating integer random lists. A random list is formed of fixed-size tuples, the values of which range from 0 to a limit given by the user. When generating random lists, it is possible to indicate:


Nested Class Summary
static class RandomListGenerator.Structure
           
 
Field Summary
protected  int[] fixedTuple
          A particular tuple, which if not null , must or must not belong to the generated lists.
protected static Logger LOGGER
           
protected  int nbMaxValues
          The maximum number of values for the elements of the generated tuples.
protected  int[] nbOccurences
          The number of occurrences of each value in the generated lists.
protected  int[] nbValues
          The number of values for each element of the tuples of the generated lists.
protected  Random random
          The Random object used to generate lists.
protected  boolean requiredFixedTuple
          Indicates if the fixed tuple, if not null , must or must not belong to the generated lists.
protected  long seed
          The seed used to generate random numbers.
protected  int tupleLength
          The length of each tuple of the generated lists.
protected  boolean tupleRepetition
          Indicates if the same tuple can occur several times in the generated lists.
protected  int[][] tuples
          The generated tuples.
protected  RandomListGenerator.Structure type
          The type of the generated lists which can be UNSTRUCTURED, CONNECTED or BALANCED.
protected  boolean valueRepetition
          Indicates if the same value can occur several times in a generated tuple.
 
Constructor Summary
RandomListGenerator(int[] nbValues, long seed)
          Builds a random list generator.
RandomListGenerator(int nb, int tupleLength, long seed)
          Builds a random list generator.
 
Method Summary
protected static double cnp(int n, int p)
          Returns the number of combinations of p elements chosen among n elements.
static double computeNbArrangementsFrom(int[] t)
           
static double computeNbCombinationsFrom(int[] t)
           
static double computeNbCombinationsFrom(int[] t, int i, int j)
           
protected  double computeNbDistinctTuples()
          Reurns the number of distinct tuples (hence, we do not take into account tuple repetition).
 void displayTuples()
          Displays the current random generated list.
protected  String getSelectionDescription()
           
 int[][] getTuples()
          Returns the generated tuples.
 void saveElements()
          Saves the current generated list in a file.
 void setParameters(RandomListGenerator.Structure type, boolean tupleRepetition, boolean valueRepetition, int[] fixedTuple, boolean requiredFixedTuple)
          Sets the parameters used to generate random lists.
protected  void updateNbValueOccurencesFor(int[] tuple)
          Updates the number of occurrences of each value in the given tuple
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER

random

protected Random random
The Random object used to generate lists.


seed

protected long seed
The seed used to generate random numbers.


nbValues

protected int[] nbValues
The number of values for each element of the tuples of the generated lists. The array index corresponds to the order of the elements of the tuples. The array value gives the number of values for the corresponding element. For instance, if nbValues[i] = n then it means that the ith element of each tuple can belong to the propagationSet {0,1,...,n-1} .


tupleLength

protected int tupleLength
The length of each tuple of the generated lists.


type

protected RandomListGenerator.Structure type
The type of the generated lists which can be UNSTRUCTURED, CONNECTED or BALANCED.


tupleRepetition

protected boolean tupleRepetition
Indicates if the same tuple can occur several times in the generated lists.


valueRepetition

protected boolean valueRepetition
Indicates if the same value can occur several times in a generated tuple.


tuples

protected int[][] tuples
The generated tuples.


fixedTuple

protected int[] fixedTuple
A particular tuple, which if not null , must or must not belong to the generated lists.


requiredFixedTuple

protected boolean requiredFixedTuple
Indicates if the fixed tuple, if not null , must or must not belong to the generated lists.


nbOccurences

protected int[] nbOccurences
The number of occurrences of each value in the generated lists.


nbMaxValues

protected int nbMaxValues
The maximum number of values for the elements of the generated tuples.

Constructor Detail

RandomListGenerator

public RandomListGenerator(int[] nbValues,
                           long seed)
Builds a random list generator.

Parameters:
nbValues - the number of values for each element of the tuples
seed - the seed used to generate random numbers

RandomListGenerator

public RandomListGenerator(int nb,
                           int tupleLength,
                           long seed)
Builds a random list generator.

Parameters:
nb - the uniform number of values used to build tuples
tupleLength - the length of each tuple
seed - the seed used to generate random numbers
Method Detail

getTuples

public int[][] getTuples()
Returns the generated tuples.

Returns:

setParameters

public void setParameters(RandomListGenerator.Structure type,
                          boolean tupleRepetition,
                          boolean valueRepetition,
                          int[] fixedTuple,
                          boolean requiredFixedTuple)
Sets the parameters used to generate random lists.

Parameters:
type - the type of the generated lists which can be UNSTRUCTURED, CONNECTED or BALANCED
tupleRepetition - indicates if the same tuple can occur several times in the generated lists
valueRepetition - indicates if the same value can occur several times in a generated tuple
fixedTuple - a particular tuple, which if not null , must or must not belong to the generated lists
requiredFixedTuple - indicates if the fixed tuple, if not null , must or must not belong to the generated lists

updateNbValueOccurencesFor

protected void updateNbValueOccurencesFor(int[] tuple)
Updates the number of occurrences of each value in the given tuple

Parameters:
tuple - a generated tuple

cnp

protected static double cnp(int n,
                            int p)
Returns the number of combinations of p elements chosen among n elements.

Parameters:
n - the number of elements that can be selected
p - the number of elements to select
Returns:
the number of combinations of p elements chosen among n elements

computeNbArrangementsFrom

public static double computeNbArrangementsFrom(int[] t)

computeNbCombinationsFrom

public static double computeNbCombinationsFrom(int[] t,
                                               int i,
                                               int j)

computeNbCombinationsFrom

public static double computeNbCombinationsFrom(int[] t)

computeNbDistinctTuples

protected double computeNbDistinctTuples()
Reurns the number of distinct tuples (hence, we do not take into account tuple repetition).

Returns:

getSelectionDescription

protected String getSelectionDescription()

saveElements

public void saveElements()
Saves the current generated list in a file.


displayTuples

public void displayTuples()
Displays the current random generated list.



Copyright © 2012. All Rights Reserved.