@Override
  public void execute() {

    double util = 0;
    double power = 0;
    double prevSlavWork;
    double prevWork;

    // store current work and SLA violated work values
    prevSlavWork = totalSlavWork;
    prevWork = totalWork;

    // reset total work values
    totalSlavWork = 0;
    totalWork = 0;

    totalPower = 0;

    for (Host host : dc.getHosts()) {

      // store host CPU utilization
      if (!hostUtil.containsKey(host)) {
        hostUtil.put(host, new DescriptiveStatistics());
      }

      hostUtil.get(host).addValue(host.getCpuManager().getCpuInUse());

      util += host.getCpuManager().getCpuInUse();

      // get VM SLA values
      for (VMAllocation vmAlloc : host.getVMAllocations()) {
        totalSlavWork += vmAlloc.getVm().getApplication().getTotalSLAViolatedWork();
        totalWork +=
            vmAlloc
                .getVm()
                .getApplication()
                .getTotalIncomingWork(); // NOTE: This ONLY works with SINGLE TIERED applications.
        // For multi-tiered applications, this will count incoming
        // work multiple times!!
      }

      // get power consumption
      power += host.getCurrentPowerConsumption();
      totalPower += host.getPowerConsumed();
    }

    dcUtil.addValue(util);

    dcPower.addValue(power);
    dcPowerEfficiency.addValue(util / power);
    double optimalPowerConsumption = calculateOptimalPowerConsumption(util);
    dcOptimalPower.addValue(optimalPowerConsumption);
    dcOptimalPowerEfficiency.addValue(util / optimalPowerConsumption);

    dcOptimalPowerRatio.addValue((util / optimalPowerConsumption) / (util / power));

    // records the total fraction of SLA violated incoming work since the last time interval
    dcSla.addValue((totalSlavWork - prevSlavWork) / (totalWork - prevWork));
  }
  /**
   * Construct a list of VMs that must be executed
   *
   * @param hosts
   * @return
   */
  private ArrayList<VMAllocation> buildVmList(ArrayList<Host> hosts) {
    ArrayList<VMAllocation> vmList = new ArrayList<VMAllocation>();

    for (Host host : hosts) {
      vmList.addAll(host.getVMAllocations());
    }
    Collections.sort(vmList, new VmExecutionOrderComparator());

    return vmList;
  }