Class UtilizationModelDynamic

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

public class UtilizationModelDynamic extends UtilizationModelAbstract
A Cloudlet UtilizationModel that allows to increase the utilization of the related resource along the simulation time. It accepts a Lambda Expression that defines how the utilization increment must behave. This way, the class enables the developer to define such a behaviour when instantiating objects of this class.

For instance, it is possible to use the class to arithmetically or geometrically increment resource usage, but any kind of increment as logarithmic or exponential is possible. For more details, see the setUtilizationUpdateFunction(Function).

Since:
CloudSim Plus 1.0
Author:
Manoel Campos da Silva Filho
  • Constructor Details

    • UtilizationModelDynamic

      public UtilizationModelDynamic()
      Creates a UtilizationModelDynamic with no initial utilization. The resource utilization unit is defined in UtilizationModel.Unit.PERCENTAGE.

      The utilization won't be dynamically incremented until an increment function is defined by the setUtilizationUpdateFunction(Function).

      See Also:
    • UtilizationModelDynamic

      public UtilizationModelDynamic(UtilizationModel.Unit unit)
      Creates a UtilizationModelDynamic with no initial utilization. The resource utilization UtilizationModel.Unit is defined according to the given parameter.

      The utilization won't be dynamically incremented until that an increment function is defined by the setUtilizationUpdateFunction(Function).

      Parameters:
      unit - the UtilizationModel.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)
    • UtilizationModelDynamic

      public UtilizationModelDynamic(double initialUtilizationPercent)
      Creates a UtilizationModelDynamic that the initial resource utilization will be defined according to the given parameter and the UtilizationModel.Unit will be set as UtilizationModel.Unit.PERCENTAGE.

      The utilization will not be dynamically incremented until that an increment function is defined by the setUtilizationUpdateFunction(Function).

      Parameters:
      initialUtilizationPercent - the initial percentage of resource utilization
    • UtilizationModelDynamic

      public UtilizationModelDynamic(double initialUtilization, double maxResourceUtilization)
      Creates a UtilizationModelDynamic with an initial resource utilization and max resource utilization, where the UtilizationModel.Unit is set as UtilizationModel.Unit.PERCENTAGE.

      The utilization will not be dynamically incremented until that an increment function is defined by the setUtilizationUpdateFunction(Function).

      Parameters:
      initialUtilization - the initial resource utilization, that the unit depends on the unit parameter
      maxResourceUtilization - the maximum resource utilization
    • UtilizationModelDynamic

      public UtilizationModelDynamic(UtilizationModel.Unit unit, double initialUtilization)
      Creates a UtilizationModelDynamic that the initial resource utilization and the UtilizationModel.Unit will be defined according to the given parameters.

      The utilization will not be dynamically incremented until that an increment function is defined by the setUtilizationUpdateFunction(Function).

      Parameters:
      unit - the UtilizationModel.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)
      initialUtilization - the initial resource utilization, that the unit depends on the unit parameter
    • UtilizationModelDynamic

      public UtilizationModelDynamic(UtilizationModel.Unit unit, double initialUtilization, double maxResourceUtilization)
      Creates a UtilizationModelDynamic that the initial resource utilization, max resource utilization and the UtilizationModel.Unit will be defined according to the given parameters.

      The utilization will not be dynamically incremented until that an increment function is defined by the setUtilizationUpdateFunction(Function).

      Parameters:
      unit - the UtilizationModel.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)
      initialUtilization - the initial resource utilization, that the unit depends on the unit parameter
      maxResourceUtilization - the maximum resource utilization
    • UtilizationModelDynamic

      protected UtilizationModelDynamic(UtilizationModelDynamic source)
      A copy constructor that creates a read-only UtilizationModelDynamic based on a source object.
      Parameters:
      source - the source UtilizationModelDynamic to create an instance from
    • UtilizationModelDynamic

      public UtilizationModelDynamic(UtilizationModelDynamic source, double initialUtilization)
      A copy constructor that creates a UtilizationModelDynamic based on a source object.
      Parameters:
      source - the source UtilizationModelDynamic to create an instance from
      initialUtilization - the initial resource utilization (in the same unit of the given UtilizationModelDynamic instance)
  • Method Details

    • getUtilizationInternal

      protected double getUtilizationInternal(double time)
      It will automatically increment the UtilizationModelAbstract.getUtilization() by applying the increment function.
      Specified by:
      getUtilizationInternal in class UtilizationModelAbstract
    • getTimeSpan

      public double getTimeSpan()
      Gets the time difference from the current simulation time to the last time the resource utilization was updated.
      Returns:
    • getMaxResourceUtilization

      public double getMaxResourceUtilization()
      Gets the maximum amount of resource that will be used.

      Such a value can be a percentage in scale from [0 to 1] or an absolute value, depending on the UtilizationModelAbstract.getUnit().

      Returns:
      the maximum resource utilization
    • setMaxResourceUtilization

      public final UtilizationModelDynamic setMaxResourceUtilization(double maxResourceUsagePercentage)
      Sets the maximum amount of resource that will be used.

      Such a value can be a percentage in scale from [0 to 1] or an absolute value, depending on the UtilizationModelAbstract.getUnit().

      Parameters:
      maxResourceUsagePercentage - the maximum resource usage
      Returns:
    • setUtilizationUpdateFunction

      public final UtilizationModelDynamic setUtilizationUpdateFunction(Function<UtilizationModelDynamic,Double> utilizationUpdateFunction)
      Sets the function defining how the resource utilization will be incremented or decremented along the time.

      Such a function must require one UtilizationModelDynamic parameter and return the new resource utilization. When this function is called internally by this UtilizationModel, it receives a read-only UtilizationModelDynamic instance and allow the developer using this UtilizationModel to define how the utilization must be updated.

      For instance, to define an arithmetic increment, a Lambda function to be given to this setter could be defined as below:

      um -> um.getUtilization() + um.getTimeSpan()*0.1

      Considering the UtilizationModel UtilizationModel.Unit was defined in UtilizationModel.Unit.PERCENTAGE, such a Lambda Expression will increment the usage in 10% for each second that has passed since the last time the utilization was computed.

      The value returned by the given Lambda Expression will be automatically validated to avoid negative utilization or utilization over 100% (when the UtilizationModel unit is defined in percentage). The function would be defined to decrement the utilization along the time, by just changing the plus to a minus signal.

      Defining a geometric progression for the resource utilization is as simple as changing the plus signal to a multiplication signal.

      Parameters:
      utilizationUpdateFunction - the utilization increment function to set, that will receive the UtilizationModel instance and must return the new utilization value based on the previous utilization.
      Returns: