@Override
	public void doScheduling(long availableExecTime, VMOffers vmOffers) {
				
		Enumeration<DataItem> dataIter = dataItems.elements();
		while(dataIter.hasMoreElements()){
			DataItem item = dataIter.nextElement();
			dataRequiredLocation.put(item.getId(), new HashSet<Integer>());
		}
		
		//===== 1.Determine available computation services =====
		
		//what's the best VM available?
		vmOffersList = getVmOfferList();
                
                Log.printLine("Simulation optimized : " + optimizeScheduling);
                
                if(optimizeScheduling) 
                    CP=findCriticalPath();  
                
		for(Task ti:tasks){
			
                        Vm instance = null;
                        if(optimizeScheduling)
                        {
                            if(CP.contains(ti))
                            {
                                ti.setCritical(true);   
                                Log.printLine("task num " + ti.getId()+" app au CP : vm rapide ");
                                instance = vmOffersList.get(vmOffersList.size()-1);
                            }
                            else
                            {
                                Log.printLine("task num " + ti.getId()+" app PAS au CP : vm lente ");
                                instance = vmOffersList.get(0); // vm lente
                            }
                        }else
                        {
                            //use only the best available VM, one task per VM
                            instance = vmOffersList.get(vmOffersList.size()-1);
                        }
                              
                        
                        
			Vm newVm = new Vm(vmId,ownerId,instance.getMips(),instance.getNumberOfPes(),instance.getRam(),instance.getBw(),instance.getSize(),"",new CloudletSchedulerTimeShared());
			int cost = vmOffers.getCost(newVm.getMips(), newVm.getRam(), newVm.getBw());
			provisioningInfo.add(new ProvisionedVm(newVm,0,availableExecTime,cost));
			ArrayList<Task> tList = new ArrayList<Task>();
			tList.add(ti);
			schedulingTable.put(newVm.getId(), tList);
			ti.setVmId(newVm.getId());
			
			//set data dependencies info
			for(DataItem data:ti.getDataDependencies()){
				if(!dataRequiredLocation.containsKey(data.getId())){
					dataRequiredLocation.put(data.getId(), new HashSet<Integer>());
				}
				dataRequiredLocation.get(data.getId()).add(newVm.getId());
			}
			
			for(DataItem data:ti.getOutput()){
				if(!dataRequiredLocation.containsKey(data.getId())){
					dataRequiredLocation.put(data.getId(), new HashSet<Integer>());
				}
			}
			
			vmId++;
		}
               
	}