问题
I faced a problem while using addMIPStart().
At first, for testing purpose, I took a generalized assignment problem (has only one set of binary decision variables x[i][]j) and add a bound using addMIPStart(). It has worked perfectly.
But, when I was trying the same on my own problem, I got an error problem CPLEX: "IloExtractable 189 IloNumVarl has not been extracted by Iloalgorithm 000001ECF89B160".
In my problem, there are four types of variables:
x[k][p][t] = IloNumVar(env, 0.0, 1, ILOINT, name.str().c_str()); //binary
y[p][t] = IloNumVar(env, 0.0, 1, ILOINT, name.str().c_str()); //binary
z[k][p][t] = IloNumVar(env, 0.0, 1, ILOINT, name.str().c_str()); //binary
w[p][t] = IloNumVar(env, 0.0, IloInfinity, ILOINT, name.str().c_str()); //pure integer
Now, I have added the following piece of code ......................
/*************************************************/
IloNumVarArray startVar(env);
IloNumArray startVal(env);
IloNum remExtResource = 0;
IloInt cutOffTime = 0;
IloInt totExtResource = 0;
for (k = 0; k < K; k++) {
for (p = 0; p<P; p++) {
for (t = 0; t<T + 2; t++) {
startVar.add(x[k][p][t]);
startVal.add(0);
}
}
}
for (k = 0; k < K; k++) {
for (p = 0; p<P2; p++) {
for (t = 0; t<T + 1; t++) {
startVar.add(z[k][p][t]);
startVal.add(0);
}
}
}
for (p = 0; p<P2; p++) {
totExtResource = ceil(D[p] / a_e[p]);
cutOffTime = ceil(totExtResource / Q[p]);
for (t_p = 0; t_p<T + 2; t_p++) {
if (t <= cutOffTime){
startVar.add(y[p][t]);
startVal.add(0);
}
if (t > cutOffTime){
startVar.add(y[p][t]);
startVal.add(1);
}
}
totExtResource = 0;
cutOffTime = 0;
}
for (p = 0; p<P2; p++) {
remExtResource = ceil(D[p] / a_e[p]);
for (t = 0; t<T + 1; t++) {
if (t == 0) {
startVar.add(w[p][t]);
startVal.add(0);
}
else {
if (remExtResource == 0) {
startVar.add(w[p][t]);
startVal.add(0);
}
else if ((remExtResource > 0) && (remExtResource <= Q[p])) {
startVar.add(w[p][t]);
startVal.add(remExtResource);
remExtResource = 0;
}
else {
startVar.add(w[p][t]);
startVal.add(Q[p]);
remExtResource = remExtResource - Q[p];
}
}
}
remExtResource = 0;
}
// cplex.addMIPStart(startVar, startVal, IloCplex::MIPStartAuto, "secondMIPStart");
cplex.addMIPStart(startVar, startVal);
startVal.end();
startVar.end();
/*************************************************/
As a starting solution, I make all the x-variables and z-variables to 0. And based on some logic some y-variables are 0 and some are 1, whereas some w-variables are assigned to full capacity Q[p], whereas others are 0.
It has the same logic I have followed but could find what I have missed here. Could you please help me?
回答1:
Most often when I have seen this sort of error it's because I am trying to add a mipstart value for a variable that is not in my problem. Eg the variables are declared but not involved in any constraints or in the objective, so cplex doesn't have them in its extracted model.
来源:https://stackoverflow.com/questions/43802501/error-in-using-addmipstart-in-cplex-c