Class UtilizationModelStochastic
- All Implemented Interfaces:
UtilizationModel
The class may return different utilization values
for the same requested time.
For performance reasons, this behaviour is dependent of the isHistoryEnabled()
and isAlwaysGenNewRandUtilization()
.
- Since:
- CloudSim Toolkit 2.0
- Author:
- Anton Beloglazov, Manoel Campos da Silva Filho
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cloudbus.cloudsim.utilizationmodels.UtilizationModel
UtilizationModel.Unit
-
Field Summary
Fields inherited from class org.cloudbus.cloudsim.utilizationmodels.UtilizationModelAbstract
ALMOST_ZERO
Fields inherited from interface org.cloudbus.cloudsim.utilizationmodels.UtilizationModel
NULL
-
Constructor Summary
ConstructorDescriptionInstantiates a utilization model stochastic that defines the resource utilization in percentage.UtilizationModelStochastic
(long seed) Instantiates a utilization model stochastic that defines the resource utilization in percentage.Instantiates a utilization model stochastic based on a given Pseudo Random Number Generator (PRNG).Instantiates a utilization model stochastic where the resource utilization is defined in the given unit.UtilizationModelStochastic
(UtilizationModel.Unit unit, long seed) Instantiates a utilization model stochastic where the resource utilization is defined in the given unit.Instantiates a new utilization model stochastic based on a given Pseudo Random Number Generator (PRNG). -
Method Summary
Modifier and TypeMethodDescriptionGets the random number generator.protected Double
getUtilizationHistory
(double time) Gets the utilization percentage for a given time from the internalhistoryMap
.protected double
getUtilizationInternal
(double time) boolean
Checks if every time theUtilizationModelAbstract.getUtilization()
orUtilizationModelAbstract.getUtilization(double)
methods are called, a new randomly generated utilization will be returned or not.boolean
Checks if the history of resource utilization along simulation time is to be kept or not.void
loadHistory
(String filename) Load a utilization history from a file.void
saveHistory
(String filename) Save the utilization history to a file.setAlwaysGenNewRandUtilization
(boolean alwaysGenNewRandUtilization) Allow the model to always generate a new random utilization value whenUtilizationModelAbstract.getUtilization()
methods are called, even if the simulation clock hasn't changed since the last call.setHistoryEnabled
(boolean enable) Enables or disables the resource utilization history, so that utilization values are stored along all the simulation execution.final void
setRandomGenerator
(ContinuousDistribution randomGenerator) Sets the random number generator.Methods inherited from class org.cloudbus.cloudsim.utilizationmodels.UtilizationModelAbstract
getSimulation, getUnit, getUtilization, getUtilization, isOverCapacityRequestAllowed, setOverCapacityRequestAllowed, setSimulation, setUnit, validateUtilizationField, validateUtilizationField
-
Constructor Details
-
UtilizationModelStochastic
public UtilizationModelStochastic()Instantiates a utilization model stochastic that defines the resource utilization in percentage. The resource utilization history is enabled by default. -
UtilizationModelStochastic
Instantiates a utilization model stochastic where the resource utilization is defined in the given unit. The resource utilization history is enabled by default.- Parameters:
unit
- theUtilizationModel.Unit
that determines how the resource is used (for instance, if resource usage is defined in percentage of the Vm resource or in absolute values)- See Also:
-
UtilizationModelStochastic
Instantiates a utilization model stochastic where the resource utilization is defined in the given unit. The resource utilization history is enabled by default.- Parameters:
unit
- theUtilizationModel.Unit
that determines how the resource is used (for instance, if resource usage is defined in percentage of the Vm resource or in absolute values)seed
- the seed to initialize the random number generator.- See Also:
-
UtilizationModelStochastic
public UtilizationModelStochastic(long seed) Instantiates a utilization model stochastic that defines the resource utilization in percentage. The resource utilization history is enabled by default.- Parameters:
seed
- the seed to initialize the random number generator.- See Also:
-
UtilizationModelStochastic
Instantiates a utilization model stochastic based on a given Pseudo Random Number Generator (PRNG). It defines the resource utilization in percentage. The resource utilization history is enabled by default.- Parameters:
prng
- the Pseudo Random Number Generator (PRNG) to generate utilization values- See Also:
-
UtilizationModelStochastic
Instantiates a new utilization model stochastic based on a given Pseudo Random Number Generator (PRNG). The resource utilization history is enabled by default.- Parameters:
unit
- theUtilizationModel.Unit
that determines how the resource is used (for instance, if resource usage is defined in percentage of the Vm resource or in absolute values)prng
- the Pseudo Random Number Generator (PRNG) to generate utilization values- See Also:
-
-
Method Details
-
getUtilizationInternal
protected double getUtilizationInternal(double time) - Specified by:
getUtilizationInternal
in classUtilizationModelAbstract
- See Also:
-
getUtilizationHistory
Gets the utilization percentage for a given time from the internalhistoryMap
.- Parameters:
time
- the time to get the utilization history for- Returns:
- the stored utilization percentage or null if it has never been generated an utilization value for the given time
-
saveHistory
Save the utilization history to a file.- Parameters:
filename
- the filename- Throws:
UncheckedIOException
- when the file cannot be accessed
-
loadHistory
Load a utilization history from a file.- Parameters:
filename
- the filename- Throws:
UncheckedIOException
- when the file cannot be accessed
-
getRandomGenerator
Gets the random number generator.- Returns:
- the random number generator
-
setRandomGenerator
Sets the random number generator.- Parameters:
randomGenerator
- the new random number generator
-
isHistoryEnabled
public boolean isHistoryEnabled()Checks if the history of resource utilization along simulation time is to be kept or not.- Returns:
- true if the history is to be kept, false otherwise
- See Also:
-
setHistoryEnabled
Enables or disables the resource utilization history, so that utilization values are stored along all the simulation execution.If utilization history is disable, more pseudo-random numbers will be generated, decreasing simulation performance. Changing this attribute is a trade-off between memory and CPU utilization:
- enabling reduces CPU utilization but increases RAM utilization;
- disabling reduces RAM utilization but increases CPU utilization.
- Parameters:
enable
- true to enable the utilization history, false to disable- Returns:
-
isAlwaysGenNewRandUtilization
public boolean isAlwaysGenNewRandUtilization()Checks if every time theUtilizationModelAbstract.getUtilization()
orUtilizationModelAbstract.getUtilization(double)
methods are called, a new randomly generated utilization will be returned or not. This attribute is false by default, meaning that consecutive utilization requests for the same time may return the same previous generated utilization value. Check the documentation in the return section at the end for details.Using one instance of this utilization model for every Cloudlet in a large simulation scenario may be very expensive in terms of simulation time and memory consumption. This way, the researcher may want to use a single utilization model instance for every Cloudlet. The side effect is that, if this attribute is false (the default), it will usually return the same utilization value for the same requested time for distinct Cloudlets. That commonly is not what the researcher wants. He/she usually wants that every Cloudlet has an independent resource utilization.
To reduce simulation time and memory consumption, you can use a single utilization model instance for a given Cloudlet resource (such as CPU) and set this attribute to false. This way, it will always generate different utilization values for every time an utilization is requested (even if the same previous time is given).
- Returns:
- true if a new randomly generated utilization will always be returned;
false if for the same requested time, the same utilization must be returned.
In this last case, it's just ensured that, for a given time,
the same utilization will always be returned,
if the
history is enabled
. - See Also:
-
setAlwaysGenNewRandUtilization
public UtilizationModelStochastic setAlwaysGenNewRandUtilization(boolean alwaysGenNewRandUtilization) Allow the model to always generate a new random utilization value whenUtilizationModelAbstract.getUtilization()
methods are called, even if the simulation clock hasn't changed since the last call.- Parameters:
alwaysGenNewRandUtilization
- true to allow generating a new random value for each time the resource utilization is required; false to disable- Returns:
- See Also:
-