coin-or / pulp

A python Linear Programming API
http://coin-or.github.io/pulp/
Other
2.04k stars 381 forks source link

Infeasible using PULP_CBC_CMD #662

Open etiennecallies opened 1 year ago

etiennecallies commented 1 year ago

Hi,

I'm using PuLP==2.7.0 (tried also to install pulp from source).

I got Infeasible status on this solvable problem :

    lp_problem = LpProblem('my_problem', LpMinimize)

    x_0 = LpVariable('x_0', lowBound=0, upBound=1, cat='Integer')
    x_1 = LpVariable('x_1', lowBound=0, upBound=1, cat='Integer')
    x_2 = LpVariable('x_2', lowBound=0, upBound=1, cat='Integer')
    c_0 = LpVariable('c_0', lowBound=0, upBound=1, cat='Integer')
    c_1 = LpVariable('c_1', lowBound=0, upBound=1, cat='Integer')

    # objective
    lp_problem += c_0 + c_1

    # constraints
    lp_problem += x_0 + c_1 == 1

    lp_problem += x_0 + c_0 >= 1
    lp_problem += x_1 + c_1 <= 1
    lp_problem += c_0 + c_1 <= 1

    lp_problem += x_2 == 1

    lp_problem += 9000 * x_1 + 7200 * x_2 + 10800 * c_1 >= 16200

    print(lp_problem)
    lp_problem.solve(PULP_CBC_CMD(msg=True))
    print(LpStatus[lp_problem.status])

It is indeed solvable if all x are 1 and c are 0. Whenever I try to reduce it , I got Optimal. For example when I use this constraint :

# lp_problem += 9000 * x_1 + 7200 * x_2 + 10800 * c_1 >= 16200
lp_problem += 900 * x_1 + 720 * x_2 + 1080 * c_1 >= 1620

Or even when I rename some variable.

Am I doing sth wrong, or is there a bug?

Details for the issue

What did you expect to see?

I expected the problem to be solvable.

What did you see instead?

I got Infeasible.

Useful extra information

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

I'm using python version:

I installed PuLP via:

Did you also

Thanks

pchtsp commented 7 months ago

Indeed, if I try with CPLEX it returns optimal.

I recommend you to transfer this issue to the cbc team in https://github.com/coin-or/Cbc Ideally, by sharing the mps file using lp_problem.writeMPS("error.mps").

etiennecallies commented 7 months ago

Hi @pchtsp ! Thanks for having looked at it. I just submitted this issue on CBC repo: https://github.com/coin-or/Cbc/issues/632