...
 
Commits (2)
#ifndef AVAILSEQUENCE_H
#define AVAILSEQUENCE_H
#include <list>
#include <vector>
#include <ostream>
class Period {
......@@ -11,7 +11,7 @@ class Period {
Period() {}
Period(double s, double e) : start(s), end(e) {}
};
typedef std::list<Period> timeSeq;
typedef std::vector<Period> timeSeq;
class AvailSequence {
......
......@@ -47,22 +47,21 @@ double HeftAlgorithm::compute(Instance& ins, SchedAction *action) {
if(verbosity >= 4)
cout << "HEFT: considering task " << i << endl;
k = 0;
double depTime = 0;
for(j = 0; j < (int) ins.dependencies[i].size(); j++) {
depTime = std::max(depTime, endtimesTasks[ins.dependencies[i][j]]);
}
for(int& d: ins.dependencies[i])
depTime = std::max(depTime, endtimesTasks[d]);
double bestTime = std::numeric_limits<double>::infinity();
double bestStart = -1;
int bestK = 0; int bestT = 0;
k = 0;
timeSeq::iterator bestPeriod; // Should belond to workerAvailability[bestK]
for(t = 0; t < ins.nbWorkerTypes; t++) {
for(j = 0; j < ins.nbWorkers[t]; j++, k++) {
double e = -1; double l = ins.execType(t, i);
if(ins.isValidValue(l)) {
timeSeq::iterator p = workerAvailability[k].getAvail(depTime, l, e);
if(e +l < bestTime){
if(e + l < bestTime){
bestK = k;
bestTime = e + l;
bestStart = e;
......@@ -83,12 +82,11 @@ double HeftAlgorithm::compute(Instance& ins, SchedAction *action) {
workerAvailability[bestK].insertBusy(bestPeriod, startTime, ins.execType(bestT, i));
endtimesTasks[i] = bestTime;
for(j = 0; j < (int) revDependencies[i].size(); j++) {
int k = revDependencies[i][j];
nbDep[k]--;
if(nbDep[k] == 0){
queue->insert(k);
if(action != NULL) action->onTaskPush(i);
for(int &d: revDependencies[i]) {
nbDep[d]--;
if(nbDep[d] == 0){
queue->insert(d);
if(action != NULL) action->onTaskPush(d);
}
}
}
......
......@@ -29,12 +29,12 @@ void AvailSequence::insertBusy(timeSeq::iterator i, double start, double len) {
Period orig = *i;
auto j = seq.erase(i);
if(orig.start < start) {
Period before(orig.start, start);
seq.insert(j, before);
// Period before(orig.start, start);
seq.emplace(j, orig.start, start);
}
if(orig.end > start + len) {
Period after(start + len, orig.end);
seq.insert(j, after);
// Period after(start + len, orig.end);
seq.emplace(j, start+len, orig.end);
}
}
......