Index: DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessRandomSP.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessRandomSP.java	(revision 708)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessRandomSP.java	(revision 734)
@@ -91,13 +91,14 @@
 
 			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
-			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+			for (int i = 0; i < cores.size(); i++) {
 				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(cores.get(i));
+					//choosenResources.add(cores.get(i));
 					cpuRequest--;
 				}
 			}
 			if (cpuRequest > 0) {
-				return null;
+				//return null;
 			}
+			choosenResources.add(node);
 			ProcessingElements pe = new ProcessingElements();
 			pe.addAll(choosenResources);
Index: DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessEnOptDFSSP.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessEnOptDFSSP.java	(revision 734)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessEnOptDFSSP.java	(revision 734)
@@ -0,0 +1,279 @@
+package test.article.recs.plugins.scheduling;
+
+import gridsim.dcworms.DCWormsTags;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.computing.ComputingNode;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+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.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import test.article.recs.utils.AppType;
+import test.article.recs.utils.RecsProcessorPowerInterface;
+
+public class RecsExclusivenessEnOptDFSSP extends RecsSP {
+
+	private static String TIME_DATA_FILE_NAME = "src/test/article/recs/data/time_data.properties";
+	private static String POWER_DATA_FILE_NAME = "src/test/article/recs/data/power_data.properties";
+	
+	private ResourceBundle powBundle;
+	private ResourceBundle timeBundle;
+	
+	
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// our tasks are placed only in first queue (see
+		// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+		TaskQueue q = queues.get(0);
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				initApplicationType(task);
+				
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources  != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} 
+				}
+			}
+			adjustFrequency(resourceManager.getProcessors());
+		}
+		return plan;
+	}
+	
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map;
+		List<ComputingNode> nodes = resourceManager.getComputingNodes();
+		Collections.sort(nodes, new EnergyComparator(task));
+		//System.out.println("*****");
+		for (ComputingNode node : nodes) {
+			//System.out.println(node.getCategory());
+			int cpuRequest;
+			try {
+				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+			} catch (NoSuchFieldException e) {
+				cpuRequest = 0;
+			}
+
+			if (cpuRequest != 0) {
+
+				/*Properties properties = new Properties();
+				properties.setProperty("type", StandardResourceType.Core.getName());
+				properties.setProperty("status", ResourceStatus.FREE.toString());
+				 */
+				List<Core> cores = node.getProcessors().get(0).getCores();
+				if (cores.size() < cpuRequest/* || node.getProcessors().get(0).filterDescendants(properties).size() != cores.size()*/) {
+					continue;
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores != cores.size())
+					continue;
+				
+				try {
+					if(!getExecutiveness(createExecutivenessQuery(task, node)))
+						continue;
+				} catch (FileNotFoundException e) {
+					continue;
+				} catch (IOException e) {
+					continue;
+				} catch (MissingResourceException e){
+					continue;
+				}
+				
+				List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
+				for (int i = 0; i < cores.size(); i++) {
+					if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+						//choosenResources.add(cores.get(i));
+						cpuRequest--;
+					}
+				}
+				choosenResources.add(node);
+				if (cpuRequest > 0) {
+					//continue;
+				}
+				map = new HashMap<ResourceUnitName, ResourceUnit>();
+				ProcessingElements pe = new ProcessingElements();
+				pe.addAll(choosenResources);
+				map.put(StandardResourceUnitName.PE, pe);
+				return map;
+
+			}
+		}
+	
+		return null;
+	}
+	
+
+	
+	protected String createQuery(TaskInterface<?> task, ComputingNode node) {
+		String query;
+		query = getApplicationType(task) + "." + getNodeCategory(node) + "." + getFrequency(node) + "." + getCoreCnt(task);
+		return query;
+	}
+
+	private String getApplicationType(TaskInterface<?> task){	
+		AppType appType = taskToApp.getAppType(task);
+		return appType.toString();
+	}
+	
+	private String getNodeCategory(ComputingNode node){
+
+		return node.getCategory();
+	}
+	
+	private int getFrequency(ComputingNode node){
+		Processor proc = (Processor) node.getProcessors().get(0);
+		double freq = proc.getPowerInterface().getFrequency();
+		return Double.valueOf(freq).intValue();	
+	}
+	
+	private int getCoreCnt(TaskInterface<?> task){	
+		double cpuReq;
+		try {
+			cpuReq = task.getCpuCntRequest();
+		} catch (NoSuchFieldException e) {
+				cpuReq = 1;
+		}
+		return Double.valueOf(cpuReq).intValue();
+	}
+	
+	protected double getMeasuredPower(String query) throws FileNotFoundException, IOException{
+		ResourceBundle powBundle = getPowBundle();
+		return Double.valueOf(powBundle.getString(query)).doubleValue();
+	}
+	
+	private ResourceBundle getPowBundle() throws FileNotFoundException, IOException{
+		if(powBundle == null){
+			 powBundle = new PropertyResourceBundle(new FileInputStream(POWER_DATA_FILE_NAME));
+		}
+		return powBundle;
+	}
+	
+	protected double getMeasuredTime(String query) throws FileNotFoundException, IOException{
+		ResourceBundle timeBundle = getTimeBundle();
+		return Double.valueOf(timeBundle.getString(query)).doubleValue();
+	}
+
+	private ResourceBundle getTimeBundle() throws FileNotFoundException, IOException{
+		if(timeBundle == null){
+			timeBundle = new PropertyResourceBundle(new FileInputStream(TIME_DATA_FILE_NAME));
+		}
+		return timeBundle;
+	}
+	class EnergyComparator implements Comparator<ComputingNode>{
+		private TaskInterface<?> task;
+		
+		public EnergyComparator(TaskInterface<?> task){
+			this.task = task;
+		}
+		
+	    public int compare(ComputingNode node1, ComputingNode node2){    
+	    	double node1EU = Double.MAX_VALUE;
+	    	double node2EU = Double.MAX_VALUE;
+	    	try {
+				node1EU = getMeasuredTime(createQuery(task, node1)) * getMeasuredPower(createQuery(task, node1));
+			} catch (FileNotFoundException e) {
+
+			} catch (IOException e) {
+
+			} catch (MissingResourceException e){
+				
+			}
+	    	try {
+				node2EU = getMeasuredTime(createQuery(task, node2)) * getMeasuredPower(createQuery(task, node2));
+			} catch (FileNotFoundException e) {
+
+			} catch (IOException e) {
+
+			} catch (MissingResourceException e){
+				
+			}
+	        if(node1EU > node2EU)
+	        	return 1;
+	        else if (node1EU < node2EU)
+	        	return -1;
+	        else return 0;
+	   
+	    }
+	}
+	private void adjustFrequency(List<Processor> processors){
+
+		for(Processor cpu: processors){
+			RecsProcessorPowerInterface rppi = (RecsProcessorPowerInterface) cpu.getPowerInterface();
+			int freeCores = 0;
+
+			for(Core core: cpu.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			if(freeCores == cpu.getCores().size()){
+				if(cpu.getComputingNode().getCategory().compareTo("Intel_i7") == 0){
+					rppi.setPState(rppi.getSupportedPStates().get("P13").getName());	
+				} else if(cpu.getComputingNode().getCategory().compareTo("AMD_Fusion") == 0){
+					rppi.setPState(rppi.getSupportedPStates().get("P1").getName());	
+				} else if(cpu.getComputingNode().getCategory().compareTo("Atom_D510") == 0){
+					rppi.setPState(rppi.getSupportedPStates().get("P7").getName());	
+				} 
+			}
+			else {
+				if(cpu.getComputingNode().getCategory().compareTo("Intel_i7") == 0){
+					rppi.setPState(rppi.getSupportedPStates().get("P13").getName());	
+				} else if(cpu.getComputingNode().getCategory().compareTo("AMD_Fusion") == 0){
+					rppi.setPState(rppi.getSupportedPStates().get("P1").getName());	
+				} else if(cpu.getComputingNode().getCategory().compareTo("Atom_D510") == 0){
+					rppi.setPState(rppi.getSupportedPStates().get("P7").getName());	
+				} 	
+			}
+
+		}
+	}
+
+}
Index: DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessEnOptSP.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessEnOptSP.java	(revision 711)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessEnOptSP.java	(revision 734)
@@ -127,12 +127,13 @@
 				
 				List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
-				for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				for (int i = 0; i < cores.size(); i++) {
 					if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-						choosenResources.add(cores.get(i));
+						//choosenResources.add(cores.get(i));
 						cpuRequest--;
 					}
 				}
+				choosenResources.add(node);
 				if (cpuRequest > 0) {
-					continue;
+					//continue;
 				}
 				map = new HashMap<ResourceUnitName, ResourceUnit>();
Index: DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessRandomNodePowManSP.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessRandomNodePowManSP.java	(revision 708)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessRandomNodePowManSP.java	(revision 734)
@@ -95,12 +95,13 @@
 
 			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
-			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+			for (int i = 0; i < cores.size(); i++) {
 				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(cores.get(i));
+					//choosenResources.add(cores.get(i));
 					cpuRequest--;
 				}
 			}
+			choosenResources.add(node);
 			if (cpuRequest > 0) {
-				return null;
+				//return null;
 			}
 			ProcessingElements pe = new ProcessingElements();
Index: DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessDFSSP.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessDFSSP.java	(revision 708)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessDFSSP.java	(revision 734)
@@ -93,12 +93,13 @@
 
 			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
-			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+			for (int i = 0; i < cores.size(); i++) {
 				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(cores.get(i));
+					//choosenResources.add(cores.get(i));
 					cpuRequest--;
 				}
 			}
