COIN-OR::LEMON - Graph Library

Opened 15 years ago

Closed 15 years ago

#334 closed defect (fixed)

MIP solver gives wrong solution

Reported by: Akos Ladanyi Owned by: Balazs Dezso
Priority: critical Milestone: LEMON 1.2 release
Component: core Version: hg main
Keywords: Cc:
Revision id: 9cc6e98c487d

Description

The program below gives x=1, y=0 as solution with LEMON 1.1.1, but with [9cc6e98c487d] the solution is x=1, y=1 (both with Glpk and Cbc).

#include <iostream>

#include <lemon/glpk.h>
#include <lemon/cbc.h>

int main()
{
    typedef lemon::GlpkMip MIP;
    //typedef lemon::CbcMip MIP;

    MIP mip;

    MIP::Col x, y;
    x = mip.addCol();
    y = mip.addCol();

    MIP::Expr e(x - 1.0);
    mip.addRow(e <= y);

    mip.colLowerBound(y, 0.0);

    mip.colType(x, MIP::INTEGER);
    mip.colBounds(x, 1.0, 2.0);

    mip.obj(y);
    mip.min();

    if (mip.solve() != MIP::SOLVED ||
        mip.type() != MIP::OPTIMAL)
    {
        std::cout << "could not solve it" << std::endl;
        return 0;
    }

    std::cout << "x=" << mip.sol(x) << std::endl;
    std::cout << "y=" << mip.sol(y) << std::endl;

    return 0;
}

Attachments (1)

207ba6c0f2e4.patch (1017 bytes) - added by Balazs Dezso 15 years ago.
Fix addRow

Download all attachments as: .zip

Change History (6)

Changed 15 years ago by Balazs Dezso

Attachment: 207ba6c0f2e4.patch added

Fix addRow

comment:1 Changed 15 years ago by Peter Kovacs

Milestone: LEMON 1.2 release

What should we do with this ticket? Does the patch correctly fix the problem?

comment:2 in reply to:  1 ; Changed 15 years ago by Akos Ladanyi

Replying to kpeter:

Does the patch correctly fix the problem?

Yes, it does.

comment:3 in reply to:  2 ; Changed 15 years ago by Alpar Juttner

Replying to ladanyi:

Replying to kpeter:

Does the patch correctly fix the problem?

Yes, it does.

Could you please rebase this changeset so that I can also merge it into the 1.1 branch?

E.g. on the top of [994c7df296c9].

comment:4 in reply to:  3 ; Changed 15 years ago by Balazs Dezso

Replying to alpar:

Could you please rebase this changeset so that I can also merge it into the 1.1 branch?

This bug is introduced in 793:[e4554cd6b2bf], which is not in the 1.1 branch. See: hg log -P 894 lemon/lp_base.h

Do you know easier solution for deciding wheter rev A is an ancestor of rev B?

comment:5 in reply to:  4 Changed 15 years ago by Alpar Juttner

Resolution: fixed
Status: newclosed

Replying to deba:

Replying to alpar:

Could you please rebase this changeset so that I can also merge it into the 1.1 branch?

This bug is introduced in 793:[e4554cd6b2bf], which is not in the 1.1 branch. See: hg log -P 894 lemon/lp_base.h

Sorry, I misread the description of the ticket.

[207ba6c0f2e4] is in the main branch now.

Do you know easier solution for deciding wheter rev A is an ancestor of rev B?

hg debugancestor A B

This tells you the greatest common ancestor(s). Iff the answer is A, then A is an ancestor of B.

Note: See TracTickets for help on using tickets.