Class UtilizationModelDynamic
- All Implemented Interfaces:
UtilizationModel
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
-
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
ModifierConstructorDescriptionCreates a UtilizationModelDynamic with no initial utilization.UtilizationModelDynamic
(double initialUtilizationPercent) Creates a UtilizationModelDynamic that the initial resource utilization will be defined according to the given parameter and theUtilizationModel.Unit
will be set asUtilizationModel.Unit.PERCENTAGE
.UtilizationModelDynamic
(double initialUtilization, double maxResourceUtilization) Creates a UtilizationModelDynamic with an initial resource utilization and max resource utilization, where theUtilizationModel.Unit
is set asUtilizationModel.Unit.PERCENTAGE
.Creates a UtilizationModelDynamic with no initial utilization.UtilizationModelDynamic
(UtilizationModel.Unit unit, double initialUtilization) Creates a UtilizationModelDynamic that the initial resource utilization and theUtilizationModel.Unit
will be defined according to the given parameters.UtilizationModelDynamic
(UtilizationModel.Unit unit, double initialUtilization, double maxResourceUtilization) Creates a UtilizationModelDynamic that the initial resource utilization, max resource utilization and theUtilizationModel.Unit
will be defined according to the given parameters.protected
A copy constructor that creates a read-only UtilizationModelDynamic based on a source object.UtilizationModelDynamic
(UtilizationModelDynamic source, double initialUtilization) A copy constructor that creates a UtilizationModelDynamic based on a source object. -
Method Summary
Modifier and TypeMethodDescriptiondouble
Gets the maximum amount of resource that will be used.double
Gets the time difference from the current simulation time to the last time the resource utilization was updated.protected double
getUtilizationInternal
(double time) It will automatically increment theUtilizationModelAbstract.getUtilization()
by applying theincrement function
.final UtilizationModelDynamic
setMaxResourceUtilization
(double maxResourceUsagePercentage) Sets the maximum amount of resource that will be used.final UtilizationModelDynamic
setUtilizationUpdateFunction
(Function<UtilizationModelDynamic, Double> utilizationUpdateFunction) Sets the function defining how the resource utilization will be incremented or decremented along the time.Methods inherited from class org.cloudbus.cloudsim.utilizationmodels.UtilizationModelAbstract
getSimulation, getUnit, getUtilization, getUtilization, isOverCapacityRequestAllowed, setOverCapacityRequestAllowed, setSimulation, setUnit, validateUtilizationField, validateUtilizationField
-
Constructor Details
-
UtilizationModelDynamic
public UtilizationModelDynamic()Creates a UtilizationModelDynamic with no initial utilization. The resource utilization unit is defined inUtilizationModel.Unit.PERCENTAGE
.The utilization won't be dynamically incremented until an increment function is defined by the
setUtilizationUpdateFunction(Function)
.- See Also:
-
UtilizationModelDynamic
Creates a UtilizationModelDynamic with no initial utilization. The resource utilizationUtilizationModel.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
- 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)
-
UtilizationModelDynamic
public UtilizationModelDynamic(double initialUtilizationPercent) Creates a UtilizationModelDynamic that the initial resource utilization will be defined according to the given parameter and theUtilizationModel.Unit
will be set asUtilizationModel.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 theUtilizationModel.Unit
is set asUtilizationModel.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 theunit
parametermaxResourceUtilization
- the maximum resource utilization
-
UtilizationModelDynamic
Creates a UtilizationModelDynamic that the initial resource utilization and theUtilizationModel.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
- 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)initialUtilization
- the initial resource utilization, that the unit depends on theunit
parameter
-
UtilizationModelDynamic
public UtilizationModelDynamic(UtilizationModel.Unit unit, double initialUtilization, double maxResourceUtilization) Creates a UtilizationModelDynamic that the initial resource utilization, max resource utilization and theUtilizationModel.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
- 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)initialUtilization
- the initial resource utilization, that the unit depends on theunit
parametermaxResourceUtilization
- the maximum resource utilization
-
UtilizationModelDynamic
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
A copy constructor that creates a UtilizationModelDynamic based on a source object.- Parameters:
source
- the source UtilizationModelDynamic to create an instance frominitialUtilization
- 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 theUtilizationModelAbstract.getUtilization()
by applying theincrement function
.- Specified by:
getUtilizationInternal
in classUtilizationModelAbstract
-
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
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 thisUtilizationModel
, it receives a read-onlyUtilizationModelDynamic
instance and allow the developer using thisUtilizationModel
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 inUtilizationModel.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:
-