Class UtilizationModelStochastic

java.lang.Object
org.cloudbus.cloudsim.utilizationmodels.UtilizationModelAbstract
org.cloudbus.cloudsim.utilizationmodels.UtilizationModelStochastic
All Implemented Interfaces:
UtilizationModel

public class UtilizationModelStochastic extends UtilizationModelAbstract
Implements a model, according to which a Cloudlet generates random resource utilization every time frame.

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
  • Constructor Details

  • Method Details

    • getUtilizationInternal

      protected double getUtilizationInternal(double time)
      Specified by:
      getUtilizationInternal in class UtilizationModelAbstract
      See Also:
    • getUtilizationHistory

      protected Double getUtilizationHistory(double time)
      Gets the utilization percentage for a given time from the internal historyMap.
      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

      public void saveHistory(String filename)
      Save the utilization history to a file.
      Parameters:
      filename - the filename
      Throws:
      UncheckedIOException - when the file cannot be accessed
    • loadHistory

      public void loadHistory(String filename)
      Load a utilization history from a file.
      Parameters:
      filename - the filename
      Throws:
      UncheckedIOException - when the file cannot be accessed
    • getRandomGenerator

      public ContinuousDistribution getRandomGenerator()
      Gets the random number generator.
      Returns:
      the random number generator
    • setRandomGenerator

      public final void setRandomGenerator(ContinuousDistribution randomGenerator)
      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

      public UtilizationModelStochastic setHistoryEnabled(boolean enable)
      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 the UtilizationModelAbstract.getUtilization() or UtilizationModelAbstract.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 when UtilizationModelAbstract.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: