Index: DCWoRMS/branches/coolemall/src/test/testSOP/Utility.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/Utility.java	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/Utility.java	(revision 1606)
@@ -0,0 +1,279 @@
+package test.testSOP;
+
+import gridsim.dcworms.DCWormsTags;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+
+import dcworms.schedframe.scheduling.ExecTask;
+
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+
+public class Utility {
+	public static int NUMBER_HOST_PIVOT = 1;
+	public static String HOST_NUMBER_PATH = "src/test/testSOP_results/data/expectedHostNumber.txt";
+	
+	
+	//Retrieve nodes by powerstateNames
+	public static List<Node> getNodesByPowerState(List<Node> nodes, StandardPowerStateName psName) {
+		ArrayList<Node> nodelist = new ArrayList<Node>();
+		for (Node n : nodes) {
+			if (n.getPowerInterface().getPowerState().equals(psName)) {
+				nodelist.add(n);
+			}
+		}
+		return nodelist;
+	}
+
+	
+	public static int getExpectedHostNumber(JobRegistry jr, ClusterResourceManager resourceManager, Log log) {
+		float cpuReq = 0;
+		float memReq = 0;
+
+		synchronized(jr.getTasks()) {
+			for (ExecTask t : jr.getTasks()) {
+	
+				if (t.getStatus() != DCWormsTags.SUCCESS && t.getStatus() != DCWormsTags.FAILED
+						&& t.getStatus() != DCWormsTags.CANCELED) {
+	
+					try {
+						cpuReq += t.getCpuCntRequest();
+						memReq += t.getMemoryRequest();
+					} catch (NoSuchFieldException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+				}
+			}
+		}
+		// Compute total capacity
+		List<Node> nodes = resourceManager.getNodes();
+		float cpuCapacity = 0;
+		float memCapacity = 0;
+		for (Node n : nodes) {
+			try {
+				cpuCapacity += n.getProcessorsNumber();
+				memCapacity += n.getTotalMemory();
+			} catch (NoSuchFieldException e) {
+				e.printStackTrace();
+			}
+		}
+		// log.debug("CPU capacity = "+cpuCapacity);
+		// log.debug("MEM capacity = "+memCapacity);
+		//log.debug("CPU req = " + cpuReq);
+		//log.debug("MEM req = " + memReq);
+		float averageHostCPUCapacity = cpuCapacity / (float) nodes.size();
+		float averageHostMEMCapacity = memCapacity / (float) nodes.size();
+		//log.debug("avgMaxHostCPUCapacity = " + averageHostCPUCapacity);
+		//log.debug("averageHostMEMCapacity = " + averageHostMEMCapacity);
+		int expectedHostNumberCPU = (int) (cpuReq / averageHostCPUCapacity);
+		int expectedHostNumberMEM = (int) (memReq / averageHostMEMCapacity);
+		int expectedHostNumber = Math.max(expectedHostNumberCPU, expectedHostNumberMEM);
+		// log.debug("Expecting needing max ("+expectedHostNumberCPU+","+expectedHostNumberMEM+") Nodes");
+
+		expectedHostNumber = expectedHostNumber + Utility.NUMBER_HOST_PIVOT;
+		log.debug("Host to be on : " + expectedHostNumber);
+		//
+		// PrintWriter writer = null;
+		// try {
+		// writer = new PrintWriter(new FileWriter(HOST_NUMBER_PATH, true));
+		// writer.println(String.format("%d", expectedHostNumber));
+		// writer.close();
+		// } catch (IOException e) {
+		// e.printStackTrace();
+		// } finally {
+		// writer.close();
+		// }
+		return expectedHostNumber;
+	}
+	
+	public static int getAllRunningTasks(JobRegistry jr) {
+		int nb = 0;
+		synchronized(jr.getTasks()) {
+			for (ExecTask t : jr.getTasks()) {
+				
+				if (t.getStatus() != DCWormsTags.SUCCESS && t.getStatus() != DCWormsTags.FAILED && t.getStatus() != DCWormsTags.CANCELED) {
+					nb++;
+				}
+			}
+		}
+		return nb;
+	}
+	
+	public static void manageHosts(JobRegistry jr, ClusterResourceManager resourceManager, Log log) {
+		List<Node> nodes = resourceManager.getNodes();
+		int expectedHostNumber = getExpectedHostNumber(jr, resourceManager, log);
+
+		//Counting ON and BOOT hosts
+		int nbOnHosts = 0;
+		int nbBootingHosts = 0;
+		for (Node n : nodes) {
+			if (n.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)) {
+				nbOnHosts++;
+			}
+			if (n.getPowerInterface().getPowerState().equals(StandardPowerStateName.BOOT)) {
+				nbBootingHosts++;
+			}
+		}
+		synchronized(jr.getTasks()) {
+			for (ExecTask t : jr.getTasks()) {
+	
+				if (t.getStatus() != DCWormsTags.SUCCESS && t.getStatus() != DCWormsTags.FAILED
+						&& t.getStatus() != DCWormsTags.CANCELED) {
+					log.debug(t.getJobId()+ " is still running");
+				}
+			}
+		}
+		log.debug("");
+		//log.debug("There is "+(nbOnHosts+nbBootingHosts)+" powered ON("+nbOnHosts+") or BOOTING("+nbBootingHosts+")");
+		int nbTotal = nbOnHosts+nbBootingHosts;
+		
+		PrintWriter writer = null;
+		try {
+			writer = new PrintWriter(new FileWriter(HOST_NUMBER_PATH, true));
+			writer.println(String.format("%d\t%d", nbOnHosts, expectedHostNumber));
+			log.debug("Wrote in HOST_NUMBER_PATH: "+HOST_NUMBER_PATH);
+			writer.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			writer.close();
+		}
+		
+		//We have to power on a host
+		if (nbTotal < expectedHostNumber) {
+			//log.debug("nbOnHosts < expectedHostNumber : We have to power on a host");
+			Node n = findNodeToPowerON(resourceManager, log);
+//			ArrayList<Node> nList = findNodeListToPowerON(resourceManager, log);
+			if(n != null) {
+				//log.debug("Powering ON node "+n.getName());
+//				n.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+				n.getPowerInterface().turnOn();
+			}
+		}
+		//We have to power off hosts
+		else if (nbTotal > expectedHostNumber) {
+			log.debug("nbOnHosts > expectedHostNumber : We have to power off hosts");
+//			Node n = findNodeToPowerOFF(resourceManager, log);
+			ArrayList<Node> nList = findNodeListToPowerOFF(resourceManager, log);
+			if (nList!= null) {
+				log.debug("Half the hosts nb is :"+Math.ceil((float)nList.size()/(float)2));
+				for(int i = 0 ; i<Math.ceil((float)nList.size()/(float)2) ; i++) {
+					//log.debug("Powering OFF node " +nList.get(i).getName());
+					nList.get(i).getPowerInterface().turnOff();
+				}
+			}
+		}
+		//We do nothing
+		else {
+			log.debug("The right number of hosts, do nothing");
+		}
+	}
+	
+	//Find all nodes that we can power off
+	private static ArrayList<Node> findNodeListToPowerOFF(ClusterResourceManager resourceManager, Log log) {
+		List<Node> nodes = resourceManager.getNodes();
+		ArrayList<Node> nodeList = new ArrayList<Node>();
+		for (Node n : nodes) {
+			if (n.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)) {
+				if (nodeIsEmpty(n, log)) {
+					nodeList.add(n);
+				}
+			}
+		}
+		if (nodeList.size() == 0) {
+			log.debug("findNodeToPowerOFF() : no host found");
+			return null;
+		}
+		else {
+			return nodeList;
+		}
+	}
+
+
+	/**
+	 * Finds empty node to power off
+	 * @param resourceManager
+	 * @return
+	 */
+	//TODO: Find best node to poweroff, sort list?
+	private static Node findNodeToPowerOFF(ClusterResourceManager resourceManager, Log log) {
+		List<Node> nodes = resourceManager.getNodes();
+		for (Node n : nodes) {
+			if (n.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)) {
+				if (nodeIsEmpty(n, log)) {
+					return n;
+				}
+			}
+		}
+		log.debug("findNodeToPowerOFF() : no host found");
+		return null;
+	}
+
+	/**
+	 * Find first node to power ON
+	 * @param resourceManager
+	 * @return
+	 */
+	//TODO: Find best node to powerOn, sort list?
+	private static Node findNodeToPowerON(ClusterResourceManager resourceManager, Log log) {
+		List<Node> nodes = resourceManager.getNodes();
+		for (Node n : nodes) {
+			if (n.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
+				return n;
+		}
+		//log.debug("findNodeToPowerON() : no host found");
+		return null;
+	}
+
+	public static boolean nodeIsEmpty(Node n, Log log) {
+		try {
+			boolean ret =  (n.getFreeMemory() == n.getTotalMemory()) && (n.getFreeProcessorsNumber() == n.getProcessorsNumber());
+			if (ret == false) {
+				//log.debug("FreeMEM: "+n.getFreeMemory()+" // TotalMEM : " +n.getTotalMemory());
+			}
+			return ret;
+		} catch (NoSuchFieldException e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
+
+
+	public static void deleteFile(String path, Log log) {
+		//Delete migration file
+		File file = new File(path);
+		if (file.delete()) {
+			log.debug("Successfully deleted file "+path);
+		}
+		else {
+			log.debug("Failed to delete file "+path);
+		}
+		
+	}
+	
+	/**
+	 * Executes an external python program
+	 * @param path path to executable
+	 */
+	public static void executeExternalProgram(String path) {
+		ProcessBuilder pb = new ProcessBuilder("python",path);
+		try {
+			Process p = pb.start();
+			p.waitFor();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+	}
+}
Index: DCWoRMS/branches/coolemall/src/test/testSOP/BaseTimeEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/BaseTimeEstimationPlugin.java	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/BaseTimeEstimationPlugin.java	(revision 1606)
@@ -0,0 +1,79 @@
+package test.testSOP;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.Parameters;
+import schedframe.PluginConfiguration;
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.units.PEUnit;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin;
+
+
+public class BaseTimeEstimationPlugin implements ExecutionTimeEstimationPlugin {
+	Log log = LogFactory.getLog(BaseTimeEstimationPlugin.class); 
+	public PluginConfiguration getConfiguration() {
+		return null;
+	}
+
+	public String getName() {
+		return getClass().getName();
+	}
+
+	public void init(Parameters parameters) {
+	}
+
+	public double estimateMigrationTime(SchedulingEvent event, ExecTask task,
+			Map<ResourceUnitName, ResourceUnit> srcResources, Map<ResourceUnitName, ResourceUnit> dstResources) {
+		double time = 0;
+		//Test migration 10s
+//		log.debug("Migration takes "+time+" seconds.");
+		return time;
+	}
+
+	/*
+	 * This method should return an estimation of time required to execute the task.
+	 * Requested calculation should be done based on the resources allocated for the task,
+	 * task description and task completion percentage.
+	 * 
+	 * Example implementation calculate the estimation based on cpu processing power.
+	 * There is also a simple assumption, that cpu processing power is a linear function
+	 * of number of allocated cpus and their speed.
+	 */
+	public double execTimeEstimation(SchedulingEvent event, ExecTask task,
+			Map<ResourceUnitName, ResourceUnit> allocatedResources,
+			double completionPercentage) {
+		
+		// collect all information necessary to do the calculation
+		PEUnit peUnit = (PEUnit) allocatedResources.get(StandardResourceUnitName.PE);
+
+		// obtain single pe speed
+		int speed = peUnit.getSpeed();
+
+		// number of used pe  
+		int cnt = peUnit.getUsedAmount();
+
+		// estimate remainingTaskLength
+		double remainingLength =  task.getLength() * (1 - completionPercentage/100);
+		
+		// do the calculation
+		double execTime = (remainingLength / (cnt * speed));
+
+		// if the result is very close to 0, but less then one millisecond then round this result to 0.001
+		if (Double.compare(execTime, 0.001) < 0) {
+			execTime = 0.001;
+		}
+
+		// time is measured in integer units, so get the nearest execTime int value.
+		execTime = Math.round(execTime);
+		return execTime;
+	}
+
+	
+}
Index: DCWoRMS/branches/coolemall/src/test/testSOP/ComparatorHostHighestLoadFirst.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/ComparatorHostHighestLoadFirst.java	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/ComparatorHostHighestLoadFirst.java	(revision 1606)
@@ -0,0 +1,34 @@
+package test.testSOP;
+
+import java.util.Comparator;
+
+import schedframe.resources.computing.Node;
+
+public class ComparatorHostHighestLoadFirst implements Comparator<Node>{
+	private float getMostLoadedResource(Node n) {
+		float memLoad = 0, cpuLoad;
+		try {
+			memLoad = (float)1 - (float)n.getFreeMemory() / (float)n.getTotalMemory();
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		cpuLoad = (float)1 - (float)n.getFreeProcessorsNumber() / (float)n.getProcessorsNumber();
+//		log.debug("GetMostLoadedResource node "+n.getName()+": "+cpuLoad+" -- "+memLoad);
+		if (cpuLoad > memLoad) {
+			return cpuLoad;
+		}
+		else {
+			return memLoad;
+		}
+	}
+	@Override
+	public int compare(Node node1, Node node2) {
+		if (getMostLoadedResource(node1) < getMostLoadedResource(node2))
+			return 1;
+		else if (getMostLoadedResource(node1) > getMostLoadedResource(node2))
+			return -1;
+		else 
+			return 0;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/RunExperimentMulticloud.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/RunExperimentMulticloud.java	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/RunExperimentMulticloud.java	(revision 1606)
@@ -0,0 +1,70 @@
+package test.testSOP.algorithms.multicloud;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import simulator.DataCenterWorkloadSimulator;
+import test.testSOP.Utility;
+
+
+
+public class RunExperimentMulticloud {
+	static Log log = LogFactory.getLog(RunExperimentMulticloud.class); 
+	public static void main(String args[]){
+		log.info("EXPERIMENT Multicloud - SOPVP");
+		
+		
+		Utility.deleteFile(SOPVP.MIGRATION_PATH, log);
+		Utility.deleteFile(Utility.HOST_NUMBER_PATH, log);
+		Utility.deleteFile(SOPVP.COMPUTATION_TIME, log);
+		Utility.deleteFile(SOPVP.TASK_REJECTIONS, log);
+		
+//		//Delete migration file
+//		File file = new File(SOPVP.MIGRATION_PATH);
+//		if (file.delete()) {
+//			log.debug("Successfully deleted file "+SOPVP.MIGRATION_PATH);
+//		}
+//		else {
+//			log.debug("Failed to delete file "+SOPVP.MIGRATION_PATH);
+//		}
+//
+//		//Delete expected host number files
+//		file = new File(Utility.HOST_NUMBER_PATH);
+//		if (file.delete()) {
+//			log.debug("Successfully deleted file "+Utility.HOST_NUMBER_PATH);
+//		}
+//		else {
+//			log.debug("Failed to delete file "+Utility.HOST_NUMBER_PATH);
+//		}
+//		//Delete computatin time files
+//		file = new File(SOPVP.COMPUTATION_TIME);
+//		if (file.delete()) {
+//			log.debug("Successfully deleted file "+SOPVP.COMPUTATION_TIME);
+//		}
+//		else {
+//			log.debug("Failed to delete file "+SOPVP.COMPUTATION_TIME);
+//		}
+				
+		String dcworms_args[] = {
+				"src/test/testSOP/algorithms/multicloud/multicloud.properties"
+				};
+		DataCenterWorkloadSimulator.main(dcworms_args);
+		
+		try {
+			String expectedHostNbDest = "src/test/testSOP_results/data/multicloud/expectedHostNumber.txt";
+			Utility.deleteFile(expectedHostNbDest, log);
+			File afile =new File(Utility.HOST_NUMBER_PATH);
+			if(afile.renameTo(new File(expectedHostNbDest))){
+				System.out.println("File is moved successful!");
+			}else{
+				System.out.println("File is failed to move!");
+			}
+			
+	    }catch(Exception e){
+	    	e.printStackTrace();
+	    }
+	}
+}
Index: DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/SOPVP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/SOPVP.java	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/SOPVP.java	(revision 1606)
@@ -0,0 +1,750 @@
+package test.testSOP.algorithms.multicloud;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import qcg.shared.constants.BrokerConstants;
+
+import dcworms.schedframe.scheduling.ExecTask;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.units.Memory;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import simulator.DataCenterWorkloadSimulator;
+import simulator.stats.implementation.DCWormsStatistics;
+import test.testSOP.ComparatorHostHighestLoadFirst;
+import test.testSOP.ComparatorHostLowestLoadFirst;
+import test.testSOP.Utility;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.GridSimTags;
+import gridsim.dcworms.DCWormsTags;
+
+public class SOPVP extends BaseLocalSchedulingPlugin {
+	Log log = LogFactory.getLog(SOPVP.class); 
+	
+	public static String MIGRATION_PATH = "src/test/testSOP_results/data/multicloud/migrations.txt";
+	public static String ON_VS_EXPECTED = "src/test/testSOP_results/data/multicloud/on_vs_expected.txt";
+	public static String COMPUTATION_TIME = "src/test/testSOP_results/data/multicloud/computation_time.txt";
+	public static String TASK_REJECTIONS = "src/test/testSOP_results/data/multicloud/task_rejections.txt";
+
+	
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+//		List<Processor> processors = resourceManager.getProcessors();
+//		List<Node> nodes = resourceManager.getNodes();
+		List<Node> nodes = Utility.getNodesByPowerState(resourceManager.getNodes(), StandardPowerStateName.ON);
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+			// our tasks are placed only in first queue (see BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			// check all tasks in queue
+
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(nodes, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+					else {
+						sendBackTask(task, jobRegistry, q, resourceManager.getNodes().get(0).getFullName().split("/")[0]); 
+					}
+					//FOR TESTING PURPOSE
+//					if (resourceManager.getNodes().get(0).getFullName().contains("ResDataCenter_2")) {
+//						
+//						sendBackTask(task, jobRegistry, q, resourceManager.getNodes().get(0).getFullName().split("/")[0]); 
+//					}
+//					else {
+//						Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(nodes, task);
+//						if (choosenResources != null) {
+//							addToSchedulingPlan(plan, task, choosenResources);
+//						} 
+//					}
+				}
+			}
+			break;
+//		case POWER_LIMIT_EXCEEDED:
+////			String src = event.getSource();
+////			optimizeEnergyUsage(jobRegistry, resourceManager , src);
+//			break;
+			
+		case TIMER:
+			
+			log.debug("Scheduler Invoked by timer");
+			long startTime = System.nanoTime();
+			consolidate(jobRegistry, resourceManager);
+			long endTime = System.nanoTime();
+			long duration = (endTime - startTime) / 1000000;  //divide by 1000000 to get milliseconds.
+			try {
+				PrintWriter writer = new PrintWriter(new FileWriter(COMPUTATION_TIME, true));
+				writer.write(String.format("%d\t%d\n", resourceManager.getNodes().size(), duration));
+				writer.close();
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			
+			Utility.manageHosts(jobRegistry, resourceManager, log);
+		case JOB_ARRIVED:
+			break;
+		case JOB_CANCELED:
+			break;
+		case JOB_FAILED:
+			break;
+		case JOB_FINISHED:
+			break;
+		case PROVIDER_FAILED:
+			break;
+		case RESOURCE_FAILED:
+			break;
+		case RESOURCE_STATE_CHANGED:
+			break;
+		case TASK_ARRIVED:
+			break;
+		case TASK_CANCELED:
+			break;
+		case TASK_FAILED:
+			break;
+		case TASK_MOVED:
+			break;
+		case TASK_PAUSED:
+			break;
+		case TASK_REQUESTED_TIME_EXPIRED:
+			break;
+		case TASK_RESUMED:
+			break;
+		default:
+			break;
+		}
+		
+		return plan;
+	}
+
+
+	
+
+	
+
+
+	
+
+
+	/**
+	 * Consolidate
+	 * @param jobRegistry
+	 * @param resourceManager
+	 */
+	@SuppressWarnings("unchecked")
+	private void consolidate(JobRegistry jobRegistry, ClusterResourceManager resourceManager) {
+		boolean success = true;
+		List<Node> nodeList = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.FREE);
+		Node leastLoadedNode = this.getLeastLoadedHost(nodeList);
+		
+		//all nodes are empty
+		if (leastLoadedNode == null) {
+			log.debug("All nodes are empty");
+			return;
+		}
+		log.debug("Least loaded node is "+leastLoadedNode.getFullName());
+	
+		//Sort host lowest load first
+		Collections.sort(nodeList, new ComparatorHostLowestLoadFirst());
+		
+		//Print the nodelist
+//		this.printNodes(nodeList);
+		
+		ArrayList<Node> hostListMostCPU = new ArrayList<Node>();
+		ArrayList<Node> hostListMostMEM = new ArrayList<Node>();
+		ArrayList<String> migrateVM= new ArrayList<String>(); //VM to migrate
+		ArrayList<String> migrateHost= new ArrayList<String>(); //Host to migrate to
+		
+		//Sort in 2 lists
+		for (Node h : nodeList) {
+			if (h == leastLoadedNode)
+				continue;
+			if (getCPULoad(h, null, null, null) > getMEMLoad(h, null, null, null)){
+				hostListMostCPU.add(h);
+			}
+			else {
+				hostListMostMEM.add(h);
+			}
+		}
+		
+		JobRegistry leastLoadedNodeJR = new JobRegistryImpl(leastLoadedNode.getFullName());
+		List<ExecTask> runningTasks = leastLoadedNodeJR.getRunningTasks();
+		//For each VM
+		for (int i = 0 ;  i<runningTasks.size() && success==true ; i++) {
+			ExecTask t = runningTasks.get(i);
+//			VM vm = getVMFromId(runningTasks.get(i), vmList);
+			boolean found = false;
+//			log.debug("There are "+hostListMostCPU.size()+" hosts with More CPU used than MEM");
+//			log.debug("There are "+hostListMostMEM.size()+" hosts with More MEM used than CPU");
+			//if VM is CPU bound
+			if (this.taskIsCPUBound(t)) {
+//				log.debug("Task "+t.getJobId()+" is CPU bound");
+				//Try MOSTMEMLIST first
+				for (int h = 0 ; h<hostListMostMEM.size() && !found ; h++) {
+					Node otherhost = hostListMostMEM.get(h);
+					if (taskCanFitOnNode(t, otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost) && otherhost != leastLoadedNode && !Utility.nodeIsEmpty(otherhost, log)) {
+//						log.debug("Task "+t.getJobId()+" can fit on host in MOSTMEMLIST "+otherhost.getFullName());
+						//register migration
+						migrateVM.add(t.getJobId());
+						migrateHost.add(otherhost.getFullName());
+						//update usage
+//						otherhost.setCpuUsage(otherhost.getCpuUsage()+vm.getCpuNumber()*100);
+//						otherhost.setMemUsage(otherhost.getMemUsage()+vm.getMem());
+						//If needed change list of h
+						if (getCPULoad(otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost) < getMEMLoad(otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost)) {
+							hostListMostMEM.remove(otherhost);
+							hostListMostCPU.add(otherhost);
+						}
+						found = true;
+					}
+				}
+				//Then try MOSTCPULIST
+				for (int h = 0 ; h<hostListMostCPU.size() && !found ; h++) {
+					Node otherhost = hostListMostCPU.get(h);
+					if (taskCanFitOnNode(t, otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost) && otherhost != leastLoadedNode && !Utility.nodeIsEmpty(otherhost, log)) {
+//						log.debug("Task "+t.getJobId()+" can fit on host in MOSTCPULIST "+otherhost.getFullName());
+						//register migration
+						migrateVM.add(t.getJobId());
+						migrateHost.add(otherhost.getFullName());
+						//update usage
+//						otherhost.setCpuUsage(otherhost.getCpuUsage()+vm.getCpuNumber()*100);
+//						otherhost.setMemUsage(otherhost.getMemUsage()+vm.getMem());
+						//If needed change list of h
+						if (getCPULoad(otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost) < getMEMLoad(otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost)) {
+							hostListMostCPU.remove(otherhost);
+							hostListMostMEM.add(otherhost);
+						}
+						found = true;
+					}
+				}
+			}
+			//If VM is MEM bound
+			else{
+//				log.debug("Task "+t.getJobId()+" is MEM bound");
+				//try MOSTCPULIST first
+				for (int h = 0 ; h<hostListMostCPU.size() && !found ; h++) {
+					Node otherhost = hostListMostCPU.get(h);
+					if (taskCanFitOnNode(t, otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost) && otherhost != leastLoadedNode && !Utility.nodeIsEmpty(otherhost, log)) {
+//						log.debug("VM "+t.getJobId()+" can fit on host in MOSTCPULIST "+otherhost.getFullName());
+						//register migration
+						migrateVM.add(t.getJobId());
+						migrateHost.add(otherhost.getFullName());
+						//update usage
+//						otherhost.setCpuUsage(otherhost.getCpuUsage()+vm.getCpuNumber()*100);
+//						otherhost.setMemUsage(otherhost.getMemUsage()+vm.getMem());
+						//If needed change list of h
+						if (getCPULoad(otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost) < getMEMLoad(otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost)) {
+							hostListMostCPU.remove(otherhost);
+							hostListMostMEM.add(otherhost);
+						}
+						found = true;
+					}
+				}
+				//then MOSTMEMLIST 
+				for (int h = 0 ; h<hostListMostMEM.size() && !found ; h++) {
+					Node otherhost = hostListMostMEM.get(h);
+					if (taskCanFitOnNode(t, otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost) && otherhost != leastLoadedNode && !Utility.nodeIsEmpty(otherhost, log)) {
+//						log.debug("Task "+t.getJobId()+" can fit on host in MOSTMEMLIST "+otherhost.getFullName());
+						//register migration
+						migrateVM.add(t.getJobId());
+						migrateHost.add(otherhost.getFullName());
+						//update usage
+//						otherhost.setCpuUsage(otherhost.getCpuUsage()+vm.getCpuNumber()*100);
+//						otherhost.setMemUsage(otherhost.getMemUsage()+vm.getMem());
+						//If needed change list of h
+						if (getCPULoad(otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost) < getMEMLoad(otherhost, jobRegistry.getRunningTasks(), migrateVM, migrateHost)) {
+							hostListMostMEM.remove(otherhost);
+							hostListMostCPU.add(otherhost);
+						}
+						found = true;
+					}
+				}
+			}
+			if (!found) {
+//				log.debug("Could not find a suitable host for task : "+t.getJobId());
+				success = false;
+			}
+		}
+		//least loaded host is empty -> success = false
+		if (migrateVM.isEmpty()) {
+			success=false;
+		}
+		
+		//if success, enforce realloc
+		if (success) {
+			for (int i = 0 ; i<migrateVM.size() ; i++) {
+//				log.info("-- Migration -- : Task "+migrateVM.get(i)+" goes to node "+migrateHost.get(i));
+			}
+			log.info("Enforcing reallocation");
+			
+			//Write fmigrations into file (might be slow)
+			PrintWriter writer = null;
+			PrintWriter writer2 = null;
+			try {
+//				log.debug(System.getProperty("user.dir"));
+				writer = new PrintWriter(new FileWriter(MIGRATION_PATH, true));
+				writer2 = new PrintWriter(new FileWriter(ON_VS_EXPECTED, true));
+				
+//				log.debug("MigrateVM "+migrateVM.size()+" = "+migrateVM.get(0));
+				for (int i = 0 ; i<migrateVM.size() ; i++) {
+					ExecTask t = jobRegistry.getTask(migrateVM.get(i), "0");
+					
+//					log.debug("TaskID: "+t.getId()+"/"+t.getJobId());
+					//should give the ok for migration 
+					ArrayList<Node> nlist = new ArrayList<Node>();
+					nlist.add((Node) resourceManager.getResourceByName(migrateHost.get(i)));
+					
+					log.debug("Destination host: "+nlist.get(0).getFullName());
+					log.debug("Task : "+t.getJobId());
+					Map<ResourceUnitName, ResourceUnit> destinationResources = chooseResourcesForExecution(nlist , t);
+					jobRegistry.migrateTask(t.getJobId(), t.getId(), destinationResources);
+					writer.println(String.format("%s\t%s", t.getJobId(), nlist.get(0).getName()));
+					int onNodes=-1;
+					for (Node n : resourceManager.getNodes()) {
+						if (n.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)
+								|| n.getPowerInterface().getPowerState().equals(StandardPowerStateName.BOOT))
+							onNodes++;
+					}
+					//SI la migration peut amener une extinction
+					if (Utility.getExpectedHostNumber(jobRegistry, resourceManager, log) < onNodes) 
+						writer2.println("TRUE");
+					else
+						writer2.println("FALSE");
+//					writer2.println(String.format("%d\t%d", Utility.getExpectedHostNumber(jobRegistry, resourceManager, log), onNodes));
+				}
+				writer.close();
+				writer2.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			} finally {
+				writer.close();
+			}
+		}
+	}
+
+//	private void optimizeEnergyUsage(JobRegistry jobRegistry, ClusterResourceManager resourceManager, String resName) {
+//		Node overLoadedNode = (Node)resourceManager .getResourceByName(resName);
+//		Node leastLoadedNode = findLeastLoadedResource(resourceManager.getNodes());
+//		
+//		if(leastLoadedNode.getLoadInterface().getRecentUtilization().getValue() >= overLoadedNode.getLoadInterface().getRecentUtilization().getValue()){
+//			return;
+//		}
+//
+//		JobRegistry srcHostJr = new JobRegistryImpl(overLoadedNode.getFullName());
+//		int runningTasksNumber = srcHostJr.getRunningTasks().size();
+//		for(int i = srcHostJr.getRunningTasks().size() - 1; i >= 0 && runningTasksNumber > 2; i--) {
+//			ExecTask execTask = srcHostJr.getRunningTasks().get(i);
+//			Map<ResourceUnitName, ResourceUnit> destinationResources = chooseResourcesForExecution(findLeastLoadedResource(resourceManager.getNodes()).getProcessors(), execTask);
+//			jobRegistry.migrateTask(execTask.getJobId(), execTask.getId(), destinationResources);
+//			runningTasksNumber--;
+//		}
+//	}
+	
+	
+
+
+
+	
+
+	/**
+	 * Is task CPUbound compared to reference
+	 * @param t
+	 * @return
+	 */
+	private boolean taskIsCPUBound(ExecTask t) {
+		//ATTENTION ICI NB PROC EN DUR
+		try {
+			return ((float) t.getCpuCntRequest() / (float)400) > ((float)t.getMemoryRequest() / (float)16384.0);
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		log.debug("Could not determine if task "+t.getJobId()+" was cpubound");
+		return true;
+	}
+
+	private float getMEMLoad(Node h, List<ExecTask> tasklist, ArrayList<String> migrateVM, ArrayList<String> migrateHost) {
+		try {
+			int additional = 0;
+			if (tasklist != null && migrateVM != null && migrateHost != null) {
+				//Get the migrating toward node h
+				for (int i = 0 ; i < migrateHost.size() ; i++) {
+					if (h.getFullName().equals(migrateHost.get(i))) {
+						for(int j=0 ; j<tasklist.size() ; j++) {
+							if (migrateVM.get(i).equals(tasklist.get(j))) {
+								additional+=tasklist.get(j).getMemoryRequest();
+							}
+						}
+					}
+				}
+			}
+			
+			return 1 - (((float)h.getFreeMemory()-(float)additional) / (float)h.getTotalMemory());
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return 0;
+	}
+
+	private float getCPULoad(Node h, List<ExecTask> tasklist, ArrayList<String> migrateVM, ArrayList<String> migrateHost) {
+		int additional = 0;
+		if (tasklist != null && migrateVM != null && migrateHost != null) {
+			//Get the migrating toward node h
+			for (int i = 0 ; i < migrateHost.size() ; i++) {
+				if (h.getFullName().equals(migrateHost.get(i))) {
+					for(int j=0 ; j<tasklist.size() ; j++) {
+						if (migrateVM.get(i).equals(tasklist.get(j))) {
+							try {
+								additional+=tasklist.get(j).getCpuCntRequest();
+							} catch (NoSuchFieldException e) {
+								// TODO Auto-generated catch block
+								e.printStackTrace();
+							}
+						}
+					}
+				}
+			}
+		}
+		return 1 - (((float) h.getFreeProcessorsNumber()-(float)additional)  / (float)h.getProcessorsNumber());
+	}
+
+	private void printNodes(List<Node> nodeList) {
+		for (Node n : nodeList){
+			try {
+				log.debug(n.getName() + "("+n.getPowerInterface().getPowerState().getLabel()+"): " +
+						"CPU="+n.getFreeProcessorsNumber()+"/"+n.getProcessorsNumber() +"(" + (float)n.getFreeProcessorsNumber() / (float)n.getProcessorsNumber()+ ")" +
+						" / MEM: " +n.getFreeMemory()+"/"+n.getTotalMemory()+ "("+(float)n.getFreeMemory()/(float)n.getTotalMemory()+")");
+			} catch (NoSuchFieldException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * Gets the most loaded resource of the node n
+	 * @param n
+	 * @return
+	 */
+	private float getMostLoadedResource(Node n) {
+		float memLoad = 0, cpuLoad;
+		try {
+			memLoad = (float)1 - (float)n.getFreeMemory() / (float)n.getTotalMemory();
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		cpuLoad = (float)1 - (float)n.getFreeProcessorsNumber() / (float)n.getProcessorsNumber();
+//		log.debug("GetMostLoadedResource node "+n.getName()+": "+cpuLoad+" -- "+memLoad);
+		if (cpuLoad > memLoad) {
+			return cpuLoad;
+		}
+		else {
+			return memLoad;
+		}
+	}
+	
+	/**
+	 * Gets the least loaded host from the list
+	 * Host powered on is not tested
+	 * @param nodeList
+	 * @return
+	 */
+	private Node getLeastLoadedHost(List<Node> nodeList) {
+		Node n = null;
+		float min = 2;
+		for (int i = 0 ; i < nodeList.size() ; i++) {
+			float mostLoadedResource = getMostLoadedResource(nodeList.get(i));
+			if (min >= mostLoadedResource  && mostLoadedResource > 0) {
+				n = nodeList.get(i);
+				min = mostLoadedResource;
+			}
+		}
+		if (n == null) {
+			log.error("Least loaded node is null !");
+			return null;
+		}
+//		logger.debug("Least loaded host is : "+h.getId() +" (CPU="+h.getCpuUsage()+"/MEM="+h.getMemUsage()+")");
+		return n;
+	}
+
+	/**
+	 * Dummy function to test full allocation to 1 proc
+	 * @param processors
+	 * @param task
+	 * @return
+	 */
+	private Map<ResourceUnitName, ResourceUnit> chooseNode1(
+			List<Processor> processors, TaskInterface<?> task) { 
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+		int cpuRequest = 0;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);
+		choosenResources.add(processors.get(0));
+		ProcessingElements pe = new ProcessingElements();
+		pe.addAll(choosenResources);
+		map.put(StandardResourceUnitName.PE, pe);
+		return map;
+	}
+	
+	/**
+	 * 
+	 * @param processors
+	 * @param task
+	 * @return
+	 */
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			List<Node> nodes, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+		
+		List<ComputingResource> chosenResources = new ArrayList<ComputingResource>();	
+		boolean found = false;
+		Memory memory = null;
+		int cpuRequest=0;
+		
+		Collections.sort(nodes, new ComparatorHostHighestLoadFirst());
+		
+		for (int h=0 ; h<nodes.size() && !found ; h++){
+			Node n = nodes.get(h);
+//			log.debug("Task "+task.getId()+"/"+task.getJobId()+" can fit?");
+			if (taskCanFitOnNode(task, n, null, null, null)){
+				try {
+					log.debug("Task "+task.getId()+"/"+task.getJobId()+" (CPU="+task.getCpuCntRequest()+" ; MEM="+task.getMemoryRequest()+") can fit on node "+n.getFullName());
+				} catch (NoSuchFieldException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				found=true;
+				
+				try {
+					cpuRequest = (int)task.getCpuCntRequest();
+					memory = new Memory(n.getMemory(), (int)task.getMemoryRequest(), (int)task.getMemoryRequest());
+				} catch (NoSuchFieldException e1) {
+					e1.printStackTrace();
+				}
+				//Adding chosen processors
+				for (int i = 0; i < n.getProcessors().size() && cpuRequest > 0; i++) {
+					if (n.getProcessors().get(i).getStatus() == ResourceStatus.FREE) {
+						chosenResources.add(n.getProcessors().get(i));
+						cpuRequest--;
+					}
+				}
+				if (cpuRequest > 0) {
+					continue;
+				}
+			}
+		}
+		if (!found) {
+			log.info("Allocation not found for task "+task.getJobId());
+			return null;
+		}
+		
+		ProcessingElements pe = new ProcessingElements();
+		pe.addAll(chosenResources);
+		map.put(StandardResourceUnitName.PE, pe);
+		if (memory != null)
+			map.put(StandardResourceUnitName.MEMORY, memory);
+		else 
+			return null;
+		return map;
+	}
+	
+//	/**
+//	 * FCFS CPU
+//	 * @param processors
+//	 * @param task
+//	 * @return
+//	 */
+//	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+//			List<Processor> processors, TaskInterface<?> task) {
+//
+//		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+//
+//		int cpuRequest;
+//		try {
+//			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+//		} catch (NoSuchFieldException e) {
+//			cpuRequest = 0;
+//		}
+//
+//		if (cpuRequest != 0) {
+//
+//			if (processors.size() < cpuRequest) {
+//				return null;
+//			}
+//
+//			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+//			for (int i = 0; i < processors.size() && cpuRequest > 0; i++) {
+//				if (processors.get(i).getStatus() == ResourceStatus.FREE) {
+//					choosenResources.add(processors.get(i));
+//					cpuRequest--;
+//				}
+//			}
+//			if (cpuRequest > 0) {
+//				return null;
+//			}
+//
+//			ProcessingElements pe = new ProcessingElements();
+//			pe.addAll(choosenResources);
+//			map.put(StandardResourceUnitName.PE, pe);
+//			return map;
+//		}
+//
+//		return null;
+//	}
+
+	/**
+	 * Checks whether a task can fit on a node
+	 * @param task
+	 * @param n
+	 * @param migrateVM 
+	 * @param runningTasks 
+	 * @param migrateHost 
+	 * @return
+	 */
+	private boolean taskCanFitOnNode(TaskInterface<?> task, Node n, List<ExecTask> runningTasks, ArrayList<String> migrateVM, ArrayList<String> migrateHost) {
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			log.warn("Task : "+task.getId()+" does not require CPU !");
+			cpuRequest = 0;
+		}
+		
+		int memRequest;
+		try {
+			memRequest = (int) task.getMemoryRequest();
+		} catch (NoSuchFieldException e) {
+			log.warn("Task : "+task.getJobId()+" does not require MEMORY !");
+			memRequest = 0;
+		}
+//		log.debug("Task "+task.getId()+" => CPU="+cpuRequest+"/MEM="+memRequest);
+
+		if (cpuRequest == 0 && memRequest == 0){
+			log.error("Error: task is empty !");
+			return false;
+		}
+		
+		try {
+			
+			//To for expected migrations
+			int additionalProc = 0;
+			int additionalMem = 0;
+			if (runningTasks != null && migrateVM != null && migrateHost != null) {
+				//check node is destination
+				for (int i = 0 ; i < migrateHost.size() ; i++) {
+					String nodeName = migrateHost.get(i);
+					if (n.getFullName().equals(nodeName)) {
+						String migrateTaskId = migrateVM.get(i);
+						//get corresponding task
+						for (int j = 0 ; j<runningTasks.size() ; j++) {
+							if (runningTasks.get(j).getJobId().equals(migrateTaskId)) {
+								additionalProc+=runningTasks.get(j).getCpuCntRequest();
+								additionalMem+=runningTasks.get(j).getMemoryRequest();
+							}
+						}
+					}
+				}
+				
+			}
+			//For each processor check whether it can fit
+			if (n.getFreeMemory() >= memRequest+additionalMem && n.getFreeProcessorsNumber() >= cpuRequest+additionalProc) {
+				return true;
+			}
+			
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return false;
+	}
+
+	private Node findLeastLoadedResource(List<Node> nodes ){
+		Node leastLoadedNode = null;
+		double minLoad = Double.MAX_VALUE;
+		
+		for(int i = 0; i < nodes.size(); i++){
+			Node node = nodes.get(i);
+			double totalLoad = node.getLoadInterface().getRecentUtilization().getValue();
+			if(totalLoad < minLoad){
+				leastLoadedNode= node;
+				minLoad = totalLoad;
+			}
+		}
+		return leastLoadedNode;
+	}
+
+	private void sendBackTask(TaskInterface<?> task, JobRegistry jobRegistry, TaskQueue q, String clusterName) {
+		try {
+			PrintWriter writer = new PrintWriter(new FileWriter(TASK_REJECTIONS, true));
+			//Task id / Cluster name 
+			writer.write(String.format("%s\t%s\n", task.getJobId(), clusterName));
+			writer.close();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		log.debug("Task: "+task.getJobId() + " sent back to GridBroker");
+		try {
+			//Unsubmit task
+			jobRegistry.getJobInfo(task.getJobId()).getTask(task.getId()).setStatus((int)BrokerConstants.TASK_STATUS_UNSUBMITTED);
+
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		q.remove(task);
+		synchronized(jobRegistry) {
+			jobRegistry.getTasks().remove(task);
+		}
+		DataCenterWorkloadSimulator.getEventManager().send("grid", 0, GridSimTags.GRIDLET_SUBMIT, jobRegistry.getJobInfo(task.getJobId()));
+		
+	}
+}
Index: DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/DCWORMS_resourcesMulticloud.xml
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/DCWORMS_resourcesMulticloud.xml	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/DCWORMS_resourcesMulticloud.xml	(revision 1606)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<environment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:noNamespaceSchemaLocation="../DCwormsResSchema.xsd">
+   <resources mode="CoolEmAll">
+      <scheduler/>
+   </resources>
+</environment>
Index: DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/resourcesMulticloud.xml
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/resourcesMulticloud.xml	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/resourcesMulticloud.xml	(revision 1606)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<environment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+	xsi:noNamespaceSchemaLocation="../../simulator/schemas/resources/DCwormsResSchema.xsd">
+	<timeEstimationPlugin>
+		<name>test.testSOP.BaseTimeEstimationPlugin</name>
+	</timeEstimationPlugin>
+	<resources>
+		<computingResource class="DataCenter" name="ResDataCenter" count="2">
+		    <!-- Node Description -->
+			<computingResource class="Node" count="50">
+				<resourceUnit class="memory">
+					<amount>16384</amount>
+				</resourceUnit>
+				<!-- Power Profile Description -->
+				<profile>
+					<powerProfile>
+						<energyEstimationPlugin>
+							<name>test.testSOP.NodeEnergyEstimationPlugin</name>
+						</energyEstimationPlugin>
+						<powerStates>
+							<powerState>
+								<name>ON</name>
+								<powerUsage>70</powerUsage>
+								<transition name="POWEROFF">
+									<to>OFF</to>
+									<powerUsage>101</powerUsage>
+									<time>15</time>
+								</transition> 
+							</powerState>
+							<powerState>
+								<name>OFF</name>
+								<powerUsage>0</powerUsage>
+								<transition name="BOOT">
+									<to>ON</to>
+									<powerUsage>122</powerUsage>
+									<time>30</time>
+								</transition> 
+							</powerState>
+							<!-- To compute energy consumption -->
+							<powerState>
+								<name>P_MAX</name>
+								<powerUsage>140</powerUsage>
+							</powerState>
+							<powerState>
+								<name>P_MIN</name>
+								<powerUsage>70</powerUsage>
+							</powerState>
+							
+						</powerStates>		
+					</powerProfile>
+				</profile>
+				<!-- Processor Description -->
+				<computingResource class="Processor" count="800">
+					<profile>
+						<powerProfile />
+					</profile>
+					<!--<computingResource class="Core" count="4"/> -->
+				</computingResource>
+			</computingResource>
+		</computingResource>
+	    <scheduler class="GridBroker" name="metasched">
+			<schedulingPlugin>
+				<name>test.testSOP.algorithms.multicloud.MetaSched</name>
+				<!-- <frequency>20</frequency> -->
+			</schedulingPlugin>	
+			<scheduler class="Cluster" name="cluster1">
+				<schedulingPlugin>
+					<name>test.testSOP.algorithms.multicloud.SOPVP</name>
+					<frequency>30</frequency>
+				</schedulingPlugin>	
+				<managedComputingResources include="false">
+					<resourceName>ResDataCenter_1</resourceName>
+				</managedComputingResources>
+			</scheduler>
+			<scheduler class="Cluster" name="cluster2">
+				<schedulingPlugin>
+					<name>test.testSOP.algorithms.multicloud.SOPVP</name>
+					<frequency>30</frequency>
+				</schedulingPlugin>	
+				<managedComputingResources include="false">
+					<resourceName>ResDataCenter_2</resourceName>
+				</managedComputingResources>
+			</scheduler> 
+		</scheduler>
+		
+	</resources>
+</environment>
Index: DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/multicloud.properties
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/multicloud.properties	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/multicloud.properties	(revision 1606)
@@ -0,0 +1,31 @@
+# Use single *.swf file as workload description.
+
+numberofsimulations=1
+
+# Path to xml file which describes resource characteristics.
+resdesc=src/test/testSOP/algorithms/multicloud/resourcesMulticloud.xml
+
+# and swf file, which name is declared by readscenario.workloadfilename parameter.
+# Swf file must be placed in readscenario.inputfolder directory.  
+#readscenario.workloadfilename=src/test/testSOP/workloads/generated/workloadGen.swf
+readscenario.workloadfilename=src/test/testSOP/test.swf
+#readscenario.workloadfilename=src/test/testSOP/algorithms/multicloud/test.swf
+
+# Choose directory where all result files should be placed.
+stats.outputfolder=src/test/testSOP_results/data/multicloud
+
+# Define the type and content of charts to generate
+
+# Gantt chart
+#creatediagrams.gantt=true
+
+# Shows the execution times of tasks
+#creatediagrams.tasks=true
+
+# Shows the waiting times of tasks
+#creatediagrams.taskswaitingtime=true
+
+# Resource utilization chart - only for processors
+creatediagrams.resutilization=Node
+
+creatediagrams.respowerusage=Node
Index: DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/MetaSched.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/MetaSched.java	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/MetaSched.java	(revision 1606)
@@ -0,0 +1,274 @@
+package test.testSOP.algorithms.multicloud;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.scheduling.Scheduler;
+import schedframe.scheduling.SchedulerDescription;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ManagedComputingResources;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.Allocation;
+import schedframe.scheduling.plan.impl.ScheduledTask;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.Module;
+import schedframe.scheduling.plugin.ModuleList;
+import schedframe.scheduling.plugin.grid.ResourceDiscovery;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import schedframe.scheduling.tasks.WorkloadUnit;
+import example.globalplugin.BaseGlobalPlugin;
+
+
+public class MetaSched  extends BaseGlobalPlugin {
+	Log log = LogFactory.getLog(MetaSched.class); 
+	private LinkedList<String> lastUsedResources = new LinkedList<String>();
+	
+	private static ArrayList<String> cacheTaskId = new ArrayList<String>();
+	private static ArrayList<String> cacheChosenCluster = new ArrayList<String>();
+	private static ArrayList<Integer> cacheNbTries = new ArrayList<Integer>();
+	
+	private static int MAX_TRIES = 3;
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event,
+			TaskQueueList queues, 
+			JobRegistry jobRegistry,
+			ResourceManager resourceManager, ModuleList modules)  {
+	
+		
+		ResourceDiscovery resources = null;
+		for(int i = 0; i < modules.size(); i++){
+			Module m = modules.get(i);
+			switch(m.getType()){
+				case RESOURCE_DISCOVERY: resources = (ResourceDiscovery) m;
+					break;
+			}
+		}
+		
+//		switch(event.getType()) {
+//			case TIMER:
+//				log.debug("Metasched called by timer");
+//				incrementNbTriesCache();
+//				removeOldCacheEntries();
+//				break;
+//			default:
+//				log.debug("Defau");
+//				break;
+//		}
+		SchedulingPlan plan = new SchedulingPlan();
+		
+		TaskQueue q = queues.get(0);
+//		log.debug("Queues size:"+queues.size());
+		int size = q.size();
+		
+		// order of the resources on this list is not determined
+		List<SchedulerDescription> availableResources = resources.getResources();
+		
+//		log.debug("Available resource: "+availableResources.size());
+//		log.debug(availableResources.get(0).getId());
+//		log.debug(resourceManager.getSchedulers().get(0).getFullName());
+//		log.debug(resourceManager.getSchedulers().get(0).getCompResources().get(0).getLoadInterface().getRecentUtilization().getValue());
+//		log.debug(resourceManager.getSchedulers().get(0).getCompResources().get(0).getFullName());
+//		log.debug(availableResources.get(0).getProvider().getPropertyKeys());
+//		getY(resourceManager.getSchedulers().get(0).getCompResources());
+		
+//		log.debug("0 : "+availableResources.get(0).getProvider().getProviderId());
+//		log.debug("1 : "+availableResources.get(1).getProvider().getProviderId());
+		
+		
+		//For each task in the queue
+		for(int i = 0; i < size; i++) {
+			WorkloadUnit job = q.remove(0);
+			TaskInterface<?> task = (TaskInterface<?>)job;
+			Scheduler sched = chooseCloud(resourceManager.getSchedulers(), task);
+			incrementNbTriesCache();
+			removeOldCacheEntries();
+			//Skip task if we dont have a cloud available
+			if (sched == null)
+				continue;
+			cacheTaskId.add(task.getJobId());
+			cacheChosenCluster.add(sched.getFullName());
+			cacheNbTries.add(1);
+//			log.debug("Choosen cloud : "+sched.getFullName());
+			//Round robin
+			SchedulerDescription sd = availableResources.get(availableResources.size() - 1);
+			for(SchedulerDescription schedDesc: availableResources){
+				if(!lastUsedResources.contains(schedDesc.getProvider().getProviderId())){
+					if(lastUsedResources.size() + 1 >= availableResources.size()){
+						lastUsedResources.poll();
+					}
+					lastUsedResources.add(schedDesc.getProvider().getProviderId());
+					sd = schedDesc;
+					break;
+				}
+			}
+			
+			Allocation allocation = new Allocation();
+			allocation.setProcessesCount(1);
+			allocation.setProviderName(sd.getProvider().getProviderId());
+			ScheduledTask scheduledTask = new ScheduledTask(task);
+			scheduledTask.setTaskId(task.getId());
+			scheduledTask.setJobId(task.getJobId());
+			scheduledTask.addAllocation(allocation);		
+			
+			plan.addTask(scheduledTask);
+			
+			//Metasched
+//			Allocation allocation = new Allocation();
+//			allocation.setProcessesCount(1);
+//			allocation.setProviderName(sched.get_name());
+//			ScheduledTask scheduledTask = new ScheduledTask(task);
+//			scheduledTask.setTaskId(task.getId());
+//			scheduledTask.setJobId(task.getJobId());
+//			scheduledTask.addAllocation(allocation);		
+//			
+//			plan.addTask(scheduledTask);
+		}
+		return plan;
+	}
+
+	private void incrementNbTriesCache() {
+		for (int i = 0 ; i < cacheNbTries.size(); i++) {
+			cacheNbTries.set(i, cacheNbTries.get(i)+1);
+		}
+	}
+	
+	private void removeOldCacheEntries() {
+		for (int i = 0 ; i < cacheNbTries.size(); i++) {
+			if (cacheNbTries.get(i) > MAX_TRIES) {
+				log.debug("Cache entry :"+cacheTaskId.get(i)+"/"+cacheChosenCluster.get(i)+"/"+cacheNbTries.get(i)+" is too old");
+				cacheNbTries.remove(i);
+				cacheTaskId.remove(i);
+				cacheChosenCluster.remove(i);
+			}
+		}
+	}
+
+	// return std::max((float)c.cpu_number_hosts_le_50p/(float)c.host_number, (float)c.mem_number_hosts_le_50p/(float)c.host_number);
+	private float getX(ManagedComputingResources compRes) {	
+		float hostNumber = compRes.size();
+//		log.debug("Host number: "+hostNumber);
+		float cpu_number_hosts_le_50p=0;
+		float mem_number_hosts_le_50p=0;
+		
+		for (ComputingResource cr : compRes) {
+			Node node = (Node)cr;
+//			log.debug(node.getFullName());
+//			log.debug("Free Processors = "+node.getFreeProcessorsNumber()+"/"+node.getProcessorsNumber());
+//			log.debug(((Processor)node.getChildren().get(0)).);
+			if ((float)node.getFreeProcessorsNumber() >= 0.5 * (float)node.getProcessorsNumber()) {
+				cpu_number_hosts_le_50p++;
+			}
+			try {
+				if ((float)node.getFreeMemory() >= 0.5 *(float)node.getTotalMemory()) {
+					mem_number_hosts_le_50p++;
+				}
+			} catch (NoSuchFieldException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		float ret = Math.max(cpu_number_hosts_le_50p/hostNumber,mem_number_hosts_le_50p/hostNumber);
+//		log.debug("X=max("+cpu_number_hosts_le_50p+"/"+hostNumber+","+mem_number_hosts_le_50p+"/"+hostNumber+")="+ret);
+		return ret;
+	}
+	
+	//return (float)(c.highest_mean_resource_le_50_p / 100.0);
+	private float getY(ManagedComputingResources compRes) {
+		float mean_cpu_le_50p = 0;
+		float nbCPU=0;
+		float mean_mem_le_50p = 0;
+		float nbMEM=0;
+		for (ComputingResource cr : compRes) {
+			Node node = (Node)cr;
+			//node is loaded < 50%
+			if ((float)node.getFreeProcessorsNumber() >= 0.5 * (float)node.getProcessorsNumber()) {
+				mean_cpu_le_50p+=((float)node.getProcessorsNumber()-(float)node.getFreeProcessorsNumber())/(float)node.getProcessorsNumber();
+				nbCPU++;
+//				log.debug("CPU Inf 50p");
+//				log.debug("(float)node.getProcessorsNumber() = "+(float)node.getProcessorsNumber());
+//				log.debug("(float)node.getFreeProcessorsNumber() = "+(float)node.getFreeProcessorsNumber());
+			}
+			try {
+				if ((float)node.getFreeMemory() >= 0.5 *(float)node.getTotalMemory()) {
+					mean_mem_le_50p+=((float)node.getTotalMemory() - (float)node.getFreeMemory()) / (float)node.getTotalMemory();
+					nbMEM++;
+//					log.debug(((float)node.getTotalMemory() - (float)node.getFreeMemory()));
+//					log.debug((float)node.getFreeMemory());
+//					log.debug("mem Inf 50p");
+				}
+			} catch (NoSuchFieldException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		if (nbCPU != 0) {
+//			log.debug("cpu: "+mean_cpu_le_50p+"/"+nbCPU);
+			mean_cpu_le_50p = mean_cpu_le_50p / nbCPU;				
+		}
+		else {
+			mean_cpu_le_50p = (float) 0.5;
+		}
+		if (nbMEM != 0) {
+//			log.debug("mem: "+mean_mem_le_50p+"/"+nbMEM);
+			mean_mem_le_50p = mean_mem_le_50p / nbMEM;
+		}
+		else {
+			mean_mem_le_50p = (float) 0.5;
+		}
+//		log.debug("Y = max("+mean_cpu_le_50p+","+mean_mem_le_50p+")");
+		return Math.max(mean_cpu_le_50p, mean_mem_le_50p);
+	}
+	
+	private Scheduler chooseCloud(List<Scheduler> schedulers, TaskInterface<?> task) {
+		Scheduler chosenCloud = null;
+		float value = Float.NEGATIVE_INFINITY;
+		Collections.sort(schedulers, new ComparatorRankingMetasched());
+		for (int i = 0 ; i < schedulers.size() ; i++) {
+			//If scheduler has already been chosen, continue
+			if (cloudAlreadyChosen(schedulers.get(i), task)) {
+				log.debug("Task "+task.getJobId()+" already chose cloud "+schedulers.get(i).getFullName());
+				continue;
+			}
+				
+//			log.debug("Cloud : "+schedulers.get(i).get_name());
+			float x = getX(schedulers.get(i).getCompResources());
+			float y = getY(schedulers.get(i).getCompResources());
+			float z = i;
+			float newValue = x * ((float)schedulers.get(i).getCompResources().size() / 2)
+						- y * (float)schedulers.get(i).getCompResources().size()
+						- z;
+			if (newValue > value) {
+				chosenCloud = schedulers.get(i);
+				value = newValue;
+			}
+		}
+		if (chosenCloud == null) {
+			log.debug("No cloud was found !");
+		}
+		return chosenCloud;
+	}
+
+
+	private boolean cloudAlreadyChosen(Scheduler sched, TaskInterface<?> task) {
+		for (int i = 0 ; i < cacheTaskId.size() ; i++) {
+			if (task.getJobId().equals(cacheTaskId.get(i)) && sched.getFullName().equals(cacheChosenCluster.get(i))) {
+				return true;
+			}
+		}
+		return false;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/test.swf
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/test.swf	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/test.swf	(revision 1606)
@@ -0,0 +1,27 @@
+; Example job:
+; {'status': 1, 'requested_processors': 291, 'preceding_job': -1, 'user_id': -1, 'app_number': -1, 'queue_number': -1, 'used_memory': -1, 'requested_memory': 1959, 'partition_number': -1, 'wait_time': -1, 'allocated_processors': 291, 'requested_time': 770, 'think_time_from_preceding_job': -1, 'run_time': 770, 'submit_time': 0, 'avg_cpu_time_used': -1, 'group_id': -1, 'job_number': 1}
+;Automatically generated workload description by the Data Center Workload and Resource Management Simulator
+;		j|		s|		w|		r|		c|		c|		m|		p|		t|		m|		s|		u|		g|		e|		q|		p|		p|		t|
+;		o|		u|		a|		u|		p|		p|		e|		r|		i|		e|		t|		i|		i|		x|		u|		a|		r|		h|
+;		b|		b|		i|		n|		u|		u|		m|		o|		m|		m|		a|		d|		d|		e|		e|		r|		e|		i|
+;		 |		m|		t|		t|		 |		 |		 |		c|		e|		 |		t|		 |		 |		c|		u|		t|		c|		n|
+;		 |		i|		 |		i|		a|		t|		u|		 |		 |		r|		u|		 |		 |		u|		e|		i|		 |		k|
+;		 |		t|		 |		m|		l|		i|		s|		r|		r|		e|		s|		 |		 |		t|		 |		t|		j|		 |
+;		 |		 |		 |		e|		l|		m|		e|		e|		e|		q|		 |		 |		 |		a|		n|		i|		o|		t|
+;		 |		 |		 |		 |		o|		e|		d|		q|		q|		 |		 |		 |		 |		b|		r|		o|		b|		i|
+;		 |		 |		 |		 |		c|		 |		 |		 |		 |		 |		 |		 |		 |		l|		 |		n|		 |		m|
+;		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		e|		 |		 |		 |		e|
+;StartTime: Thu Jan 15 10:00:00 CET 2009
+1	0	-1	500	1	-1	-1	1	500	2048	1	-1	-1	-1	-1	-1	-1	-1	
+2	10	-1	500	1	-1	-1	1	500	2048	1	-1	-1	-1	-1	-1	-1	-1	
+3	10	-1	500	1	-1	-1	1	500	2048	1	-1	-1	-1	-1	-1	-1	-1	
+4	10	-1	500	1	-1	-1	1	500	2048	1	-1	-1	-1	-1	-1	-1	-1	
+5	10	-1	500	1	-1	-1	1	500	2048	1	-1	-1	-1	-1	-1	-1	-1	
+6	10	-1	500	1	-1	-1	1	500	2048	1	-1	-1	-1	-1	-1	-1	-1	
+7	10	-1	500	1	-1	-1	1	500	2048	1	-1	-1	-1	-1	-1	-1	-1	
+
+;IDMapping: swfID:jobID:taskID
+; 
+;0:0:0,
+; 
+;IDMapping: end
Index: DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/ComparatorRankingMetasched.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/ComparatorRankingMetasched.java	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/algorithms/multicloud/ComparatorRankingMetasched.java	(revision 1606)
@@ -0,0 +1,92 @@
+package test.testSOP.algorithms.multicloud;
+
+import java.util.Comparator;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.scheduling.Scheduler;
+import schedframe.scheduling.manager.resources.ManagedComputingResources;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import test.testSOP.Utility;
+
+//Copie de lowest load first
+public class ComparatorRankingMetasched implements Comparator<Scheduler>{
+	@Override
+	public int compare(Scheduler sched1, Scheduler sched2) {
+		ManagedComputingResources c1 = sched1.getCompResources();
+		ManagedComputingResources c2 = sched2.getCompResources();
+		float mean_load_cpu_c1 = 0;
+		float mean_load_mem_c1 = 0;
+		float vm_number_c1 = 0;
+		float nb=0;
+		for (ComputingResource cr : c1) {
+			Node node = (Node)cr;
+			mean_load_cpu_c1 += node.getLoadInterface().getRecentUtilization().getValue();
+			try {
+				mean_load_mem_c1 += ((float)node.getTotalMemory() - (float)node.getFreeMemory()) / (float)node.getTotalMemory();
+			} catch (NoSuchFieldException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			
+			JobRegistry nodeJR = new JobRegistryImpl(node.getFullName());
+			synchronized(nodeJR) {
+				vm_number_c1 += Utility.getAllRunningTasks(nodeJR);
+			}
+			nb++;
+		}
+		mean_load_cpu_c1 = mean_load_cpu_c1 / nb;
+		mean_load_mem_c1 = mean_load_mem_c1 / nb;
+		
+		float mean_load_cpu_c2 = 0;
+		float mean_load_mem_c2 = 0;
+		float vm_number_c2 = 0;
+		nb=0;
+		for (ComputingResource cr : c1) {
+			Node node = (Node)cr;
+			mean_load_cpu_c2 += node.getLoadInterface().getRecentUtilization().getValue();
+			try {
+				mean_load_mem_c2 += ((float)node.getTotalMemory() - (float)node.getFreeMemory()) / (float)node.getTotalMemory();
+			} catch (NoSuchFieldException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			JobRegistry nodeJR = new JobRegistryImpl(node.getFullName());
+			synchronized(nodeJR) {
+				vm_number_c2 += Utility.getAllRunningTasks(nodeJR);
+			}
+			nb++;
+		}
+		mean_load_cpu_c2 = mean_load_cpu_c2 / nb;
+		mean_load_mem_c2 = mean_load_mem_c2 / nb;
+		
+		float z1, z2;
+		if (vm_number_c1 == 0) {
+			z1 = 1;
+		}
+		else {
+			z1 = Math.max(mean_load_cpu_c1 / vm_number_c1, mean_load_mem_c1 / vm_number_c1);
+		}
+		if (vm_number_c2 == 0) {
+			z2 = 1;
+		}
+		else {
+			z2 = Math.max(mean_load_cpu_c2 / vm_number_c2, mean_load_mem_c2 / vm_number_c2);
+		}
+		
+		if (z1 > z2)
+			return 1;
+		else if (z1 > z2)
+			return -1;
+		else 
+			return 0;
+	}
+}
+//static bool ranking_clouds(metasched_cloud_t c1, metasched_cloud_t c2) {
+//float z1 = std::max((float)c1.load_cpu / (float)c1.vm_number
+//                  , (float)c1.load_memory/(float)c1.vm_number);
+//float z2 = std::max((float)c2.load_cpu / (float)c2.vm_number
+//                  , (float)c2.load_memory/(float)c2.vm_number);
+//return (z1 <= z2);
+//}
Index: DCWoRMS/branches/coolemall/src/test/testSOP/ComparatorHostLowestLoadFirst.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/ComparatorHostLowestLoadFirst.java	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/ComparatorHostLowestLoadFirst.java	(revision 1606)
@@ -0,0 +1,34 @@
+package test.testSOP;
+
+import java.util.Comparator;
+
+import schedframe.resources.computing.Node;
+
+public class ComparatorHostLowestLoadFirst implements Comparator<Node>{
+	private float getMostLoadedResource(Node n) {
+		float memLoad = 0, cpuLoad;
+		try {
+			memLoad = (float)1 - (float)n.getFreeMemory() / (float)n.getTotalMemory();
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		cpuLoad = (float)1 - (float)n.getFreeProcessorsNumber() / (float)n.getProcessorsNumber();
+//		log.debug("GetMostLoadedResource node "+n.getName()+": "+cpuLoad+" -- "+memLoad);
+		if (cpuLoad > memLoad) {
+			return cpuLoad;
+		}
+		else {
+			return memLoad;
+		}
+	}
+	@Override
+	public int compare(Node node1, Node node2) {
+		if (getMostLoadedResource(node1) > getMostLoadedResource(node2))
+			return 1;
+		else if (getMostLoadedResource(node1) < getMostLoadedResource(node2))
+			return -1;
+		else 
+			return 0;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/test/testSOP/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/NodeEnergyEstimationPlugin.java	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/NodeEnergyEstimationPlugin.java	(revision 1606)
@@ -0,0 +1,165 @@
+package test.testSOP;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.commons.logging.LogFactory;
+
+import schedframe.events.EventReason;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.power.PowerState;
+import schedframe.resources.computing.profiles.energy.power.CustomPowerStateName;
+import schedframe.resources.computing.profiles.energy.power.PowerStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+//	private static int POWER_CAP_LEVEL = 150;
+	org.apache.commons.logging.Log log = LogFactory.getLog(NodeEnergyEstimationPlugin.class); 
+	
+//	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+//			PhysicalResource resource) {
+//		
+//		if (event.getReason() == EventReason.SIM_INIT) {
+//			String state = "CUSTOM_ON";
+//			log.debug("Initialization of all the nodes power state to "+state);
+//			resource.getPowerInterface().setPowerState(new CustomPowerStateName(state));
+//		}
+//		double powerConsumption = 0;
+//		Node node = (Node) resource;
+//		if(node.getPowerInterface().getPowerState().getLabel().equals(new CustomPowerStateName("CUSTOM_ON").getLabel())){
+//			powerConsumption = getPowerConsumption(node);
+//		} 
+////		if(powerConsumption > POWER_CAP_LEVEL ){
+////			DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.POWER_LIMIT_EXCEEDED, node.getFullName());
+////		}
+//		return powerConsumption;
+//	}
+	
+	public double getPowerConsumption(Node node){
+		double powerConsumption = 0;
+		double loadLevel = node.getLoadInterface().getRecentUtilization().getValue();
+		double p_max = -1;
+		double p_min = -1;
+
+		//Find power Consumption of 100% and 0% load states
+		for (PowerState p : node.getPowerInterface().getSupportedPowerStates()) {
+			if (p.getName().getLabel().equals(new CustomPowerStateName("P_MAX").getLabel())) {
+				p_max = p.getPowerUsage();
+			}
+			if (p.getName().getLabel().equals(new CustomPowerStateName("P_MIN").getLabel())) {
+				p_min = p.getPowerUsage();
+			}
+		}
+		if (p_max == -1 || p_min == -1) {
+			log.error("ERROR: Load_100 or load_0 not found in powerstate list of node "+node.getFullName());
+		}
+		else {
+			powerConsumption = p_min + (p_max-p_min)*(loadLevel/100);
+//			log.debug("Power Consumption of node "+node.getName()+" at "+loadLevel+"% is "+powerConsumption);
+		}
+//		log.debug("powerConsumption : "+powerConsumption);
+		return powerConsumption;
+	}
+
+	@Override
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		//Cleanup !
+		if (event.getReason() == EventReason.SIM_INIT) {
+			//Do at initialisation of simulation
+		}
+//		//TesT
+//		if (event.getReason() == EventReason.SIM_INIT && resource.getName().equals("Node_1")) {
+//			PowerStateName state = StandardPowerStateName.OFF;
+//			log.debug("Initialization of Node_1 power state to "+state);
+//			resource.getPowerInterface().setPowerState(state);
+//		}
+		double powerConsumption = 0;
+		Node node = (Node) resource;
+		if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)){
+			powerConsumption = getPowerConsumption(node);
+		} 
+		else {
+			try {
+				powerConsumption = node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
+			} catch (NoSuchFieldException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+//		if(powerConsumption > POWER_CAP_LEVEL ){
+//			DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.POWER_LIMIT_EXCEEDED, node.getFullName());
+//		}
+		return powerConsumption;
+	}
+	
+//	public double getPowerConsumption(Node node){
+//		double powerConsumption = 0;
+//		double loadLevel = node.getLoadInterface().getRecentUtilization().getValue();
+//		double lowestLoadLevel = 100;
+//		double highestLoadLevel = 0;
+//		try{
+//			if(node.getPowerInterface().supportPowerState(new CustomPowerStateName("ON_" + new Double(loadLevel).intValue()))){
+//				powerConsumption = node.getPowerInterface().getPowerConsumption(new CustomPowerStateName("ON_" + new Double(loadLevel).intValue()));
+//			} else {
+//				for(PowerState powerState: node.getPowerInterface().getSupportedPowerStates()){
+//					Double load;
+//					try{
+//						load = Double.valueOf(powerState.getName().getLabel().substring(3));
+//					}catch (Exception e){
+//						continue;
+//					}
+//					if(lowestLoadLevel > load){
+//						lowestLoadLevel = load;
+//					}
+//					if(highestLoadLevel < load){
+//						highestLoadLevel = load;
+//					}
+//				}
+//				if(loadLevel == 0){
+//					powerConsumption = node.getPowerInterface().getPowerConsumption(new CustomPowerStateName("ON_0"));
+//				} else {
+//					
+//					double lowerLoadLevel = lowestLoadLevel;
+//					double higherLoadLevel = highestLoadLevel;
+//
+//					for(PowerState powerState: node.getPowerInterface().getSupportedPowerStates()){
+//						Double load = Double.valueOf(powerState.getName().getLabel().substring(3));
+//						if(loadLevel > load){
+//							lowerLoadLevel = load;
+//						}
+//						else if(loadLevel < load){
+//							higherLoadLevel = load;
+//							break;
+//						}
+//					}
+//					double powerBelow;
+//					double powerAbove;
+//					double a;
+//					double b;
+//					if(lowerLoadLevel != higherLoadLevel) {
+//						powerBelow = node.getPowerInterface().getPowerConsumption(new CustomPowerStateName("ON_" + new Double(lowerLoadLevel).intValue()));
+//						powerAbove = node.getPowerInterface().getPowerConsumption(new CustomPowerStateName("ON_" + new Double(higherLoadLevel).intValue()));
+//						a = (powerAbove - powerBelow)/(higherLoadLevel - lowerLoadLevel);
+//						b = powerAbove - a * higherLoadLevel;
+//					} else {
+//						powerBelow = node.getPowerInterface().getPowerConsumption(new CustomPowerStateName("ON_" + new Double(lowestLoadLevel).intValue()));
+//						powerAbove = node.getPowerInterface().getPowerConsumption(new CustomPowerStateName("ON_" + new Double(highestLoadLevel).intValue()));
+//						a = (powerAbove - powerBelow)/(highestLoadLevel - lowestLoadLevel);
+//						b = powerAbove - a * highestLoadLevel;
+//					}
+//					powerConsumption = a * loadLevel + b;
+//				}
+//			}
+//		} catch (Exception e){
+//			
+//		}
+//	
+//		return powerConsumption;
+//	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/testSOP/test.swf
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/test.swf	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/test.swf	(revision 1606)
@@ -0,0 +1,196 @@
+; Example job:
+; {'status': 1, 'requested_processors': 194, 'preceding_job': -1, 'user_id': -1, 'app_number': -1, 'queue_number': -1, 'used_memory': -1, 'requested_memory': 4312, 'partition_number': -1, 'wait_time': -1, 'allocated_processors': 194, 'requested_time': 3193, 'think_time_from_preceding_job': -1, 'run_time': 3193, 'submit_time': 9, 'avg_cpu_time_used': -1, 'group_id': -1, 'job_number': 1}
+;Automatically generated workload description by the Data Center Workload and Resource Management Simulator
+;		j|		s|		w|		r|		c|		c|		m|		p|		t|		m|		s|		u|		g|		e|		q|		p|		p|		t|
+;		o|		u|		a|		u|		p|		p|		e|		r|		i|		e|		t|		i|		i|		x|		u|		a|		r|		h|
+;		b|		b|		i|		n|		u|		u|		m|		o|		m|		m|		a|		d|		d|		e|		e|		r|		e|		i|
+;		 |		m|		t|		t|		 |		 |		 |		c|		e|		 |		t|		 |		 |		c|		u|		t|		c|		n|
+;		 |		i|		 |		i|		a|		t|		u|		 |		 |		r|		u|		 |		 |		u|		e|		i|		 |		k|
+;		 |		t|		 |		m|		l|		i|		s|		r|		r|		e|		s|		 |		 |		t|		 |		t|		j|		 |
+;		 |		 |		 |		e|		l|		m|		e|		e|		e|		q|		 |		 |		 |		a|		n|		i|		o|		t|
+;		 |		 |		 |		 |		o|		e|		d|		q|		q|		 |		 |		 |		 |		b|		r|		o|		b|		i|
+;		 |		 |		 |		 |		c|		 |		 |		 |		 |		 |		 |		 |		 |		l|		 |		n|		 |		m|
+;		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		e|		 |		 |		 |		e|
+;StartTime: Thu Jan 15 10:00:00 CET 2009
+1	9	-1	3193	194	-1	-1	194	3193	4312	1	-1	-1	-1	-1	-1	-1	-1	
+2	9	-1	3239	295	-1	-1	295	3239	5078	1	-1	-1	-1	-1	-1	-1	-1	
+3	58	-1	2640	214	-1	-1	214	2640	5152	1	-1	-1	-1	-1	-1	-1	-1	
+4	61	-1	2963	89	-1	-1	89	2963	2755	1	-1	-1	-1	-1	-1	-1	-1	
+5	69	-1	3353	342	-1	-1	342	3353	1708	1	-1	-1	-1	-1	-1	-1	-1	
+6	72	-1	657	80	-1	-1	80	657	1087	1	-1	-1	-1	-1	-1	-1	-1	
+7	94	-1	1337	176	-1	-1	176	1337	1853	1	-1	-1	-1	-1	-1	-1	-1	
+8	98	-1	2721	337	-1	-1	337	2721	6671	1	-1	-1	-1	-1	-1	-1	-1	
+9	99	-1	3335	33	-1	-1	33	3335	5612	1	-1	-1	-1	-1	-1	-1	-1	
+10	116	-1	1055	365	-1	-1	365	1055	6630	1	-1	-1	-1	-1	-1	-1	-1	
+11	127	-1	746	322	-1	-1	322	746	1070	1	-1	-1	-1	-1	-1	-1	-1	
+12	146	-1	2286	269	-1	-1	269	2286	4498	1	-1	-1	-1	-1	-1	-1	-1	
+13	224	-1	1460	59	-1	-1	59	1460	1033	1	-1	-1	-1	-1	-1	-1	-1	
+14	232	-1	2868	186	-1	-1	186	2868	2234	1	-1	-1	-1	-1	-1	-1	-1	
+15	238	-1	2501	308	-1	-1	308	2501	1308	1	-1	-1	-1	-1	-1	-1	-1	
+16	330	-1	3473	136	-1	-1	136	3473	3986	1	-1	-1	-1	-1	-1	-1	-1	
+17	332	-1	2198	98	-1	-1	98	2198	4696	1	-1	-1	-1	-1	-1	-1	-1	
+18	342	-1	2938	40	-1	-1	40	2938	5947	1	-1	-1	-1	-1	-1	-1	-1	
+19	354	-1	3454	239	-1	-1	239	3454	4737	1	-1	-1	-1	-1	-1	-1	-1	
+20	372	-1	2200	78	-1	-1	78	2200	2175	1	-1	-1	-1	-1	-1	-1	-1	
+21	388	-1	2743	146	-1	-1	146	2743	5323	1	-1	-1	-1	-1	-1	-1	-1	
+22	406	-1	2480	229	-1	-1	229	2480	3540	1	-1	-1	-1	-1	-1	-1	-1	
+23	406	-1	616	252	-1	-1	252	616	5767	1	-1	-1	-1	-1	-1	-1	-1	
+24	509	-1	665	115	-1	-1	115	665	3371	1	-1	-1	-1	-1	-1	-1	-1	
+25	511	-1	1174	92	-1	-1	92	1174	5890	1	-1	-1	-1	-1	-1	-1	-1	
+26	568	-1	1579	366	-1	-1	366	1579	6333	1	-1	-1	-1	-1	-1	-1	-1	
+27	577	-1	2080	186	-1	-1	186	2080	1811	1	-1	-1	-1	-1	-1	-1	-1	
+28	592	-1	2178	41	-1	-1	41	2178	5349	1	-1	-1	-1	-1	-1	-1	-1	
+29	596	-1	910	218	-1	-1	218	910	1408	1	-1	-1	-1	-1	-1	-1	-1	
+30	599	-1	2002	123	-1	-1	123	2002	1716	1	-1	-1	-1	-1	-1	-1	-1	
+31	603	-1	2670	164	-1	-1	164	2670	6846	1	-1	-1	-1	-1	-1	-1	-1	
+32	638	-1	2791	290	-1	-1	290	2791	2058	1	-1	-1	-1	-1	-1	-1	-1	
+33	659	-1	2083	331	-1	-1	331	2083	3440	1	-1	-1	-1	-1	-1	-1	-1	
+34	666	-1	1980	91	-1	-1	91	1980	3128	1	-1	-1	-1	-1	-1	-1	-1	
+35	788	-1	1554	364	-1	-1	364	1554	2459	1	-1	-1	-1	-1	-1	-1	-1	
+36	789	-1	2379	67	-1	-1	67	2379	6979	1	-1	-1	-1	-1	-1	-1	-1	
+37	844	-1	2704	40	-1	-1	40	2704	2995	1	-1	-1	-1	-1	-1	-1	-1	
+38	865	-1	2466	84	-1	-1	84	2466	6985	1	-1	-1	-1	-1	-1	-1	-1	
+39	870	-1	2157	370	-1	-1	370	2157	2958	1	-1	-1	-1	-1	-1	-1	-1	
+40	876	-1	2648	331	-1	-1	331	2648	1620	1	-1	-1	-1	-1	-1	-1	-1	
+41	903	-1	1108	109	-1	-1	109	1108	4573	1	-1	-1	-1	-1	-1	-1	-1	
+42	924	-1	1758	168	-1	-1	168	1758	3526	1	-1	-1	-1	-1	-1	-1	-1	
+43	930	-1	2769	228	-1	-1	228	2769	6010	1	-1	-1	-1	-1	-1	-1	-1	
+44	939	-1	2014	193	-1	-1	193	2014	4067	1	-1	-1	-1	-1	-1	-1	-1	
+45	1062	-1	2435	315	-1	-1	315	2435	2022	1	-1	-1	-1	-1	-1	-1	-1	
+46	1070	-1	3122	238	-1	-1	238	3122	4866	1	-1	-1	-1	-1	-1	-1	-1	
+47	1081	-1	1447	112	-1	-1	112	1447	6624	1	-1	-1	-1	-1	-1	-1	-1	
+48	1099	-1	3388	323	-1	-1	323	3388	2898	1	-1	-1	-1	-1	-1	-1	-1	
+49	1133	-1	1053	53	-1	-1	53	1053	5776	1	-1	-1	-1	-1	-1	-1	-1	
+50	1151	-1	830	203	-1	-1	203	830	1999	1	-1	-1	-1	-1	-1	-1	-1	
+51	1154	-1	2348	127	-1	-1	127	2348	4103	1	-1	-1	-1	-1	-1	-1	-1	
+52	1164	-1	1591	325	-1	-1	325	1591	3279	1	-1	-1	-1	-1	-1	-1	-1	
+53	1195	-1	3062	265	-1	-1	265	3062	5413	1	-1	-1	-1	-1	-1	-1	-1	
+54	1228	-1	1780	109	-1	-1	109	1780	6565	1	-1	-1	-1	-1	-1	-1	-1	
+55	1243	-1	2268	78	-1	-1	78	2268	6061	1	-1	-1	-1	-1	-1	-1	-1	
+56	1274	-1	1651	178	-1	-1	178	1651	6658	1	-1	-1	-1	-1	-1	-1	-1	
+57	1278	-1	2869	128	-1	-1	128	2869	3034	1	-1	-1	-1	-1	-1	-1	-1	
+58	1325	-1	531	279	-1	-1	279	531	1639	1	-1	-1	-1	-1	-1	-1	-1	
+59	1381	-1	2233	323	-1	-1	323	2233	2855	1	-1	-1	-1	-1	-1	-1	-1	
+60	1392	-1	816	274	-1	-1	274	816	6978	1	-1	-1	-1	-1	-1	-1	-1	
+61	1434	-1	881	110	-1	-1	110	881	2745	1	-1	-1	-1	-1	-1	-1	-1	
+62	1525	-1	3162	72	-1	-1	72	3162	4664	1	-1	-1	-1	-1	-1	-1	-1	
+63	1531	-1	2680	111	-1	-1	111	2680	5186	1	-1	-1	-1	-1	-1	-1	-1	
+64	1567	-1	1556	185	-1	-1	185	1556	3962	1	-1	-1	-1	-1	-1	-1	-1	
+65	1588	-1	2938	226	-1	-1	226	2938	1444	1	-1	-1	-1	-1	-1	-1	-1	
+66	1600	-1	2357	110	-1	-1	110	2357	7094	1	-1	-1	-1	-1	-1	-1	-1	
+67	1610	-1	928	111	-1	-1	111	928	6810	1	-1	-1	-1	-1	-1	-1	-1	
+68	1610	-1	3017	185	-1	-1	185	3017	2813	1	-1	-1	-1	-1	-1	-1	-1	
+69	1626	-1	3009	261	-1	-1	261	3009	6086	1	-1	-1	-1	-1	-1	-1	-1	
+70	1675	-1	2575	318	-1	-1	318	2575	1501	1	-1	-1	-1	-1	-1	-1	-1	
+71	1690	-1	3050	61	-1	-1	61	3050	4502	1	-1	-1	-1	-1	-1	-1	-1	
+72	1733	-1	1685	162	-1	-1	162	1685	5961	1	-1	-1	-1	-1	-1	-1	-1	
+73	1769	-1	1846	272	-1	-1	272	1846	1995	1	-1	-1	-1	-1	-1	-1	-1	
+74	1810	-1	1150	293	-1	-1	293	1150	6804	1	-1	-1	-1	-1	-1	-1	-1	
+75	1932	-1	1550	99	-1	-1	99	1550	3400	1	-1	-1	-1	-1	-1	-1	-1	
+76	2030	-1	2725	161	-1	-1	161	2725	4936	1	-1	-1	-1	-1	-1	-1	-1	
+77	2052	-1	3498	272	-1	-1	272	3498	1654	1	-1	-1	-1	-1	-1	-1	-1	
+78	2061	-1	2262	360	-1	-1	360	2262	5039	1	-1	-1	-1	-1	-1	-1	-1	
+79	2073	-1	2953	158	-1	-1	158	2953	2522	1	-1	-1	-1	-1	-1	-1	-1	
+80	2081	-1	2099	43	-1	-1	43	2099	1630	1	-1	-1	-1	-1	-1	-1	-1	
+81	2102	-1	1068	119	-1	-1	119	1068	4362	1	-1	-1	-1	-1	-1	-1	-1	
+82	2103	-1	1170	345	-1	-1	345	1170	5517	1	-1	-1	-1	-1	-1	-1	-1	
+83	2104	-1	1000	140	-1	-1	140	1000	5701	1	-1	-1	-1	-1	-1	-1	-1	
+84	2135	-1	1339	349	-1	-1	349	1339	4120	1	-1	-1	-1	-1	-1	-1	-1	
+85	2154	-1	2218	221	-1	-1	221	2218	5602	1	-1	-1	-1	-1	-1	-1	-1	
+86	2186	-1	1521	143	-1	-1	143	1521	2626	1	-1	-1	-1	-1	-1	-1	-1	
+87	2206	-1	3170	83	-1	-1	83	3170	4574	1	-1	-1	-1	-1	-1	-1	-1	
+88	2271	-1	3339	148	-1	-1	148	3339	5735	1	-1	-1	-1	-1	-1	-1	-1	
+89	2280	-1	1647	38	-1	-1	38	1647	6118	1	-1	-1	-1	-1	-1	-1	-1	
+90	2282	-1	2093	302	-1	-1	302	2093	3153	1	-1	-1	-1	-1	-1	-1	-1	
+91	2283	-1	1862	326	-1	-1	326	1862	1801	1	-1	-1	-1	-1	-1	-1	-1	
+92	2306	-1	1146	129	-1	-1	129	1146	4630	1	-1	-1	-1	-1	-1	-1	-1	
+93	2324	-1	1771	312	-1	-1	312	1771	4593	1	-1	-1	-1	-1	-1	-1	-1	
+94	2351	-1	1559	89	-1	-1	89	1559	6247	1	-1	-1	-1	-1	-1	-1	-1	
+95	2357	-1	3099	279	-1	-1	279	3099	3043	1	-1	-1	-1	-1	-1	-1	-1	
+96	2383	-1	3293	202	-1	-1	202	3293	6275	1	-1	-1	-1	-1	-1	-1	-1	
+97	2400	-1	1197	145	-1	-1	145	1197	2376	1	-1	-1	-1	-1	-1	-1	-1	
+98	2427	-1	1286	119	-1	-1	119	1286	6642	1	-1	-1	-1	-1	-1	-1	-1	
+99	2454	-1	1728	334	-1	-1	334	1728	3921	1	-1	-1	-1	-1	-1	-1	-1	
+100	2552	-1	2620	333	-1	-1	333	2620	2081	1	-1	-1	-1	-1	-1	-1	-1	
+101	2561	-1	2032	318	-1	-1	318	2032	2124	1	-1	-1	-1	-1	-1	-1	-1	
+102	2577	-1	579	90	-1	-1	90	579	4311	1	-1	-1	-1	-1	-1	-1	-1	
+103	2595	-1	3006	328	-1	-1	328	3006	3897	1	-1	-1	-1	-1	-1	-1	-1	
+104	2595	-1	2472	46	-1	-1	46	2472	4102	1	-1	-1	-1	-1	-1	-1	-1	
+105	2613	-1	529	195	-1	-1	195	529	2268	1	-1	-1	-1	-1	-1	-1	-1	
+106	2632	-1	2863	103	-1	-1	103	2863	4453	1	-1	-1	-1	-1	-1	-1	-1	
+107	2699	-1	3168	226	-1	-1	226	3168	3303	1	-1	-1	-1	-1	-1	-1	-1	
+108	2700	-1	1989	64	-1	-1	64	1989	1535	1	-1	-1	-1	-1	-1	-1	-1	
+109	2711	-1	903	111	-1	-1	111	903	3679	1	-1	-1	-1	-1	-1	-1	-1	
+110	2758	-1	817	246	-1	-1	246	817	2127	1	-1	-1	-1	-1	-1	-1	-1	
+111	2772	-1	2897	125	-1	-1	125	2897	2866	1	-1	-1	-1	-1	-1	-1	-1	
+112	2779	-1	3413	345	-1	-1	345	3413	6524	1	-1	-1	-1	-1	-1	-1	-1	
+113	2792	-1	1500	158	-1	-1	158	1500	7161	1	-1	-1	-1	-1	-1	-1	-1	
+114	2821	-1	2806	191	-1	-1	191	2806	5428	1	-1	-1	-1	-1	-1	-1	-1	
+115	2863	-1	1135	127	-1	-1	127	1135	1941	1	-1	-1	-1	-1	-1	-1	-1	
+116	2866	-1	2426	236	-1	-1	236	2426	3600	1	-1	-1	-1	-1	-1	-1	-1	
+117	2867	-1	2415	348	-1	-1	348	2415	1136	1	-1	-1	-1	-1	-1	-1	-1	
+118	2907	-1	1873	351	-1	-1	351	1873	6108	1	-1	-1	-1	-1	-1	-1	-1	
+119	2919	-1	1952	307	-1	-1	307	1952	6215	1	-1	-1	-1	-1	-1	-1	-1	
+120	2934	-1	1825	64	-1	-1	64	1825	1924	1	-1	-1	-1	-1	-1	-1	-1	
+121	2937	-1	1448	38	-1	-1	38	1448	4434	1	-1	-1	-1	-1	-1	-1	-1	
+122	2938	-1	1215	136	-1	-1	136	1215	6848	1	-1	-1	-1	-1	-1	-1	-1	
+123	3101	-1	2717	347	-1	-1	347	2717	2661	1	-1	-1	-1	-1	-1	-1	-1	
+124	3110	-1	589	368	-1	-1	368	589	3051	1	-1	-1	-1	-1	-1	-1	-1	
+125	3124	-1	1042	256	-1	-1	256	1042	7024	1	-1	-1	-1	-1	-1	-1	-1	
+126	3129	-1	1411	278	-1	-1	278	1411	5628	1	-1	-1	-1	-1	-1	-1	-1	
+127	3152	-1	1926	49	-1	-1	49	1926	2608	1	-1	-1	-1	-1	-1	-1	-1	
+128	3162	-1	3322	113	-1	-1	113	3322	3691	1	-1	-1	-1	-1	-1	-1	-1	
+129	3213	-1	2250	70	-1	-1	70	2250	4919	1	-1	-1	-1	-1	-1	-1	-1	
+130	3266	-1	1387	189	-1	-1	189	1387	4488	1	-1	-1	-1	-1	-1	-1	-1	
+131	3311	-1	2351	89	-1	-1	89	2351	5056	1	-1	-1	-1	-1	-1	-1	-1	
+132	3348	-1	3021	253	-1	-1	253	3021	4293	1	-1	-1	-1	-1	-1	-1	-1	
+133	3374	-1	2118	215	-1	-1	215	2118	6197	1	-1	-1	-1	-1	-1	-1	-1	
+134	3387	-1	2395	259	-1	-1	259	2395	2165	1	-1	-1	-1	-1	-1	-1	-1	
+135	3401	-1	2651	239	-1	-1	239	2651	3038	1	-1	-1	-1	-1	-1	-1	-1	
+136	3446	-1	3239	72	-1	-1	72	3239	2452	1	-1	-1	-1	-1	-1	-1	-1	
+137	3451	-1	3137	358	-1	-1	358	3137	5658	1	-1	-1	-1	-1	-1	-1	-1	
+138	3507	-1	3253	267	-1	-1	267	3253	6254	1	-1	-1	-1	-1	-1	-1	-1	
+139	3522	-1	2150	43	-1	-1	43	2150	3546	1	-1	-1	-1	-1	-1	-1	-1	
+140	3527	-1	2499	187	-1	-1	187	2499	7105	1	-1	-1	-1	-1	-1	-1	-1	
+141	3541	-1	1015	263	-1	-1	263	1015	3105	1	-1	-1	-1	-1	-1	-1	-1	
+142	3543	-1	1353	157	-1	-1	157	1353	3223	1	-1	-1	-1	-1	-1	-1	-1	
+143	3572	-1	2886	320	-1	-1	320	2886	5199	1	-1	-1	-1	-1	-1	-1	-1	
+144	3607	-1	957	154	-1	-1	154	957	1463	1	-1	-1	-1	-1	-1	-1	-1	
+145	3617	-1	2448	263	-1	-1	263	2448	4722	1	-1	-1	-1	-1	-1	-1	-1	
+146	3618	-1	3060	57	-1	-1	57	3060	6809	1	-1	-1	-1	-1	-1	-1	-1	
+147	3620	-1	3217	37	-1	-1	37	3217	6379	1	-1	-1	-1	-1	-1	-1	-1	
+148	3690	-1	3371	364	-1	-1	364	3371	3594	1	-1	-1	-1	-1	-1	-1	-1	
+149	3712	-1	729	62	-1	-1	62	729	2629	1	-1	-1	-1	-1	-1	-1	-1	
+150	3724	-1	679	245	-1	-1	245	679	5606	1	-1	-1	-1	-1	-1	-1	-1	
+151	3734	-1	2188	329	-1	-1	329	2188	2890	1	-1	-1	-1	-1	-1	-1	-1	
+152	3742	-1	2546	150	-1	-1	150	2546	6087	1	-1	-1	-1	-1	-1	-1	-1	
+153	3744	-1	3355	290	-1	-1	290	3355	3432	1	-1	-1	-1	-1	-1	-1	-1	
+154	3750	-1	822	227	-1	-1	227	822	1450	1	-1	-1	-1	-1	-1	-1	-1	
+155	3841	-1	2602	141	-1	-1	141	2602	4615	1	-1	-1	-1	-1	-1	-1	-1	
+156	3863	-1	2421	314	-1	-1	314	2421	3249	1	-1	-1	-1	-1	-1	-1	-1	
+157	3895	-1	968	31	-1	-1	31	968	6690	1	-1	-1	-1	-1	-1	-1	-1	
+158	3917	-1	3182	125	-1	-1	125	3182	4290	1	-1	-1	-1	-1	-1	-1	-1	
+159	3935	-1	670	287	-1	-1	287	670	7071	1	-1	-1	-1	-1	-1	-1	-1	
+160	3958	-1	629	75	-1	-1	75	629	1864	1	-1	-1	-1	-1	-1	-1	-1	
+161	3970	-1	2104	355	-1	-1	355	2104	2899	1	-1	-1	-1	-1	-1	-1	-1	
+;IDMapping: swfID:jobID:taskID
+; 
+;0:0:0, 1:1:0, 2:2:0, 3:3:0, 4:4:0, 5:5:0, 6:6:0, 7:7:0, 8:8:0, 9:9:0, 
+;10:10:0, 11:11:0, 12:12:0, 13:13:0, 14:14:0, 15:15:0, 16:16:0, 17:17:0, 18:18:0, 19:19:0, 
+;20:20:0, 21:21:0, 22:22:0, 23:23:0, 24:24:0, 25:25:0, 26:26:0, 27:27:0, 28:28:0, 29:29:0, 
+;30:30:0, 31:31:0, 32:32:0, 33:33:0, 34:34:0, 35:35:0, 36:36:0, 37:37:0, 38:38:0, 39:39:0, 
+;40:40:0, 41:41:0, 42:42:0, 43:43:0, 44:44:0, 45:45:0, 46:46:0, 47:47:0, 48:48:0, 49:49:0, 
+;50:50:0, 51:51:0, 52:52:0, 53:53:0, 54:54:0, 55:55:0, 56:56:0, 57:57:0, 58:58:0, 59:59:0, 
+;60:60:0, 61:61:0, 62:62:0, 63:63:0, 64:64:0, 65:65:0, 66:66:0, 67:67:0, 68:68:0, 69:69:0, 
+;70:70:0, 71:71:0, 72:72:0, 73:73:0, 74:74:0, 75:75:0, 76:76:0, 77:77:0, 78:78:0, 79:79:0, 
+;80:80:0, 81:81:0, 82:82:0, 83:83:0, 84:84:0, 85:85:0, 86:86:0, 87:87:0, 88:88:0, 89:89:0, 
+;90:90:0, 91:91:0, 92:92:0, 93:93:0, 94:94:0, 95:95:0, 96:96:0, 97:97:0, 98:98:0, 99:99:0, 
+;100:100:0, 101:101:0, 102:102:0, 103:103:0, 104:104:0, 105:105:0, 106:106:0, 107:107:0, 108:108:0, 109:109:0, 
+;110:110:0, 111:111:0, 112:112:0, 113:113:0, 114:114:0, 115:115:0, 116:116:0, 117:117:0, 118:118:0, 119:119:0, 
+;120:120:0, 121:121:0, 122:122:0, 123:123:0, 124:124:0, 125:125:0, 126:126:0, 127:127:0, 128:128:0, 129:129:0, 
+;130:130:0, 131:131:0, 132:132:0, 133:133:0, 134:134:0, 135:135:0, 136:136:0, 137:137:0, 138:138:0, 139:139:0, 
+;140:140:0, 141:141:0, 142:142:0, 143:143:0, 144:144:0, 145:145:0, 146:146:0, 147:147:0, 148:148:0, 149:149:0, 
+;150:150:0, 151:151:0, 152:152:0, 153:153:0, 154:154:0, 155:155:0, 156:156:0, 157:157:0, 158:158:0, 159:159:0, 
+;160:160:0, 161:161:0, 
+; 
+;IDMapping: end
Index: DCWoRMS/branches/coolemall/src/test/testSOP/trucs.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/testSOP/trucs.txt	(revision 1606)
+++ DCWoRMS/branches/coolemall/src/test/testSOP/trucs.txt	(revision 1606)
@@ -0,0 +1,11 @@
+1.8 Proc en moyenne = 45%
+4760 mÃ©moire en moyenne = 29%
+400 durÃ©e moyenne 
+
+==> 13 jobs en meme temps
+
+==> 30s interarrival?
+
+1105439112
+1143960112
+1169804112
