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

About get feasible solution from pulp and gurobi #788

Closed
davidzhr opened this issue Nov 28, 2024 · 4 comments
Closed

About get feasible solution from pulp and gurobi #788

davidzhr opened this issue Nov 28, 2024 · 4 comments

Comments

@davidzhr
Copy link

davidzhr commented Nov 28, 2024

What is your question

I am using pullp and gurobi solver im my project.

Usually I set the MipGap and TimeLimit to tell solver when it can stop find the better solution.

See below gurobi logs.

------------------------------ gurobi log--------------------------------------------------------------------------
2024-11-27 19:17:20,394 - INFO - 1975 1411 100.45425 43 45 109.88616 95.89462 12.7% 22.1 5s
2024-11-27 19:17:20,861 - INFO - H 1987 1347 109.8856560 95.89500 12.7% 22.0 5s
2024-11-27 19:17:21,769 - INFO - H 2078 1349 107.5550789 96.01789 10.7% 24.5 6s
2024-11-27 19:17:21,770 - INFO - H 2086 1283 107.5519338 96.01789 10.7% 24.5 6s
2024-11-27 19:17:22,608 - INFO - H 2125 1256 107.4454193 96.01789 10.6% 24.7 7s
2024-11-27 19:17:22,609 - INFO - H 2126 1197 105.2182115 96.01789 8.74% 24.7 7s
2024-11-27 19:17:25,075 - INFO - H16028 9636 105.2177856 98.06523 6.80% 20.6 9s
2024-11-27 19:17:25,076 - INFO - H16044 9616 105.1619561 98.06523 6.75% 20.6 9s
2024-11-27 19:17:25,409 - INFO - 17482 11176 98.59086 48 19 105.16196 98.06523 6.75% 20.4 10s
2024-11-27 19:17:33,776 - INFO - 43290 26882 98.06523 38 23 105.16196 98.06523 6.75% 22.8 18s
2024-11-27 19:17:35,375 - INFO - 43316 26899 102.22296 59 50 105.16196 98.06523 6.75% 22.8 20s
2024-11-27 19:17:40,337 - INFO - 43401 26956 100.63478 52 76 105.16196 98.06523 6.75% 22.8 25s
2024-11-27 19:17:42,082 - INFO - H 43430 25628 105.1619544 98.06523 6.75% 23.2 26s
2024-11-27 19:17:45,365 - INFO - 49232 27942 98.06523 48 38 105.16195 98.06523 6.75% 23.5 30s
2024-11-27 19:17:50,646 - INFO - 64696 33556 104.09758 70 14 105.16195 98.06523 6.75% 25.0 35s
2024-11-27 19:17:56,433 - INFO - 72014 34998 99.71859 67 30 105.16195 98.06523 6.75% 26.2 41s
2024-11-27 19:18:00,705 - INFO - 76595 36696 98.61314 58 38 105.16195 98.06523 6.75% 27.1 45s
2024-11-27 19:18:06,488 - INFO - 82415 38771 98.06523 55 23 105.16195 98.06523 6.75% 28.6 51s
2024-11-27 19:18:11,528 - INFO - 86878 40452 103.76532 77 22 105.16195 98.06523 6.75% 30.0 56s
2024-11-27 19:18:16,893 - INFO - 91656 41825 101.63235 66 21 105.16195 98.06523 6.75% 31.3 61s
2024-11-27 19:18:22,359 - INFO - 96182 42873 101.54738 69 26 105.16195 98.06523 6.75% 32.4 67s
2024-11-27 19:18:22,364 - INFO - H 96183 41589 105.1608547 98.06523 6.75% 32.4 67s
2024-11-27 19:18:29,368 - INFO - 100569 42677 98.46351 59 40 105.16085 98.06523 6.75% 33.6 74s
2024-11-27 19:18:32,197 - INFO - 102113 43588 103.92169 71 22 105.16085 98.06523 6.75% 34.0 76s
2024-11-27 19:18:36,682 - INFO - 106855 44487 98.11053 45 56 105.16085 98.06523 6.75% 35.3 81s
2024-11-27 19:18:42,249 - INFO - 110413 46671 99.22062 57 35 105.16085 98.06523 6.75% 36.4 86s
2024-11-27 19:18:45,704 - INFO - 112779 47907 98.50856 70 38 105.16085 98.06523 6.75% 37.2 90s
2024-11-27 19:18:51,493 - INFO - 118412 49852 99.12550 64 24 105.16085 98.06523 6.75% 38.4 96s
2024-11-27 19:18:55,911 - INFO - 123071 53063 98.06523 49 49 105.16085 98.06523 6.75% 39.6 100s
2024-11-27 19:19:03,521 - INFO - 129214 56838 98.06523 53 48 105.16085 98.06523 6.75% 41.2 108s
2024-11-27 19:19:07,285 - INFO - 131078 59147 98.55890 57 27 105.16085 98.06523 6.75% 41.6 111s
2024-11-27 19:19:10,671 - INFO - 134718 61217 98.29175 56 46 105.16085 98.06523 6.75% 42.1 115s
2024-11-27 19:19:15,346 - INFO - 140541 63929 98.45910 54 62 105.16085 98.06523 6.75% 42.8 120s
2024-11-27 19:19:15,367 - INFO -
2024-11-27 19:19:15,367 - INFO - Cutting planes:
2024-11-27 19:19:15,368 - INFO - Learned: 57
2024-11-27 19:19:15,368 - INFO - Gomory: 31
2024-11-27 19:19:15,368 - INFO - Cover: 58
2024-11-27 19:19:15,368 - INFO - Implied bound: 10
2024-11-27 19:19:15,368 - INFO - Projected implied bound: 59
2024-11-27 19:19:15,368 - INFO - MIR: 986
2024-11-27 19:19:15,368 - INFO - StrongCG: 2
2024-11-27 19:19:15,368 - INFO - Flow cover: 613
2024-11-27 19:19:15,368 - INFO - RLT: 6
2024-11-27 19:19:15,368 - INFO - Relax-and-lift: 7
2024-11-27 19:19:15,372 - INFO -
2024-11-27 19:19:15,373 - INFO - Explored 142086 nodes (6113351 simplex iterations) in 120.04 seconds (85.47 work units)
2024-11-27 19:19:15,373 - INFO - Thread count was 16 (of 16 available processors)
2024-11-27 19:19:15,373 - INFO -
2024-11-27 19:19:15,373 - INFO - Solution count 10: 105.161 105.162 105.218 ... 113.288
2024-11-27 19:19:15,373 - INFO -
2024-11-27 19:19:15,373 - INFO - Time limit reached
2024-11-27 19:19:15,383 - INFO - Warning: max constraint violation (1.0000e-06) exceeds tolerance
2024-11-27 19:19:15,383 - INFO - Best objective 1.051608556929e+02, best bound 9.806523446154e+01, gap 6.7474%

---------------------------log end----------------------------------------------------------------------------------------------

From the log, you will see that Gurobi has found some feasible solutions, but it reaches the time-limit value and the gap is greater than 0.05 that i set. For this case, pulp will repot that the solver does not find the optimal solution. In fact, sometimes the better feasible solution in feasible solution pool can meet the problem's requirements.

How to handle this case in pulp?

@stumitchell
Copy link
Contributor

Pulp will still report the best solution found in this case,
So in this case the status will be LpStatusNotSolved however if you inspect the solver models status you will see it is GRB.TIME_LIMIT

@davidzhr
Copy link
Author

Yes, The status of gurobi solver is GRB.TIME_LIMIT. for some cases, gurobi has found some feasible solutions, but gurobi has not proven that the current suolution is optimal. For such case, how to get the incumbent solution from pulp?

And i searched the previous issue list. i know the work around is using GUROBI_CMD.

@stumitchell

@stumitchell
Copy link
Contributor

what version are you using anything higher than 2.8.0 should just return the incumbent

@stumitchell
Copy link
Contributor

@davidzhr do you still have an issue with the latest release?

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

2 participants