/** The main function */
  @Override
  public void run() {

    for (Iterator it = getTaskList().iterator(); it.hasNext(); ) {
      Task task = (Task) it.next();
      double duration = task.getCloudletLength() / 1000;

      for (int i = 0; i < task.getParentList().size(); i++) {
        Task parent = task.getParentList().get(i);
      }

      for (int i = 0; i < task.getChildList().size(); i++) {
        Task child = task.getChildList().get(i);
      }

      int vmNum = getVmList().size();
      /** Randomly choose a vm */
      Random random = new Random((long) duration);
      int vmId = random.nextInt(vmNum);

      CondorVM vm = (CondorVM) getVmList().get(vmId);
      // This shows the cpu capability of a vm
      double mips = vm.getMips();

      task.setVmId(vm.getId());

      long deadline = Parameters.getDeadline();
    }
  }
  @Override
  public void run() {

    int size = getCloudletList().size();

    for (int i = 0; i < size; i++) {

      Cloudlet cloudlet = (Cloudlet) getCloudletList().get(i);

      int vmSize = getVmList().size();
      CondorVM closestVm = null; // (CondorVM)getVmList().get(0);
      double minTime = Double.MAX_VALUE;
      for (int j = 0; j < vmSize; j++) {
        CondorVM vm = (CondorVM) getVmList().get(j);
        if (vm.getState() == WorkflowSimTags.VM_STATUS_IDLE) {
          Job job = (Job) cloudlet;
          double time = dataTransferTime(job.getFileList(), cloudlet, vm.getId());
          if (time < minTime) {
            minTime = time;
            closestVm = vm;
          }
        }
      }

      if (closestVm != null) {
        closestVm.setState(WorkflowSimTags.VM_STATUS_BUSY);
        cloudlet.setVmId(closestVm.getId());
        getScheduledList().add(cloudlet);
      }
    }
  }
  @Override
  public void run() {
    // Round Robin

    for (Iterator it = getCloudletList().iterator(); it.hasNext(); ) {
      Cloudlet cloudlet = (Cloudlet) it.next();
      boolean stillHasVm = false;
      for (Iterator itc = getVmList().iterator(); itc.hasNext(); ) {

        CondorVM vm = (CondorVM) itc.next();
        if (vm.getState() == WorkflowSimTags.VM_STATUS_IDLE) {
          stillHasVm = true;
          vm.setState(WorkflowSimTags.VM_STATUS_BUSY);
          cloudlet.setVmId(vm.getId());
          this.scheduledList.add(cloudlet);
          break;
        }
      }
      // no vm available
      if (!stillHasVm) {
        break;
      }
    }
  }