Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CglKnapsackCover::exactSolveKnapsack returns suboptimal solutions #49

Open
tosttost opened this issue Oct 20, 2019 · 0 comments
Open

CglKnapsackCover::exactSolveKnapsack returns suboptimal solutions #49

tosttost opened this issue Oct 20, 2019 · 0 comments

Comments

@tosttost
Copy link
Contributor

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant