use of es.bsc.compss.scheduler.multiobjective.types.OptimizationWorker in project compss by bsc-wdc.
the class MOScheduleOptimizer method globalOptimization.
/*--------------------------------------------------
---------------------------------------------------
--------------- Local optimization ---------------
---------------------------------------------------
--------------------------------------------------*/
@SuppressWarnings("unchecked")
public void globalOptimization(long optimizationTS, Collection<ResourceScheduler<? extends WorkerResourceDescription>> workers) {
LOGGER.debug(LOG_PREFIX + " --- Start Global Optimization ---");
int workersCount = workers.size();
if (workersCount == 0) {
return;
}
OptimizationWorker[] optimizedWorkers = new OptimizationWorker[workersCount];
LinkedList<OptimizationWorker> receivers = new LinkedList<>();
int i = 0;
for (ResourceScheduler<? extends WorkerResourceDescription> worker : workers) {
optimizedWorkers[i] = new OptimizationWorker((MOResourceScheduler<WorkerResourceDescription>) worker);
i++;
}
boolean hasDonated = true;
while (hasDonated) {
optimizationTS = System.currentTimeMillis();
hasDonated = false;
LOGGER.debug(LOG_PREFIX + " --- Iteration of global Optimization ---");
// Perform local optimizations
for (OptimizationWorker ow : optimizedWorkers) {
LOGGER.debug(LOG_PREFIX + "Optimizing localy resource " + ow.getName());
ow.localOptimization(optimizationTS);
LOGGER.debug(LOG_PREFIX + "Resource " + ow.getName() + " will end at " + ow.getDonationIndicator());
}
LinkedList<OptimizationWorker> donors = determineDonorAndReceivers(optimizedWorkers, receivers);
while (!hasDonated && !donors.isEmpty()) {
OptimizationWorker donor = donors.remove();
AllocatableAction candidate;
while (!hasDonated && (candidate = donor.pollDonorAction()) != null) {
/*
* if (candidate == null) { break; }
*/
Iterator<OptimizationWorker> recIt = receivers.iterator();
while (recIt.hasNext()) {
OptimizationWorker receiver = recIt.next();
if (move(candidate, donor, receiver)) {
hasDonated = true;
break;
}
}
}
}
LOGGER.debug(LOG_PREFIX + "--- Optimization Iteration finished ---");
}
LOGGER.debug(LOG_PREFIX + "--- Global Optimization finished ---");
}
use of es.bsc.compss.scheduler.multiobjective.types.OptimizationWorker in project compss by bsc-wdc.
the class MOScheduleOptimizer method determineDonorAndReceivers.
public static LinkedList<OptimizationWorker> determineDonorAndReceivers(OptimizationWorker[] workers, LinkedList<OptimizationWorker> receivers) {
receivers.clear();
PriorityQueue<OptimizationWorker> receiversPQ = new PriorityQueue<OptimizationWorker>(1, getReceptionComparator());
long topIndicator = Long.MIN_VALUE;
LinkedList<OptimizationWorker> top = new LinkedList<>();
for (OptimizationWorker ow : workers) {
long indicator = ow.getDonationIndicator();
if (topIndicator > indicator) {
receiversPQ.add(ow);
} else {
if (indicator > topIndicator) {
topIndicator = indicator;
for (OptimizationWorker extop : top) {
receiversPQ.add(extop);
}
top.clear();
}
top.add(ow);
}
}
OptimizationWorker ow;
while ((ow = receiversPQ.poll()) != null) {
receivers.add(ow);
}
return top;
}
Aggregations