Commit c1343c14 authored by eudaldsabate's avatar eudaldsabate
Browse files

LNS has the sensor2actuator changes, LNSNL does not.

parent 256a54a9
......@@ -4,15 +4,7 @@ import es.bsc.compss.log.Loggers;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.*;
public class LNS extends Heuristics {
......@@ -33,7 +25,16 @@ public class LNS extends Heuristics {
this.m = m;
}
public ReadyQueueElement getNextReadyTask(PriorityQueue<ReadyQueueElement> readyQueue) {
public ReadyQueueElement getNextReadyTask(PriorityQueue<ReadyQueueElement> readyQueue, float lastScheduledEndTime) {
double factorThreshold = Double.POSITIVE_INFINITY;
Iterator<ReadyQueueElement> iterator = readyQueue.iterator();
while (iterator.hasNext()) {
ReadyQueueElement rqe = iterator.next();
if (lastScheduledEndTime - rqe.releaseTime >= factorThreshold * 1000 / 30) {
iterator.remove();
return rqe;
}
}
return readyQueue.poll();
}
......@@ -276,8 +277,9 @@ public class LNS extends Heuristics {
int resource;
ResourceTransferCost rtf;
this.dummyNodes = 0;
float lastScheduledEndTime = 0.0f;
while (!readyQueue.isEmpty()) {
ReadyQueueElement rqe = getNextReadyTask(readyQueue);
ReadyQueueElement rqe = getNextReadyTask(readyQueue, lastScheduledEndTime);
readyTask = rqe.getId();
if (checkDummy(readyTask)) {
this.dummies.set(readyTask, true);
......@@ -320,6 +322,7 @@ public class LNS extends Heuristics {
}
}
System.out.println("RUB IS " + rub);
System.out.println("Task 13 starts at " + endTime.get(12) + " or is it " + endTime.get(13));
return updateStructures(iniTime, endTime, computingNode, computingUnits, rub);
}
......
......@@ -21,7 +21,6 @@ import es.bsc.compss.log.Loggers;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
......@@ -227,8 +226,8 @@ public class LNSNL extends Heuristics {
}
// TODO: move it to a common class
public void releaseTasks(PriorityQueue readyQueue, DAG dag, int readyTask, ArrayList<Boolean> completed,
ArrayList<Float> endTime) {
public void releaseTasks(PriorityQueue<ReadyQueueElement> readyQueue, DAG dag, int readyTask,
ArrayList<Boolean> completed, ArrayList<Float> endTime) {
boolean[][] succ = dag.getSucc();
boolean ready;
for (int s = 0; s < this.n; ++s) { // start at 0 instead of readyTask + 1
......
......@@ -164,11 +164,13 @@ public class RTHeuristicsResourceScheduler<T extends WorkerResourceDescription>
succDSI.removePredecessor(action);
List<AllocatableAction> predecessors = succDSI.getPredecessors();
long taskId = ((((ExecutionAction) successor).getTask().getId() - 1) % this.scheduler.getNumTasks()) + 1;
/*LOGGER.debug("[RTResourceScheduler] Checking successors of action " + action +
", next task considered is " + successor + " with task id " + taskId);
LOGGER.debug("[RTResourceScheduler] For this task, hasPredecessors value is " + succDSI.hasPredecessors()
+ " and hasOpActionPred is " + succDSI.hasOpActionPred() + " and predecessors.size() is " +
predecessors.size() + " and resourceFree.isEmpty is " + resourceFree.isEmpty());*/
/*
* LOGGER.debug("[RTResourceScheduler] Checking successors of action " + action +
* ", next task considered is " + successor + " with task id " + taskId);
* LOGGER.debug("[RTResourceScheduler] For this task, hasPredecessors value is " + succDSI.hasPredecessors()
* + " and hasOpActionPred is " + succDSI.hasOpActionPred() + " and predecessors.size() is " +
* predecessors.size() + " and resourceFree.isEmpty is " + resourceFree.isEmpty());
*/
if (!succDSI.hasPredecessors()) {
// if successor does not have other predecessors, add them to resourceFree to be executed
if (resourceFree.isEmpty()) {
......
......@@ -586,17 +586,20 @@ public class RTHeuristicsScheduler extends TaskScheduler {
try {
transfer.schedule(transferScore);
} catch (BlockedActionException bae) {
ErrorManager.warn("[RTHeuristicsScheduler] Blocked scheduling for transfer action "
+ predecessor + " " + dp);
ErrorManager
.warn("[RTHeuristicsScheduler] Blocked scheduling for transfer action "
+ predecessor + " " + dp);
} catch (UnassignedActionException ise) {
ErrorManager.warn("[RTHeuristicsScheduler] Unassigned scheduling for transfer action "
+ predecessor + " " + dp);
ErrorManager
.warn("[RTHeuristicsScheduler] Unassigned scheduling for transfer action "
+ predecessor + " " + dp);
}
try {
transfer.tryToLaunch();
} catch (InvalidSchedulingException ise) {
ErrorManager.warn("[RTHeuristicsScheduler] Invalid scheduling for transfer action "
+ predecessor + " " + dp);
ErrorManager
.warn("[RTHeuristicsScheduler] Invalid scheduling for transfer action "
+ predecessor + " " + dp);
}
break; // for a specific parameter only one predecessor,
// so once it has been found stop
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment