GridSim 5.0 beta

gridsim
Class GridSimRandom

Object
  extended by GridSimRandom

public class GridSimRandom
extends Object

GridSim Random provides static methods for incorporating randomness in data used for any simulation.

NOTE From version 5.0 this class will NOT be created by GridSim upon initialization of the simulation. Hence, you should instantiate this class according to your needs.

Any predicted or estimated data, e.g. number of Gridlets used by an experiment, execution time and output size of a Gridlet, etc. need to present in the prediction or estimation process and the randomness that exists in the nature itself.

Example: to produce a random number between 18.00 and 22.00, need to invoke GridSimRandom.real(20.0, 0.1, 0.1, randDouble) where randDouble comes from java.util.Random.

Since:
GridSim Toolkit 1.0
Author:
Manzur Murshed and Rajkumar Buyya
See Also:
Gridlet, Random, GridSim.init(int, Calendar, boolean), GridSim.init(int, Calendar, boolean, String[], String[], String)
Invariant:
$none

Constructor Summary
GridSimRandom()
          Allocates a new GridSimRandom object
GridSimRandom(long seed)
          Allocates a new GridSimRandom object using a single long seed
GridSimRandom(long seed, double lessFactorIO, double moreFactorIO, double lessFactorExec, double moreFactorExec)
          Allocates a new GridSimRandom object with specified parameters
 
Method Summary
static double doubleSample()
          Gets the random double value from java.util.Random
static double expectedExec(double value)
          Gets the expected factor of Execution
static double expectedIO(double value)
          Gets the expected factor of Network I/O
static double getFactorExec()
          Gets the average factor of Execution
static double getFactorIO()
          Gets the average factor of Network I/O
static int intSample(int range)
          Gets the random int value from java.util.Random
static double real(double value, double lessFactor, double moreFactor, double randDouble)
          Maps the predicted or estimated value to a random real-world number between (1 - lessFactor) * value and (1 + moreFactor) * value.
static double realExec(double value)
          Gets the real number from the factors of Execution
static double realIO(double value)
          Gets the real number from the factors of Network I/O
static void setAllFactors(double lessFactorIOValue, double moreFactorIOValue, double lessFactorExecValue, double moreFactorExecValue)
          Sets the Network I/O and execution values
static void setLessFactorExec(double factor)
          Sets the less factor of Execution
static void setLessFactorIO(double factor)
          Sets the less factor of Network I/O
static void setMoreFactorExec(double factor)
          Sets the more factor of Execution
static void setMoreFactorIO(double factor)
          Sets the more factor of Network I/O
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridSimRandom

public GridSimRandom()
Allocates a new GridSimRandom object

Pre Condition:
$none
Post Condition:
$none

GridSimRandom

public GridSimRandom(long seed)
Allocates a new GridSimRandom object using a single long seed

Parameters:
seed - the initial seed
Pre Condition:
seed >= 0.0
Post Condition:
$none

GridSimRandom

public GridSimRandom(long seed,
                     double lessFactorIO,
                     double moreFactorIO,
                     double lessFactorExec,
                     double moreFactorExec)
Allocates a new GridSimRandom object with specified parameters

Parameters:
seed - the initial seed
lessFactorIO - less factor for Network I/O
moreFactorIO - more factor for Network I/O
lessFactorExec - less factor for execution
moreFactorExec - more factor for execution
Pre Condition:
seed >= 0.0, lessFactorIO >= 0.0, moreFactorIO >= 0.0, lessFactorExec >= 0.0, moreFactorExec >= 0.0
Post Condition:
$none
Method Detail

setAllFactors

public static void setAllFactors(double lessFactorIOValue,
                                 double moreFactorIOValue,
                                 double lessFactorExecValue,
                                 double moreFactorExecValue)
Sets the Network I/O and execution values

Parameters:
lessFactorIOValue - less factor for Network I/O
moreFactorIOValue - more factor for Network I/O
lessFactorExecValue - less factor for execution
moreFactorExecValue - more factor for execution
Pre Condition:
lessFactorIOValue >= 0.0, moreFactorIOValue >= 0.0, lessFactorExecValue >= 0.0, moreFactorExecValue >= 0.0
Post Condition:
$none

intSample

public static int intSample(int range)
                     throws IllegalArgumentException
Gets the random int value from java.util.Random