+			choosenResources.add(node);
 			if (cpuRequest > 0) {
-				return null;
+				//return null;
 			}
 			ProcessingElements pe = new ProcessingElements();
Index: DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessEnOptNodePowManSP.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessEnOptNodePowManSP.java	(revision 711)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessEnOptNodePowManSP.java	(revision 734)
@@ -132,12 +132,13 @@
 				
 				List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
-				for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				for (int i = 0; i < cores.size(); i++) {
 					if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-						choosenResources.add(cores.get(i));
+						//choosenResources.add(cores.get(i));
 						cpuRequest--;
 					}
 				}
+				choosenResources.add(node);
 				if (cpuRequest > 0) {
-					continue;
+					//continue;
 				}
 				map = new HashMap<ResourceUnitName, ResourceUnit>();
Index: DCWoRMS/trunk/src/test/article/recs/plugins/energy/RecsNodeBaseEEP.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/energy/RecsNodeBaseEEP.java	(revision 662)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/energy/RecsNodeBaseEEP.java	(revision 734)
@@ -8,4 +8,5 @@
 import java.util.ResourceBundle;
 
+import schedframe.resources.computing.ComputingNode;
 import schedframe.resources.computing.Core;
 import schedframe.resources.computing.Processor;
@@ -46,4 +47,6 @@
 		
 		ProcessingElements pe = (ProcessingElements) peUnit;
+		if(pe.get(0) instanceof ComputingNode)
+			return ((ComputingNode)pe.get(0)).getCategory();
 		Core core = (Core)pe.get(0);
 		return core.getParent().getParent().getCategory();
@@ -52,4 +55,6 @@
 	private int getFrequency(PEUnit peUnit){
 		ProcessingElements pe = (ProcessingElements) peUnit;
+		if(pe.get(0) instanceof ComputingNode)
+			return Double.valueOf(((ComputingNode)pe.get(0)).getProcessors().get(0).getPowerInterface().getFrequency()).intValue();
 		Core core = (Core)pe.get(0);
 		Processor proc = (Processor) core.getParent();
Index: DCWoRMS/trunk/src/test/article/recs/plugins/timeestimation/RecsTimeEstimationPlugin.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/timeestimation/RecsTimeEstimationPlugin.java	(revision 664)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/timeestimation/RecsTimeEstimationPlugin.java	(revision 734)
@@ -10,4 +10,5 @@
 
 import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.computing.ComputingNode;
 import schedframe.resources.computing.Core;
 import schedframe.resources.computing.Processor;
@@ -42,8 +43,10 @@
 		try {
 			execTime = TIME_FACTOR * (1 - completionPercentage/100) * getMeasuredTime(query);
+			//System.out.println(task.getJobId()+": "+ execTime + "; "+ completionPercentage);
 			if (Double.compare(execTime, 0.001) < 0) {
 				execTime = 0.001;
 			}
 			execTime = Math.round(execTime);
+			//System.out.println(task.getJobId()+": "+ execTime);
 		} catch (FileNotFoundException e) {
 			execTime = defaultEstimation(task, peUnit, completionPercentage);
@@ -71,4 +74,6 @@
 		
 		ProcessingElements pe = (ProcessingElements) peUnit;
+		if(pe.get(0) instanceof ComputingNode)
+			return ((ComputingNode)pe.get(0)).getCategory();
 		Core core = (Core)pe.get(0);
 		return core.getParent().getParent().getCategory();
@@ -77,4 +82,6 @@
 	private int getFrequency(PEUnit peUnit){
 		ProcessingElements pe = (ProcessingElements) peUnit;
+		if(pe.get(0) instanceof ComputingNode)
+			return Double.valueOf(((ComputingNode)pe.get(0)).getProcessors().get(0).getPowerInterface().getFrequency()).intValue();
 		Core core = (Core)pe.get(0);
 		Processor proc = (Processor) core.getParent();
