Cgl
Cgl copied to clipboard
CglKnapsackCover::exactSolveKnapsack returns suboptimal solutions
CglKnapsackCover::exactSolveKnapsack sometimes returns suboptimal solutions. Example:
int main()
{
const int n = 6;
const double c = 7.0;
const double pp[] = { 10.0, 5.0, 2, 2, 1.4, 1.1 };
const double ww[] = { 2.0, 2.0, 2, 2, 1.5, 1.4 };
//verify that items are sorted
for(int i = 1; i < n; ++i)
{
assert(pp[i] / ww[i] <= pp[i - 1] / ww[i - 1]);
}
double z = 42;
int* x = new int[n];
exactSolveKnapsack(n, c, pp, ww, z, x);
printf("z=%f\n", z);
assert(fabs(z - 17.5) < 1e-3);
delete[] x;
}
In fact Matthew Galati beat me by 6 years: https://list.coin-or.org/pipermail/cgl/2013-July/000156.html See his post for details.
I verified that the profits are in fact fractional - simply put a "printf" into the function... Based on the comments inside CglKnapsackCover::findExactMostViolatedMinCover it looks like this can lead to weaker (as Matthew suspected) or missed cuts (if the knapsack solution is suboptimal, "oofv = (sum (1-xstar_j))- max sum (1-xstar)y_j" gets larger and the test "oofv < 1" might fail).
By the way: there some typos in CglKnapsackCover.cpp: "inequalty", "appraoch"