org.cloudbus.cloudsim.power.models.PowerModelSpecPower Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudsim-plus Show documentation
Show all versions of cloudsim-plus Show documentation
CloudSim Plus: A modern, highly extensible and easier-to-use Java 8 Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.power.models;
/**
* The abstract class of power models created based on data from
* SPECpower benchmark.
*
* If you are using any algorithms, policies or workload included in the power package please cite
* the following paper:
*
*
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 3.0
*/
public abstract class PowerModelSpecPower extends PowerModelAbstract {
@Override
public double getMaxPower() {
return getPower(1);
}
@Override
protected double getPowerInternal(final double utilization) throws IllegalArgumentException {
if (utilization % 0.1 == 0) {
return getPowerData((int) (utilization * 10));
}
final int utilization1 = (int) Math.floor(utilization * 10);
final int utilization2 = (int) Math.ceil(utilization * 10);
final double power1 = getPowerData(utilization1);
final double power2 = getPowerData(utilization2);
final double delta = (power2 - power1) / 10;
return power1 + delta * (utilization - (double) utilization1 / 10) * 100;
}
/**
* Gets the power consumption for a given utilization percentage.
*
* @param index the utilization percentage in the scale from [0 to 10],
* where 10 means 100% of utilization.
* @return the power consumption for the given utilization percentage
*/
protected abstract double getPowerData(final int index);
}