generator_lib
Class GeneratorUtils

java.lang.Object
  extended by generator_lib.GeneratorUtils

public class GeneratorUtils
extends java.lang.Object

The GeneratorUtils class assists the TraceGenerator driver program with the generation of users, file libraries, and transactions.


Field Summary
private  Globals GLOBALS
          The Network parameterization object.
private  Network nw
          The Network for which the generations are taking place.
private  double ZIPF_SUM
          Sum of all file Zipf frequencies.
 
Constructor Summary
GeneratorUtils(Network network, Globals GLOBALS)
          Construct a GeneratorUtils object.
 
Method Summary
 void generateInitLibs()
          Generate/populate the initial file library.
 void generateUsers()
          Generate/populate the User library.
 Transaction genTransactionNaive()
          'Naively' generate a transaction.
 Transaction genTransactionSmart()
          'Intelligently' generate a transaction.
private  int genUserType(User.Behavior model, int quantity, int prev)
          Generate all users of a specified type, and place in library
private  double getZipf(int rank)
          Return the Zipf frequency of a given file.
private  int inverseZipf(double weight)
          Given an number on [0..ZIPF_SUM], map that value to a file identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nw

private Network nw
The Network for which the generations are taking place.


GLOBALS

private final Globals GLOBALS
The Network parameterization object.


ZIPF_SUM

private double ZIPF_SUM
Sum of all file Zipf frequencies.

Constructor Detail

GeneratorUtils

public GeneratorUtils(Network network,
                      Globals GLOBALS)
Construct a GeneratorUtils object.

Parameters:
network - The Network on which the utilities will operate
GLOBALS - The Network parameterization object
Method Detail

generateUsers

public void generateUsers()
Generate/populate the User library.


generateInitLibs

public void generateInitLibs()
Generate/populate the initial file library.


genTransactionSmart

public Transaction genTransactionSmart()
'Intelligently' generate a transaction.

Returns:
A Transaction object containing the data generated

genTransactionNaive

public Transaction genTransactionNaive()
'Naively' generate a transaction.

Returns:
A Transaction object containing the data generated

genUserType

private int genUserType(User.Behavior model,
                        int quantity,
                        int prev)
Generate all users of a specified type, and place in library

Parameters:
model - The Behavior model of the generated users
quantity - The number of users of this type to generate
prev - Identifier where first such user will be placed in User lib.
Returns:
The number of users generated

getZipf

private double getZipf(int rank)
Return the Zipf frequency of a given file.

Parameters:
rank - File number whose frequency is desired
Returns:
Fraction describing frequency rate on [0..1]

inverseZipf

private int inverseZipf(double weight)
Given an number on [0..ZIPF_SUM], map that value to a file identifier. This is performed such that if a number is randomly selected on that interval, the probability of a file identifier being returned corresponds to its Zipf frequency as calculated by the getZipf() method. I am dissatisfied with the efficiency of this calculation.

Parameters:
weight - Number on the [0..ZIPF_SUM] interval
Returns:
Corresponding file identifier, per probability weighting