Parameters:
range - the bound on the random number to be returned. The range must be positive (excluding 0).
Returns:
a pseudorandom, uniformly distributed int value between 0 (inclusive) and range (exclusive)
Throws:
IllegalArgumentException - range is not positive
Pre Condition:
range > 0
Post Condition:
$result >= 0

doubleSample

public static double doubleSample()
Gets the random double value from java.util.Random

Returns:
the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence
Pre Condition:
$none
Post Condition:
$result >= 0.0 && $result <= 1.0

setLessFactorIO

public static void setLessFactorIO(double factor)
                            throws IllegalArgumentException
Sets the less factor of Network I/O

Parameters:
factor - the initial factor
Throws:
IllegalArgumentException - factor is not zero or positive
Pre Condition:
factor >= 0.0
Post Condition:
$none

setMoreFactorIO

public static void setMoreFactorIO(double factor)
                            throws IllegalArgumentException
Sets the more factor of Network I/O

Parameters:
factor - the initial factor
Throws:
IllegalArgumentException - factor is not zero or positive
Pre Condition:
factor >= 0.0
Post Condition:
$none

setLessFactorExec

public static void setLessFactorExec(double factor)
                              throws IllegalArgumentException
Sets the less factor of Execution

Parameters:
factor - the initial factor
Throws:
IllegalArgumentException - factor is not zero or positive
Pre Condition:
factor >= 0.0
Post Condition:
$none

setMoreFactorExec

public static void setMoreFactorExec(double factor)
                              throws IllegalArgumentException
Sets the more factor of Execution

Parameters:
factor - the initial factor
Throws:
IllegalArgumentException - factor is not zero or positive
Pre Condition:
factor >= 0.0
Post Condition:
$none

getFactorIO

public static double getFactorIO()
Gets the average factor of Network I/O

Returns:
factor of Network I/O
Pre Condition:
$none
Post Condition:
$result >= 0.0

getFactorExec

public static double getFactorExec()
Gets the average factor of Execution

Returns:
factor of Execution
Pre Condition:
$none
Post Condition:
$result >= 0.0

real

public static double real(double value,
                          double lessFactor,
                          double moreFactor,
                          double randDouble)
                   throws IllegalArgumentException
Maps the predicted or estimated value to a random real-world number between (1 - lessFactor) * value and (1 + moreFactor) * value.

The formula used is:
value * (1 - lessFactor + (lessFactor + moreFactor) * randDouble)
where 0.0 <= lessFactor and moreFactor <= 1.0

Parameters:
value - the estimated value
lessFactor - less factor for a value
moreFactor - more factor for a value (the range is between 0.0 and 1.0)
randDouble - an uniformly distributed double value between 0.0 and 1.0
Returns:
the real number in double
Throws:
IllegalArgumentException - value, lessFactor, moreFactor and randDouble are not zero or positive. In addition, the max. number for moreFactor and randDouble is 1.0
Pre Condition:
value >= 0.0, lessFactor >= 0.0, moreFactor >= 0.0 && moreFactor <= 1.0, randDouble >= 0.0 && randDouble <= 1.0
Post Condition:
$none

realIO

public static double realIO(double value)
                     throws IllegalArgumentException
Gets the real number from the factors of Network I/O

Parameters:
value - the estimated value
Returns:
the real number in double
Throws:
IllegalArgumentException - value is not zero or positive
Pre Condition:
value >= 0.0
Post Condition:
$none

realExec

public static double realExec(double value)
                       throws IllegalArgumentException
Gets the real number from the factors of Execution

Parameters:
value - the estimated value
Returns:
the real number in double
Throws:
IllegalArgumentException - factor is not zero or positive
Pre Condition:
value >= 0.0
Post Condition:
$none

expectedIO

public static double expectedIO(double value)
                         throws IllegalArgumentException
Gets the expected factor of Network I/O

Parameters:
value - the estimated value
Returns:
the expected number in double
Throws:
IllegalArgumentException - factor is not zero or positive
Pre Condition:
value >= 0.0
Post Condition:
$none

expectedExec

public static double expectedExec(double value)
                           throws IllegalArgumentException
Gets the expected factor of Execution

Parameters:
value - the estimated value
Returns:
the expected number in double
Throws:
IllegalArgumentException - factor is not zero or positive
Pre Condition:
value >= 0.0
Post Condition:
$none

GridSim 5.0 beta

The University of Melbourne, Australia, 2009