Commit 6f1cfdbb authored by EYRAUD-DUBOIS Lionel's avatar EYRAUD-DUBOIS Lionel
Browse files

Version B of HLP, proposed by Vincent Fagnon

From https://arxiv.org/abs/1912.03088
parent 07183544
......@@ -351,6 +351,15 @@ void ProgramOptions::insertComputable(vector< pair<A, AlgOptions> > & elems, str
name = "greedy";
additionalOptions = "key=depNoHybrid[alloc]";
}
if(name == "hlpb") {
static bool hlpbAlreadyUsed = false;
if(! hlpbAlreadyUsed) {
insertBound("dep:hybrid=no:share=depNoHybridBversion:bversion=true");
hlpbAlreadyUsed = true;
}
name = "greedy";
additionalOptions = "key=depNoHybridBversion[alloc]";
}
for(AlgOptions options: optList) {
if(!additionalOptions.empty())
options.parse(additionalOptions);
......
......@@ -11,6 +11,7 @@ DepBound::DepBound(const AlgOptions & options) {
mode = options.asString("mode", "normal");
outputInteger=options.isPresent("outint");
shareKey = options.asString("share", "");
bVersion = options.isPresent("bversion");
integerSolution = false;
}
......@@ -166,12 +167,38 @@ vector<int> DepBound::getAllocTasks() {
for(int i = 0; i < nbTasks; i++) {
if(isRemoved[i]) continue;
double val = idcCplex.getValue(wType[i][0]);
result[i] = 0;
for(int j = 1; j < instance->nbWorkerTypes; j++)
if(idcCplex.getValue(wType[i][j]) > val) {
result[i] = j;
val = idcCplex.getValue(wType[i][j]);
result[i] = 0;
if(bVersion) {
// Rounding from algorithms in https://arxiv.org/abs/1912.03088
if (instance->nbWorkerTypes > 2) {
cerr << "B Version of HLP only works with two worker types" << endl;
throw(1);
}
int largestWorkers = max(instance->nbWorkers[0], instance->nbWorkers[1]);
int smallestWorkers = min(instance->nbWorkers[0], instance->nbWorkers[1]);
double r = ((double)smallestWorkers)/((double)largestWorkers);
double unsurb;
if (r < 1) {
unsurb = 1/(1 + sqrt((2-r)/(1-r)));
} else {
unsurb = 0.0;
}
if(idcCplex.getValue(wType[i][0]) <= unsurb) {
result[i] = 1;
} else if (idcCplex.getValue(wType[i][1] <= unsurb)) {
result[i] = 0;
} else {
result[i] = 0;
if(instance->execType(0, i) > instance->execType(1, i))
result[i] = 1;
}
} else {
for(int j = 1; j < instance->nbWorkerTypes; j++)
if(idcCplex.getValue(wType[i][j]) > val) {
result[i] = j;
val = idcCplex.getValue(wType[i][j]);
}
}
}
return result;
......
......@@ -22,6 +22,8 @@ class DepBound : public ModifiableBound {
// int firstlimit;
std::string mode;
std::string shareKey;
// True if we should use the rounding from https://arxiv.org/abs/1912.03088
bool bVersion;
unsigned int nbWorkerTypes;
unsigned int nbTasks;
......
Supports Markdown
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